@antv/dumi-theme-antv 0.8.0-beta.1 → 0.8.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builtins/Playground/index.module.less +0 -1
- package/dist/components/AI/HomeDialog/AntVBanner/index.module.less +2 -2
- package/dist/components/AI/HomeDialog/ModeSelector/index.js +4 -1
- package/dist/components/AI/HomeDialog/ModeSelector/index.module.less +39 -22
- package/dist/components/AI/HomeDialog/PromptTextarea/ChooseLib/index.js +5 -2
- package/dist/components/AI/HomeDialog/PromptTextarea/ChooseLib/index.module.less +0 -1
- package/dist/components/AI/HomeDialog/PromptTextarea/DatasourceCard/index.module.less +3 -3
- package/dist/components/AI/HomeDialog/PromptTextarea/Uploader/DataUploader.js +225 -0
- package/dist/components/AI/HomeDialog/PromptTextarea/index.js +61 -36
- package/dist/components/AI/HomeDialog/PromptTextarea/index.module.less +9 -8
- package/dist/components/AI/HomeDialog/RecommendCase/Card.js +13 -8
- package/dist/components/AI/HomeDialog/RecommendCase/card.module.less +1 -1
- package/dist/components/AI/HomeDialog/RecommendCase/index.js +45 -13
- package/dist/components/AI/HomeDialog/RecommendCase/index.module.less +3 -2
- package/dist/components/AI/HomeDialog/index.js +17 -4
- package/dist/components/AI/constant.js +2 -2
- package/dist/components/Login/Captcha/index.js +185 -0
- package/dist/components/Login/Captcha/index.less +91 -0
- package/dist/components/Login/CheckCode/index.js +244 -0
- package/dist/components/Login/CheckCode/index.less +137 -0
- package/dist/components/Login/CountDownButton/index.js +109 -0
- package/dist/components/Login/CountDownButton/index.less +8 -0
- package/dist/components/Login/LoginForm.js +239 -0
- package/dist/components/Login/LoginForm.less +409 -0
- package/dist/components/Login/index.js +24 -0
- package/dist/components/Login/openAuthWindow.js +54 -0
- package/dist/components/Login/types.js +5 -0
- package/dist/components/Login/utils.js +47 -0
- package/dist/layouts/DocLayout.js +2 -1
- package/dist/layouts/GlobalLayout/index.js +10 -4
- package/dist/locales/en.json +121 -1
- package/dist/locales/zh.json +121 -1
- package/dist/model/AIChat.js +65 -7
- package/dist/model/auth.js +133 -0
- package/dist/pages/AIPlayground/components/ConversationsMenu/index.js +28 -10
- package/dist/pages/AIPlayground/components/ConversationsMenu/index.module.less +2 -0
- package/dist/pages/AIPlayground/components/MarkdownComponent/MarkdownCodeBlock.js +25 -11
- package/dist/pages/AIPlayground/components/MarkdownComponent/MarkdownCodeBlock.module.less +1 -2
- package/dist/pages/AIPlayground/components/MarkdownComponent/index.js +5 -2
- package/dist/pages/AIPlayground/components/MsgBox/index.js +198 -136
- package/dist/pages/AIPlayground/components/MsgBox/index.module.less +3 -2
- package/dist/pages/AIPlayground/components/MsgBox/useAutoScroll.js +46 -0
- package/dist/pages/AIPlayground/components/SessionLayout/index.js +18 -10
- package/dist/pages/AIPlayground/components/SessionLayout/index.module.less +3 -1
- package/dist/pages/AIPlayground/components/TaskBox/generateCode.js +7 -1
- package/dist/pages/AIPlayground/components/TaskBox/index.js +79 -55
- package/dist/pages/AIPlayground/components/TaskBox/index.module.less +1 -0
- package/dist/pages/Examples/components/Accouncement/index.module.less +1 -1
- package/dist/pages/Examples/index.module.less +11 -11
- package/dist/pages/Index/components/Cases/index.module.less +8 -8
- package/dist/pages/Index/components/Companies/index.module.less +4 -3
- package/dist/pages/Index/components/Features/FeatureCard.module.less +4 -5
- package/dist/pages/Index/components/Features/index.module.less +5 -5
- package/dist/pages/Index/components/_.less +9 -9
- package/dist/plugin/index.js +2 -2
- package/dist/slots/Banner/Notification.module.less +8 -8
- package/dist/slots/Banner/index.module.less +10 -9
- package/dist/slots/CodeEditor/Toolbar.js +15 -9
- package/dist/slots/CodeEditor/index.js +19 -10
- package/dist/slots/CodeEditor/index.module.less +3 -0
- package/dist/slots/CodePreview/index.module.less +0 -3
- package/dist/slots/CodeRunner/index.js +5 -2
- package/dist/slots/ContentTable/index.module.less +2 -1
- package/dist/slots/Detail/News.module.less +9 -9
- package/dist/slots/Detail/index.module.less +11 -14
- package/dist/slots/ExampleSider/index.module.less +3 -4
- package/dist/slots/Footer/index.module.less +2 -2
- package/dist/slots/Header/Products/Product.module.less +2 -2
- package/dist/slots/Header/Search/SearchResult.js +23 -8
- package/dist/slots/Header/Search/SearchResult.module.less +1 -0
- package/dist/slots/Header/index.js +56 -11
- package/dist/slots/Header/index.module.less +13 -5
- package/dist/slots/LiveExample/index.module.less +1 -1
- package/dist/slots/Loading/index.module.less +30 -28
- package/dist/slots/ManualContent/index.module.less +14 -17
- package/dist/slots/_.less +9 -9
- package/dist/static/user.svg +3 -0
- package/dist/utils/env.js +37 -0
- package/dist/utils/request.js +42 -0
- package/package.json +7 -2
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
3
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
4
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
5
|
+
import { pickBy } from 'lodash';
|
|
6
|
+
export var AuthScene = /*#__PURE__*/function (AuthScene) {
|
|
7
|
+
AuthScene["LOGIN"] = "login";
|
|
8
|
+
AuthScene["GET_ACCESS_TOKEN"] = "get_access_token";
|
|
9
|
+
return AuthScene;
|
|
10
|
+
}({});
|
|
11
|
+
var AUTH_BROADCAST_CHANNEL_NAME = 'WeaveFox-Auth';
|
|
12
|
+
var AuthSceneUrlMap = _defineProperty(_defineProperty({}, AuthScene.LOGIN, '/login/github/oauth'), AuthScene.GET_ACCESS_TOKEN, '/login/github/access_token');
|
|
13
|
+
export function openAuthWindow(params) {
|
|
14
|
+
try {
|
|
15
|
+
var _ref = params || {},
|
|
16
|
+
onSuccess = _ref.onSuccess,
|
|
17
|
+
onFail = _ref.onFail,
|
|
18
|
+
scene = _ref.scene,
|
|
19
|
+
sceneParams = _ref.sceneParams;
|
|
20
|
+
var broadcast = new BroadcastChannel(AUTH_BROADCAST_CHANNEL_NAME);
|
|
21
|
+
var cleanedParams = pickBy(sceneParams, function (val) {
|
|
22
|
+
return val !== undefined && val !== null;
|
|
23
|
+
});
|
|
24
|
+
var sceneParamsString = new URLSearchParams(cleanedParams).toString();
|
|
25
|
+
sceneParamsString = sceneParamsString ? "?".concat(sceneParamsString) : '';
|
|
26
|
+
window.open(AuthSceneUrlMap[scene] + sceneParamsString, 'github_auth', 'left=0,top=0,width=600,height=600');
|
|
27
|
+
var handler = function handler(event) {
|
|
28
|
+
if (event.data.source !== 'WeaveFox-Auth') return;
|
|
29
|
+
// 验证来源是否可信
|
|
30
|
+
if (event.origin !== window.location.origin) {
|
|
31
|
+
console.warn('Untrusted origin: ', event.origin);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (event.data.success) {
|
|
35
|
+
if (onSuccess) {
|
|
36
|
+
onSuccess(event.data);
|
|
37
|
+
}
|
|
38
|
+
} else if (onFail) {
|
|
39
|
+
onFail(event.data);
|
|
40
|
+
}
|
|
41
|
+
window.removeEventListener('message', handler);
|
|
42
|
+
broadcast.removeEventListener('message', handler);
|
|
43
|
+
};
|
|
44
|
+
window.addEventListener('message', handler, false);
|
|
45
|
+
broadcast.addEventListener('message', handler, false);
|
|
46
|
+
|
|
47
|
+
// 未解之谜,窗口可能会丢失 opener 信息,暂时用 5s 后强制刷新解决
|
|
48
|
+
setTimeout(function () {
|
|
49
|
+
window.location.reload();
|
|
50
|
+
}, 5000);
|
|
51
|
+
} catch (e) {
|
|
52
|
+
console.error('auth unexpected error', e);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
+
import FingerprintJS from '@fingerprintjs/fingerprintjs';
|
|
6
|
+
export var chinaMobilePhoneRE = /^(13\d|14\d|15[012356789]|16[567]|17[01235678]|18\d|19\d)\d{8}(\+\d+)?$/;
|
|
7
|
+
export var SignupRegion = /*#__PURE__*/function (SignupRegion) {
|
|
8
|
+
SignupRegion["oversea"] = "oversea";
|
|
9
|
+
SignupRegion["possible_oversea"] = "possible_oversea";
|
|
10
|
+
return SignupRegion;
|
|
11
|
+
}({}); // 可能是海外(不确定/待确认)
|
|
12
|
+
export function getFingerprint() {
|
|
13
|
+
return _getFingerprint.apply(this, arguments);
|
|
14
|
+
}
|
|
15
|
+
function _getFingerprint() {
|
|
16
|
+
_getFingerprint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
17
|
+
var fp, result;
|
|
18
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
19
|
+
while (1) switch (_context.prev = _context.next) {
|
|
20
|
+
case 0:
|
|
21
|
+
_context.next = 2;
|
|
22
|
+
return FingerprintJS.load();
|
|
23
|
+
case 2:
|
|
24
|
+
fp = _context.sent;
|
|
25
|
+
_context.next = 5;
|
|
26
|
+
return fp.get();
|
|
27
|
+
case 5:
|
|
28
|
+
result = _context.sent;
|
|
29
|
+
return _context.abrupt("return", result);
|
|
30
|
+
case 7:
|
|
31
|
+
case "end":
|
|
32
|
+
return _context.stop();
|
|
33
|
+
}
|
|
34
|
+
}, _callee);
|
|
35
|
+
}));
|
|
36
|
+
return _getFingerprint.apply(this, arguments);
|
|
37
|
+
}
|
|
38
|
+
export var NC_SCENE = /*#__PURE__*/function (NC_SCENE) {
|
|
39
|
+
NC_SCENE["login"] = "login";
|
|
40
|
+
NC_SCENE["register"] = "register";
|
|
41
|
+
NC_SCENE["verifyUser"] = "verify_user";
|
|
42
|
+
NC_SCENE["registerH5"] = "nc_register_h5";
|
|
43
|
+
NC_SCENE["loginH5"] = "nc_login_h5";
|
|
44
|
+
NC_SCENE["reset"] = "nc_reset";
|
|
45
|
+
return NC_SCENE;
|
|
46
|
+
}({});
|
|
47
|
+
export var UIA_UA_RE = /Macaca UI Robot/;
|
|
@@ -14,6 +14,7 @@ import ManualLayout from "./ManualLayout";
|
|
|
14
14
|
import GlobalStyles from "../common/GlobalStyles";
|
|
15
15
|
import { defaultToken } from "../common/styles/theme";
|
|
16
16
|
import "../static/style";
|
|
17
|
+
import { LoginModal } from "../components/Login";
|
|
17
18
|
/**
|
|
18
19
|
* DocLayout 是 dumi2 的内置 layout 入口,在这里使用页面路径进行区分成自己不同的 Layout。
|
|
19
20
|
*/
|
|
@@ -107,5 +108,5 @@ export default (function () {
|
|
|
107
108
|
token: defaultToken,
|
|
108
109
|
hashed: false
|
|
109
110
|
}
|
|
110
|
-
}, /*#__PURE__*/React.createElement(GlobalStyles, null), content)));
|
|
111
|
+
}, /*#__PURE__*/React.createElement(GlobalStyles, null), content, /*#__PURE__*/React.createElement(LoginModal, null))));
|
|
111
112
|
});
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
2
|
-
import { useOutlet } from 'dumi';
|
|
3
1
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
4
|
-
import
|
|
2
|
+
import * as antd from 'antd';
|
|
3
|
+
import { useOutlet } from 'dumi';
|
|
4
|
+
import React, { useEffect } from 'react';
|
|
5
|
+
import { initializeAIChat } from "../../model/AIChat";
|
|
6
|
+
import { initializeAuth } from "../../model/auth";
|
|
5
7
|
var queryClient = new QueryClient();
|
|
6
8
|
var GlobalLayout = function GlobalLayout() {
|
|
7
9
|
var outlet = useOutlet();
|
|
8
10
|
useEffect(function () {
|
|
9
|
-
|
|
11
|
+
initializeAIChat();
|
|
12
|
+
initializeAuth();
|
|
13
|
+
if (typeof window !== 'undefined') {
|
|
14
|
+
window.antd = antd;
|
|
15
|
+
}
|
|
10
16
|
}, []);
|
|
11
17
|
return outlet && /*#__PURE__*/React.createElement(QueryClientProvider, {
|
|
12
18
|
client: queryClient
|
package/dist/locales/en.json
CHANGED
|
@@ -178,5 +178,125 @@
|
|
|
178
178
|
"企业级 Node 开发框架": "Enterprise-class Node development framework",
|
|
179
179
|
"Sketch 工具集": "Sketch Tool set",
|
|
180
180
|
"互动图形解决方案": "Interactive solution",
|
|
181
|
-
"前端智能研发": "AI Coding Assistant"
|
|
181
|
+
"前端智能研发": "AI Coding Assistant",
|
|
182
|
+
"ai.placeholder.implement": "What would you like to visualize today?",
|
|
183
|
+
"ai.placeholder.solve": "What visualization problem would you like to solve today?",
|
|
184
|
+
"ai.mode.implement": "Develop",
|
|
185
|
+
"ai.mode.solve": "Q&A",
|
|
186
|
+
"ai.upload.tooltip": "Only supports csv,json,tsv,txt files. For performance and cost reasons, only the first few lines will be used as samples",
|
|
187
|
+
"ai.upload.data": "Upload Data",
|
|
188
|
+
"ai.upload.image": "Upload Image",
|
|
189
|
+
"ai.upload.analyzing": "Analyzing...",
|
|
190
|
+
"ai.upload.file.empty": "File is empty.",
|
|
191
|
+
"ai.upload.file.parse.error": "File content format error, unable to parse.",
|
|
192
|
+
"ai.upload.file.read.error": "Failed to read file.",
|
|
193
|
+
"ai.upload.file.type.error": "Unsupported file type. Please upload {types} files.",
|
|
194
|
+
"ai.upload.file.size.error": "File size cannot exceed {size}MB!",
|
|
195
|
+
"ai.upload.file.parse.type.error": "Unsupported file parsing type",
|
|
196
|
+
"ai.upload.file.summary.truncated": "... (Data summary truncated)",
|
|
197
|
+
"ai.upload.file.full.content": "User uploaded a data file, its complete content is as follows:\n\n{fileContent}",
|
|
198
|
+
"ai.upload.file.table.summary": "This is tabular data containing approximately {rowCount} rows and {columnCount} columns.\nColumn headers are: {header}\nFirst {maxLines} rows of sample data:\n{sampleRows}",
|
|
199
|
+
"ai.upload.file.json.array.summary": "This is a JSON array containing {dataLength} objects.\nKeys for each object are: {keys}\nFirst {maxLines} sample objects:\n{sampleData}",
|
|
200
|
+
"ai.upload.file.json.object.summary": "This is a JSON object. Its structure and partial data are as follows:",
|
|
201
|
+
"ai.msgbox.like": "Like",
|
|
202
|
+
"ai.msgbox.dislike": "Dislike",
|
|
203
|
+
"ai.msgbox.retry": "Try Again",
|
|
204
|
+
"ai.msgbox.copy": "Copy",
|
|
205
|
+
"ai.msgbox.start.new.chat": "Start New Chat",
|
|
206
|
+
"ai.msgbox.send.tip": "Please enter content before sending",
|
|
207
|
+
"ai.msgbox.error.response": "Sorry, I couldn't successfully process your request, please try again later",
|
|
208
|
+
"ai.recommend.title": "Featured Cases",
|
|
209
|
+
"ai.recommend.refresh": "Refresh",
|
|
210
|
+
"ai.recommend.card.caseName": "Case Name",
|
|
211
|
+
"ai.recommend.card.description": "Description",
|
|
212
|
+
"ai.markdown.copy": "Copy",
|
|
213
|
+
"ai.markdown.run": "Run this code snippet",
|
|
214
|
+
"ai.toolbar.assistant": "AI Assistant",
|
|
215
|
+
"ai.toolbar.restore": "Restore",
|
|
216
|
+
"ai.toolbar.execute": "Execute Code",
|
|
217
|
+
"ai.toolbar.open.codesandbox": "Open in CodeSandbox",
|
|
218
|
+
"ai.toolbar.open.stackblitz": "Open in StackBlitz",
|
|
219
|
+
"ai.toolbar.open.riddle": "Open in Riddle",
|
|
220
|
+
"ai.toolbar.html.code": "HTML Code",
|
|
221
|
+
"ai.conversations.expand": "Expand",
|
|
222
|
+
"ai.conversations.collapse": "Collapse",
|
|
223
|
+
"ai.conversations.new": "Start New Chat",
|
|
224
|
+
"ai.conversations.history": "History",
|
|
225
|
+
"ai.conversations.rename": "Rename",
|
|
226
|
+
"ai.conversations.pin": "Pin",
|
|
227
|
+
"ai.conversations.delete": "Delete",
|
|
228
|
+
"ai.conversations.edit.title": "Edit Conversation Name",
|
|
229
|
+
"ai.chooseLib.placeholder": "Choose Technology Stack",
|
|
230
|
+
"ai.search.try": "Try",
|
|
231
|
+
"ai.search.visualization": "Q&A",
|
|
232
|
+
"ai.assistant.editor.intro": "I am AntV AI Assistant. You can ask me questions at any time to:\n1. Interpret the code configuration of the current chart.\n2. Generate new code based on the current case through natural language dialogue to customize the chart.",
|
|
233
|
+
"ai.placeholder.whatis": "What is {title}?",
|
|
234
|
+
"header.ai.code": "AI Code Generation",
|
|
235
|
+
"header.china.mirror.title": "AntV series websites are deployed on gh-pages. If the access speed is poor, you can visit the domestic mirror site.",
|
|
236
|
+
"header.china.mirror.temp.close": "Close Temporarily",
|
|
237
|
+
"header.china.mirror.no.more": "Don't Remind Again",
|
|
238
|
+
"header.wx.qrcode.title": "Scan QR Code to Follow",
|
|
239
|
+
"feedback.page.helpful": "Was this page helpful?",
|
|
240
|
+
"feedback.page.easy.understand": "Easy to understand",
|
|
241
|
+
"feedback.page.solved.problem": "Solved my problem",
|
|
242
|
+
"feedback.page.other": "Other",
|
|
243
|
+
"feedback.page.missing.info": "Missing information I need",
|
|
244
|
+
"feedback.page.too.complex": "Too complicated/Too many steps",
|
|
245
|
+
"feedback.page.outdated": "Content is outdated",
|
|
246
|
+
"feedback.page.code.issue": "Sample/Code issue",
|
|
247
|
+
"feedback.page.reason.title": "🚀 What is the reason for your feedback?",
|
|
248
|
+
"feedback.page.issue.alert": "If something is broken or if you need a reply to a problem you've encountered, please ",
|
|
249
|
+
"feedback.page.issue.report": "open an issue instead",
|
|
250
|
+
"feedback.page.issue.alert.end": ". Otherwise, the team won't be able to answer back or ask for more information.",
|
|
251
|
+
"feedback.section.improve": "How can we improve",
|
|
252
|
+
"feedback.section.improve.end": "section? ",
|
|
253
|
+
"feedback.result.success": "Feedback Submitted",
|
|
254
|
+
"feedback.result.error": "Error, please try again later",
|
|
255
|
+
"feedback.result.thanks": "Thank you for your feedback!",
|
|
256
|
+
"feedback.result.github.issue": "Go head to GitHub issue if the problem persists.",
|
|
257
|
+
"feedback.result.problem.type": "What kind of problem are you facing?",
|
|
258
|
+
"feedback.result.reason": "🚀 What is the reason for your feedback?",
|
|
259
|
+
"feedback.result.easy.understand": "Easy to understand",
|
|
260
|
+
"feedback.result.solved.problem": "Resolved my problem",
|
|
261
|
+
"feedback.result.other": "Other",
|
|
262
|
+
"feedback.result.missing.info": "Missing the information I need",
|
|
263
|
+
"feedback.result.too.complex": "Too complicated / Too many steps",
|
|
264
|
+
"feedback.result.outdated": "Out of date",
|
|
265
|
+
"feedback.result.code.issue": "Sample / code issue",
|
|
266
|
+
"feedback.result.previous": "Previous",
|
|
267
|
+
"feedback.result.next": "Next",
|
|
268
|
+
"feedback.result.demo.error": "Demo code error, please check",
|
|
269
|
+
"feedback.result.reading.time": "Reading needs",
|
|
270
|
+
"feedback.result.minutes": "minutes",
|
|
271
|
+
"feedback.result.no.results": "No query result found",
|
|
272
|
+
"login.user.protocol.title": "User Agreement",
|
|
273
|
+
"login.user.protocol.content": "To better protect your legitimate rights and interests, please read and agree to WeaveFox ",
|
|
274
|
+
"login.user.protocol.link": "User Agreement",
|
|
275
|
+
"login.protocol.agree": "Agree",
|
|
276
|
+
"login.protocol.disagree": "Disagree",
|
|
277
|
+
"login.placeholder.phone": "Please enter your mobile number",
|
|
278
|
+
"login.placeholder.phone.or.email": "Please enter your mobile number or email",
|
|
279
|
+
"login.error.invalid.phone": "Please enter a valid mobile number",
|
|
280
|
+
"login.error.invalid.phone.or.email": "Please enter a valid mobile number or email",
|
|
281
|
+
"login.button.login.or.register": "Sign In / Sign Up",
|
|
282
|
+
"login.protocol.read.agree": "I have read and agree to AntV ",
|
|
283
|
+
"login.protocol.link": "User Agreement",
|
|
284
|
+
"login.link.home": "Return to Home Page",
|
|
285
|
+
"login.checkcode.get": "Get Code",
|
|
286
|
+
"login.checkcode.send.success": "Verification code sent successfully",
|
|
287
|
+
"login.checkcode.error.incomplete": "Please complete the captcha verification first",
|
|
288
|
+
"login.checkcode.sent": "The Verification code has been sent",
|
|
289
|
+
"login.checkcode.required": "Verification code is required",
|
|
290
|
+
"login.checkcode.invalid": "Please enter a valid 6-digit verification code",
|
|
291
|
+
"login.checkcode.placeholder": "Verification code",
|
|
292
|
+
"login.countdown.resend": "Resend({time})",
|
|
293
|
+
"login.countdown.resend.simple": "Resend",
|
|
294
|
+
"login.captcha.drag": "Hold and drag the slider right",
|
|
295
|
+
"login.captcha.success": "Verification successful",
|
|
296
|
+
"login.captcha.loading": "Loading...",
|
|
297
|
+
"login.captcha.error.wrong": "Oops! Something went wrong. Click",
|
|
298
|
+
"login.captcha.error.network": "Poor connection. Click",
|
|
299
|
+
"login.captcha.error.refresh": "Refresh",
|
|
300
|
+
"login.captcha.required": "Please drag the slider to verify",
|
|
301
|
+
"login.modal.title": "Verification Code Login"
|
|
182
302
|
}
|
package/dist/locales/zh.json
CHANGED
|
@@ -177,5 +177,125 @@
|
|
|
177
177
|
"企业级 Node 开发框架": "企业级 Node 开发框架",
|
|
178
178
|
"Sketch 工具集": "Sketch 工具集",
|
|
179
179
|
"互动图形解决方案": "互动图形解决方案",
|
|
180
|
-
"前端智能研发": "前端智能研发"
|
|
180
|
+
"前端智能研发": "前端智能研发",
|
|
181
|
+
"ai.placeholder.implement": "今天,你想可视化什么?",
|
|
182
|
+
"ai.placeholder.solve": "今天,你想解决什么可视化问题?",
|
|
183
|
+
"ai.mode.implement": "可视化研发",
|
|
184
|
+
"ai.mode.solve": "可视化答疑",
|
|
185
|
+
"ai.upload.tooltip": "仅支持csv,json,tsv,txt文件,为了性能和成本,只会使用文件的前几行作为样本",
|
|
186
|
+
"ai.upload.data": "上传数据",
|
|
187
|
+
"ai.upload.image": "上传图片",
|
|
188
|
+
"ai.upload.analyzing": "分析中...",
|
|
189
|
+
"ai.upload.file.empty": "文件为空。",
|
|
190
|
+
"ai.upload.file.parse.error": "文件内容格式错误,无法解析。",
|
|
191
|
+
"ai.upload.file.read.error": "读取文件失败。",
|
|
192
|
+
"ai.upload.file.type.error": "不支持的文件类型。请上传 {types} 文件。",
|
|
193
|
+
"ai.upload.file.size.error": "文件大小不能超过 {size}MB!",
|
|
194
|
+
"ai.upload.file.parse.type.error": "不支持的文件解析类型",
|
|
195
|
+
"ai.upload.file.summary.truncated": "... (数据摘要已截断)",
|
|
196
|
+
"ai.upload.file.full.content": "用户上传了一个数据文件,其完整内容如下:\n\n{fileContent}",
|
|
197
|
+
"ai.upload.file.table.summary": "这是一个包含约 {rowCount} 行和 {columnCount} 列的表格数据。\n列名(Header)是: {header}\n前{maxLines}行样本数据如下:\n{sampleRows}",
|
|
198
|
+
"ai.upload.file.json.array.summary": "这是一个包含 {dataLength} 个对象的JSON数组。\n每个对象的键(Keys)是: {keys}\n前{maxLines}个样本对象如下:\n{sampleData}",
|
|
199
|
+
"ai.upload.file.json.object.summary": "这是一个JSON对象。其结构和部分数据如下:",
|
|
200
|
+
"ai.msgbox.like": "点赞",
|
|
201
|
+
"ai.msgbox.dislike": "点踩",
|
|
202
|
+
"ai.msgbox.retry": "再来一次",
|
|
203
|
+
"ai.msgbox.copy": "复制",
|
|
204
|
+
"ai.msgbox.start.new.chat": "开始新对话",
|
|
205
|
+
"ai.msgbox.send.tip": "请输入内容后发送指令",
|
|
206
|
+
"ai.msgbox.error.response": "抱歉,我没能成功处理您的请求,请稍后再次提问",
|
|
207
|
+
"ai.recommend.title": "精选案例",
|
|
208
|
+
"ai.recommend.refresh": "换一批",
|
|
209
|
+
"ai.recommend.card.caseName": "案例名",
|
|
210
|
+
"ai.recommend.card.description": "描述信息",
|
|
211
|
+
"ai.markdown.copy": "复制",
|
|
212
|
+
"ai.markdown.run": "运行此代码片段",
|
|
213
|
+
"ai.toolbar.assistant": "AI 助手",
|
|
214
|
+
"ai.toolbar.restore": "还原",
|
|
215
|
+
"ai.toolbar.execute": "执行代码",
|
|
216
|
+
"ai.toolbar.open.codesandbox": "在 CodeSandbox 中打开",
|
|
217
|
+
"ai.toolbar.open.stackblitz": "在 StackBlitz 中打开",
|
|
218
|
+
"ai.toolbar.open.riddle": "在 Riddle 中打开",
|
|
219
|
+
"ai.toolbar.html.code": "HTML 代码",
|
|
220
|
+
"ai.conversations.expand": "展开",
|
|
221
|
+
"ai.conversations.collapse": "收起",
|
|
222
|
+
"ai.conversations.new": "开始新对话",
|
|
223
|
+
"ai.conversations.history": "历史对话",
|
|
224
|
+
"ai.conversations.rename": "重命名",
|
|
225
|
+
"ai.conversations.pin": "置顶",
|
|
226
|
+
"ai.conversations.delete": "删除",
|
|
227
|
+
"ai.conversations.edit.title": "编辑对话名称",
|
|
228
|
+
"ai.chooseLib.placeholder": "选择技术栈",
|
|
229
|
+
"ai.search.try": "试试",
|
|
230
|
+
"ai.search.visualization": "可视化答疑",
|
|
231
|
+
"ai.assistant.editor.intro": "我是AntV AI助手。您可以随时向我提问,让我为您:\n\n1、解读当前图表的代码配置。\n2、通过自然语言对话,基于当前案例生成新代码以定制图表。",
|
|
232
|
+
"ai.placeholder.whatis": "{title}是什么?",
|
|
233
|
+
"header.ai.code": "AI生码",
|
|
234
|
+
"header.china.mirror.title": "AntV 系列网站部署在 gh-pages 上,若访问速度不佳,可以前往国内镜像站点。",
|
|
235
|
+
"header.china.mirror.temp.close": "暂时关闭",
|
|
236
|
+
"header.china.mirror.no.more": "不再提醒",
|
|
237
|
+
"header.wx.qrcode.title": "微信扫一扫关注",
|
|
238
|
+
"feedback.page.helpful": "这个页面对你有帮助吗?",
|
|
239
|
+
"feedback.page.easy.understand": "容易理解",
|
|
240
|
+
"feedback.page.solved.problem": "解决了我的问题",
|
|
241
|
+
"feedback.page.other": "其它",
|
|
242
|
+
"feedback.page.missing.info": "缺少我需要的信息",
|
|
243
|
+
"feedback.page.too.complex": "过于复杂/步骤太多",
|
|
244
|
+
"feedback.page.outdated": "内容更新不及时",
|
|
245
|
+
"feedback.page.code.issue": "示例/代码有问题",
|
|
246
|
+
"feedback.page.reason.title": "🚀 留下你的真实感受",
|
|
247
|
+
"feedback.page.issue.alert": "如果遇到问题或发现某些功能无法正常工作,请通过",
|
|
248
|
+
"feedback.page.issue.report": "提交问题报告",
|
|
249
|
+
"feedback.page.issue.alert.end": "来反馈。否则,团队将无法提供进一步的答复或获取更多信息。",
|
|
250
|
+
"feedback.section.improve": "你认为",
|
|
251
|
+
"feedback.section.improve.end": "部分如何改进更好?",
|
|
252
|
+
"feedback.result.success": "谢谢你的反馈意见!",
|
|
253
|
+
"feedback.result.error": "报错了,请稍后再试",
|
|
254
|
+
"feedback.result.thanks": "感谢你的支持!",
|
|
255
|
+
"feedback.result.github.issue": "如果问题持续,请前往 GitHub 提交 issue。",
|
|
256
|
+
"feedback.result.problem.type": "你遇到的问题是什么?",
|
|
257
|
+
"feedback.result.reason": "🚀 留下你的真实感受",
|
|
258
|
+
"feedback.result.easy.understand": "容易理解",
|
|
259
|
+
"feedback.result.solved.problem": "有效解决了我的问题",
|
|
260
|
+
"feedback.result.other": "其它",
|
|
261
|
+
"feedback.result.missing.info": "缺少我需要的信息",
|
|
262
|
+
"feedback.result.too.complex": "过于复杂/步骤太多",
|
|
263
|
+
"feedback.result.outdated": "内容更新不及时",
|
|
264
|
+
"feedback.result.code.issue": "示例/代码有问题",
|
|
265
|
+
"feedback.result.previous": "上一篇",
|
|
266
|
+
"feedback.result.next": "下一篇",
|
|
267
|
+
"feedback.result.demo.error": "演示代码报错,请检查",
|
|
268
|
+
"feedback.result.reading.time": "阅读时间约",
|
|
269
|
+
"feedback.result.minutes": "分钟",
|
|
270
|
+
"feedback.result.no.results": "没有找到查询结果",
|
|
271
|
+
"login.user.protocol.title": "用户协议 ",
|
|
272
|
+
"login.user.protocol.content": "为更好地保护你的合法权益,请阅读并同意 WeaveFox ",
|
|
273
|
+
"login.user.protocol.link": "用户协议 ",
|
|
274
|
+
"login.protocol.agree": "同意",
|
|
275
|
+
"login.protocol.disagree": "不同意",
|
|
276
|
+
"login.placeholder.phone": "请输入手机号",
|
|
277
|
+
"login.placeholder.phone.or.email": "请输入手机号或邮箱",
|
|
278
|
+
"login.error.invalid.phone": "请输入正确的手机号",
|
|
279
|
+
"login.error.invalid.phone.or.email": "请输入正确的手机号或邮箱",
|
|
280
|
+
"login.button.login.or.register": "登录 / 注册",
|
|
281
|
+
"login.protocol.read.agree": "我已阅读并同意 AntV ",
|
|
282
|
+
"login.protocol.link": "用户协议 ",
|
|
283
|
+
"login.link.home": "返回首页",
|
|
284
|
+
"login.checkcode.get": "获取验证码",
|
|
285
|
+
"login.checkcode.send.success": "验证码发送成功",
|
|
286
|
+
"login.checkcode.error.incomplete": "先完成滑块验证",
|
|
287
|
+
"login.checkcode.sent": "已发送验证码",
|
|
288
|
+
"login.checkcode.required": "验证码不能为空",
|
|
289
|
+
"login.checkcode.invalid": "请输入有效的 6 位数字验证码",
|
|
290
|
+
"login.checkcode.placeholder": "6 位验证码",
|
|
291
|
+
"login.countdown.resend": "重新获取({time})",
|
|
292
|
+
"login.countdown.resend.simple": "重新获取",
|
|
293
|
+
"login.captcha.drag": "按住滑块,拖动到最右边",
|
|
294
|
+
"login.captcha.success": "验证通过",
|
|
295
|
+
"login.captcha.loading": "加载中",
|
|
296
|
+
"login.captcha.error.wrong": "哎呀,出错了,单击",
|
|
297
|
+
"login.captcha.error.network": "网络不给力,单击",
|
|
298
|
+
"login.captcha.error.refresh": "刷新",
|
|
299
|
+
"login.captcha.required": "拖动滑块验证",
|
|
300
|
+
"login.modal.title": "验证码登录"
|
|
181
301
|
}
|
package/dist/model/AIChat.js
CHANGED
|
@@ -13,6 +13,7 @@ import { derive, subscribeKey } from 'valtio/utils';
|
|
|
13
13
|
import localforage from 'localforage';
|
|
14
14
|
import FingerprintJS from '@fingerprintjs/fingerprintjs';
|
|
15
15
|
import { history } from "dumi";
|
|
16
|
+
import { message } from "antd";
|
|
16
17
|
|
|
17
18
|
// --- 配置 ---
|
|
18
19
|
// 定义需要持久化的 state key
|
|
@@ -55,7 +56,7 @@ export var clearEmptySession = function clearEmptySession() {
|
|
|
55
56
|
};
|
|
56
57
|
|
|
57
58
|
// --- 初始化逻辑 ---
|
|
58
|
-
export var
|
|
59
|
+
export var initializeAIChat = /*#__PURE__*/function () {
|
|
59
60
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
60
61
|
var persistedState, fp, result, newSession, _AIChatStore$sessions;
|
|
61
62
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -129,7 +130,7 @@ export var initializeStore = /*#__PURE__*/function () {
|
|
|
129
130
|
}
|
|
130
131
|
}, _callee, null, [[5, 15]]);
|
|
131
132
|
}));
|
|
132
|
-
return function
|
|
133
|
+
return function initializeAIChat() {
|
|
133
134
|
return _ref.apply(this, arguments);
|
|
134
135
|
};
|
|
135
136
|
}();
|
|
@@ -195,10 +196,16 @@ subscribeKey(AIChatStore, 'activeSessionId', function () {
|
|
|
195
196
|
AIChatStore.codeBlock = null;
|
|
196
197
|
});
|
|
197
198
|
export var createPureNewSession = function createPureNewSession(title) {
|
|
199
|
+
var newConversationName = 'New Conversation';
|
|
200
|
+
if (AIChatStore.sessions.some(function (s) {
|
|
201
|
+
return s.title === newConversationName && s.messages.length === 0;
|
|
202
|
+
})) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
198
205
|
var newSessionId = crypto.randomUUID();
|
|
199
206
|
AIChatStore.sessions.unshift({
|
|
200
207
|
id: newSessionId,
|
|
201
|
-
title: title !== null && title !== void 0 ? title :
|
|
208
|
+
title: title !== null && title !== void 0 ? title : newConversationName,
|
|
202
209
|
createdAt: Date.now(),
|
|
203
210
|
messages: []
|
|
204
211
|
});
|
|
@@ -207,7 +214,7 @@ export var createPureNewSession = function createPureNewSession(title) {
|
|
|
207
214
|
export var createNewSession = function createNewSession(config) {
|
|
208
215
|
// todo 埋点
|
|
209
216
|
// 1. 创建一个新的会话
|
|
210
|
-
createPureNewSession();
|
|
217
|
+
createPureNewSession(config.promptText);
|
|
211
218
|
|
|
212
219
|
// 2. 创建临时消息并存入 store
|
|
213
220
|
AIChatStore.tempMessage = {
|
|
@@ -216,9 +223,60 @@ export var createNewSession = function createNewSession(config) {
|
|
|
216
223
|
content: config.promptText,
|
|
217
224
|
createdAt: Date.now(),
|
|
218
225
|
mode: config.mode,
|
|
219
|
-
lib: config.lib
|
|
226
|
+
lib: config.lib,
|
|
227
|
+
context: config.context
|
|
220
228
|
};
|
|
221
229
|
if (config.jump) {
|
|
222
|
-
|
|
230
|
+
var _config$lang;
|
|
231
|
+
history.push("/".concat((_config$lang = config.lang) !== null && _config$lang !== void 0 ? _config$lang : 'zh', "/ai-playground"));
|
|
223
232
|
}
|
|
224
|
-
};
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* 清空所有本地AI对话记录和相关状态。用户注销账户或手动请求清除数据时调用。
|
|
237
|
+
*
|
|
238
|
+
* 该函数会执行以下操作:
|
|
239
|
+
* 1. 从 localforage 中删除持久化的状态数据。
|
|
240
|
+
* 2. 将内存中的 AIChatStore 重置为初始状态。
|
|
241
|
+
*
|
|
242
|
+
*/
|
|
243
|
+
export var clearAllChatData = /*#__PURE__*/function () {
|
|
244
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
245
|
+
var initialKeys, _i, _initialKeys, key;
|
|
246
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
247
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
248
|
+
case 0:
|
|
249
|
+
_context2.prev = 0;
|
|
250
|
+
_context2.next = 3;
|
|
251
|
+
return localforage.removeItem(STORAGE_KEY);
|
|
252
|
+
case 3:
|
|
253
|
+
console.log("[AIChat] Persistent state with key \"".concat(STORAGE_KEY, "\" has been removed."));
|
|
254
|
+
|
|
255
|
+
// 步骤 2: 将内存中的 valtio store 重置为初始状态。
|
|
256
|
+
// 这会立即更新UI,让所有对话记录从界面上消失。
|
|
257
|
+
// 注意:我们不能直接做 AIChatStore = initialState,
|
|
258
|
+
// 因为 proxy 对象是不可替换的。我们必须逐个属性地重置。
|
|
259
|
+
initialKeys = Object.keys(initialState);
|
|
260
|
+
for (_i = 0, _initialKeys = initialKeys; _i < _initialKeys.length; _i++) {
|
|
261
|
+
key = _initialKeys[_i];
|
|
262
|
+
// @ts-ignore
|
|
263
|
+
AIChatStore[key] = initialState[key];
|
|
264
|
+
}
|
|
265
|
+
console.log('[AIChat] In-memory state has been reset to initial values.');
|
|
266
|
+
_context2.next = 13;
|
|
267
|
+
break;
|
|
268
|
+
case 9:
|
|
269
|
+
_context2.prev = 9;
|
|
270
|
+
_context2.t0 = _context2["catch"](0);
|
|
271
|
+
console.error('[AIChat] Failed to clear all chat data:', _context2.t0);
|
|
272
|
+
message.error('清空对话记录失败,请刷新页面后重试。');
|
|
273
|
+
case 13:
|
|
274
|
+
case "end":
|
|
275
|
+
return _context2.stop();
|
|
276
|
+
}
|
|
277
|
+
}, _callee2, null, [[0, 9]]);
|
|
278
|
+
}));
|
|
279
|
+
return function clearAllChatData() {
|
|
280
|
+
return _ref2.apply(this, arguments);
|
|
281
|
+
};
|
|
282
|
+
}();
|