@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,133 @@
|
|
|
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 { proxy } from 'valtio';
|
|
6
|
+
import request from "../utils/request";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 检查当前 URL 是否包含 'skipLogin=1' 参数
|
|
10
|
+
* @returns {boolean} 如果包含则返回 true, 否则返回 false
|
|
11
|
+
*/
|
|
12
|
+
function hasSkipLoginParam() {
|
|
13
|
+
if (typeof window === 'undefined') {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
// 1. 获取当前 URL 的查询字符串 (例如 "?foo=bar&skipLogin=1")
|
|
17
|
+
var queryString = window.location.search;
|
|
18
|
+
|
|
19
|
+
// 2. 创建一个 URLSearchParams 实例
|
|
20
|
+
var urlParams = new URLSearchParams(queryString);
|
|
21
|
+
|
|
22
|
+
// 3. 使用 .get() 方法获取 'skipLogin' 参数的值,并判断是否为 '1'
|
|
23
|
+
// 注意:URL参数的值总是字符串类型,所以我们用 '1' 而不是 1 进行比较。
|
|
24
|
+
return urlParams.get('skipLogin') === '1';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// 1. 定义 State (只包含数据)
|
|
28
|
+
export var authStore = proxy({
|
|
29
|
+
isModalOpen: false,
|
|
30
|
+
isAuthenticated: false,
|
|
31
|
+
loginCallback: function loginCallback() {}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// 2. 定义 Actions (作为独立函数)
|
|
35
|
+
export var showLoginModal = function showLoginModal(callback) {
|
|
36
|
+
authStore.isModalOpen = true;
|
|
37
|
+
authStore.loginCallback = callback;
|
|
38
|
+
};
|
|
39
|
+
export var hideLoginModal = function hideLoginModal() {
|
|
40
|
+
authStore.isModalOpen = false;
|
|
41
|
+
};
|
|
42
|
+
export var loginOrRegister = /*#__PURE__*/function () {
|
|
43
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
|
|
44
|
+
var _authStore$loginCallb;
|
|
45
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
46
|
+
while (1) switch (_context.prev = _context.next) {
|
|
47
|
+
case 0:
|
|
48
|
+
_context.prev = 0;
|
|
49
|
+
_context.next = 3;
|
|
50
|
+
return request.post('/api/modules/user/api/accounts/login_or_register', params);
|
|
51
|
+
case 3:
|
|
52
|
+
authStore.isAuthenticated = true;
|
|
53
|
+
hideLoginModal();
|
|
54
|
+
(_authStore$loginCallb = authStore.loginCallback) === null || _authStore$loginCallb === void 0 || _authStore$loginCallb.call(authStore);
|
|
55
|
+
return _context.abrupt("return", true);
|
|
56
|
+
case 9:
|
|
57
|
+
_context.prev = 9;
|
|
58
|
+
_context.t0 = _context["catch"](0);
|
|
59
|
+
console.error('Login failed in store:', _context.t0);
|
|
60
|
+
return _context.abrupt("return", false);
|
|
61
|
+
case 13:
|
|
62
|
+
case "end":
|
|
63
|
+
return _context.stop();
|
|
64
|
+
}
|
|
65
|
+
}, _callee, null, [[0, 9]]);
|
|
66
|
+
}));
|
|
67
|
+
return function loginOrRegister(_x) {
|
|
68
|
+
return _ref.apply(this, arguments);
|
|
69
|
+
};
|
|
70
|
+
}();
|
|
71
|
+
export var logout = /*#__PURE__*/function () {
|
|
72
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
73
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
74
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
75
|
+
case 0:
|
|
76
|
+
_context2.prev = 0;
|
|
77
|
+
_context2.next = 3;
|
|
78
|
+
return request.delete('/api/modules/user/api/accounts/logout');
|
|
79
|
+
case 3:
|
|
80
|
+
_context2.next = 8;
|
|
81
|
+
break;
|
|
82
|
+
case 5:
|
|
83
|
+
_context2.prev = 5;
|
|
84
|
+
_context2.t0 = _context2["catch"](0);
|
|
85
|
+
console.error('Logout failed in store:', _context2.t0);
|
|
86
|
+
case 8:
|
|
87
|
+
_context2.prev = 8;
|
|
88
|
+
authStore.isAuthenticated = false;
|
|
89
|
+
return _context2.finish(8);
|
|
90
|
+
case 11:
|
|
91
|
+
case "end":
|
|
92
|
+
return _context2.stop();
|
|
93
|
+
}
|
|
94
|
+
}, _callee2, null, [[0, 5, 8, 11]]);
|
|
95
|
+
}));
|
|
96
|
+
return function logout() {
|
|
97
|
+
return _ref2.apply(this, arguments);
|
|
98
|
+
};
|
|
99
|
+
}();
|
|
100
|
+
export function sendValidationCode(data) {
|
|
101
|
+
return request.post('/api/modules/user/api/validation_code/send', data);
|
|
102
|
+
}
|
|
103
|
+
export var initializeAuth = /*#__PURE__*/function () {
|
|
104
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
105
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
106
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
107
|
+
case 0:
|
|
108
|
+
_context3.prev = 0;
|
|
109
|
+
if (hasSkipLoginParam()) {
|
|
110
|
+
_context3.next = 4;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
_context3.next = 4;
|
|
114
|
+
return request.get('/api/modules/user/api/accounts/get_company_info');
|
|
115
|
+
case 4:
|
|
116
|
+
authStore.isAuthenticated = true;
|
|
117
|
+
_context3.next = 11;
|
|
118
|
+
break;
|
|
119
|
+
case 7:
|
|
120
|
+
_context3.prev = 7;
|
|
121
|
+
_context3.t0 = _context3["catch"](0);
|
|
122
|
+
console.error('Initialize auth failed in store:', _context3.t0);
|
|
123
|
+
authStore.isAuthenticated = false;
|
|
124
|
+
case 11:
|
|
125
|
+
case "end":
|
|
126
|
+
return _context3.stop();
|
|
127
|
+
}
|
|
128
|
+
}, _callee3, null, [[0, 7]]);
|
|
129
|
+
}));
|
|
130
|
+
return function initializeAuth() {
|
|
131
|
+
return _ref3.apply(this, arguments);
|
|
132
|
+
};
|
|
133
|
+
}();
|
|
@@ -10,9 +10,9 @@ import { Dropdown, Input, Modal } from 'antd';
|
|
|
10
10
|
import { Menu } from 'antd';
|
|
11
11
|
import styles from "./index.module.less";
|
|
12
12
|
import { useSnapshot } from 'valtio';
|
|
13
|
-
import { AIChatStore, handleDeleteSession, handlePinSession, handleRenameSession } from "../../../../model/AIChat";
|
|
14
|
-
import { history } from 'dumi';
|
|
13
|
+
import { AIChatStore, createPureNewSession, handleDeleteSession, handlePinSession, handleRenameSession } from "../../../../model/AIChat";
|
|
15
14
|
import { useSetState } from "ahooks";
|
|
15
|
+
import { useIntl } from 'dumi';
|
|
16
16
|
export var ConversationsMenu = function ConversationsMenu() {
|
|
17
17
|
var _useSetState = useSetState({
|
|
18
18
|
open: false,
|
|
@@ -33,23 +33,33 @@ export var ConversationsMenu = function ConversationsMenu() {
|
|
|
33
33
|
var toggleCollapsed = function toggleCollapsed() {
|
|
34
34
|
setCollapsed(!collapsed);
|
|
35
35
|
};
|
|
36
|
+
var _useIntl = useIntl(),
|
|
37
|
+
formatMessage = _useIntl.formatMessage;
|
|
36
38
|
var items = [{
|
|
37
39
|
key: 'fold',
|
|
38
40
|
extra: !collapsed ? /*#__PURE__*/React.createElement(MenuFoldOutlined, null) : null,
|
|
39
41
|
onClick: toggleCollapsed,
|
|
40
42
|
label: null,
|
|
41
43
|
icon: !collapsed ? null : /*#__PURE__*/React.createElement(MenuUnfoldOutlined, null),
|
|
42
|
-
title:
|
|
44
|
+
title: collapsed ? formatMessage({
|
|
45
|
+
id: 'ai.conversations.expand'
|
|
46
|
+
}) : formatMessage({
|
|
47
|
+
id: 'ai.conversations.collapse'
|
|
48
|
+
})
|
|
43
49
|
}, {
|
|
44
50
|
key: 'new',
|
|
45
51
|
icon: /*#__PURE__*/React.createElement(PlusSquareOutlined, null),
|
|
46
|
-
label:
|
|
52
|
+
label: formatMessage({
|
|
53
|
+
id: 'ai.conversations.new'
|
|
54
|
+
}),
|
|
47
55
|
onClick: function onClick() {
|
|
48
|
-
return
|
|
56
|
+
return createPureNewSession();
|
|
49
57
|
}
|
|
50
58
|
}, {
|
|
51
59
|
key: 'history',
|
|
52
|
-
label:
|
|
60
|
+
label: formatMessage({
|
|
61
|
+
id: 'ai.conversations.history'
|
|
62
|
+
}),
|
|
53
63
|
icon: /*#__PURE__*/React.createElement(HistoryOutlined, null),
|
|
54
64
|
children: snap.sessions.map(function (session) {
|
|
55
65
|
return {
|
|
@@ -62,7 +72,9 @@ export var ConversationsMenu = function ConversationsMenu() {
|
|
|
62
72
|
menu: {
|
|
63
73
|
items: [{
|
|
64
74
|
key: 'edit',
|
|
65
|
-
label:
|
|
75
|
+
label: formatMessage({
|
|
76
|
+
id: 'ai.conversations.rename'
|
|
77
|
+
}),
|
|
66
78
|
icon: /*#__PURE__*/React.createElement(EditOutlined, null),
|
|
67
79
|
onClick: function onClick(_ref) {
|
|
68
80
|
var domEvent = _ref.domEvent;
|
|
@@ -75,7 +87,9 @@ export var ConversationsMenu = function ConversationsMenu() {
|
|
|
75
87
|
}
|
|
76
88
|
}, {
|
|
77
89
|
key: 'top',
|
|
78
|
-
label:
|
|
90
|
+
label: formatMessage({
|
|
91
|
+
id: 'ai.conversations.pin'
|
|
92
|
+
}),
|
|
79
93
|
icon: /*#__PURE__*/React.createElement(VerticalAlignTopOutlined, null),
|
|
80
94
|
onClick: function onClick(_ref2) {
|
|
81
95
|
var domEvent = _ref2.domEvent;
|
|
@@ -84,7 +98,9 @@ export var ConversationsMenu = function ConversationsMenu() {
|
|
|
84
98
|
}
|
|
85
99
|
}, {
|
|
86
100
|
key: 'delete',
|
|
87
|
-
label:
|
|
101
|
+
label: formatMessage({
|
|
102
|
+
id: 'ai.conversations.delete'
|
|
103
|
+
}),
|
|
88
104
|
icon: /*#__PURE__*/React.createElement(DeleteOutlined, null),
|
|
89
105
|
onClick: function onClick(_ref3) {
|
|
90
106
|
var domEvent = _ref3.domEvent;
|
|
@@ -118,7 +134,9 @@ export var ConversationsMenu = function ConversationsMenu() {
|
|
|
118
134
|
return handleSelectSession(key);
|
|
119
135
|
}
|
|
120
136
|
}), /*#__PURE__*/React.createElement(Modal, {
|
|
121
|
-
title:
|
|
137
|
+
title: formatMessage({
|
|
138
|
+
id: 'ai.conversations.edit.title'
|
|
139
|
+
}),
|
|
122
140
|
open: state.open,
|
|
123
141
|
centered: true,
|
|
124
142
|
maskClosable: false,
|
|
@@ -10,15 +10,19 @@ import { a11yLight } from "react-syntax-highlighter/dist/cjs/styles/hljs";
|
|
|
10
10
|
import { AIChatStore } from "../../../../model/AIChat";
|
|
11
11
|
import { useCopyToClipboard } from "react-use";
|
|
12
12
|
import { CheckOutlined, CopyOutlined, PlaySquareOutlined } from "@ant-design/icons";
|
|
13
|
-
import { Space, Tooltip } from "antd";
|
|
13
|
+
import { Button, Space, Tooltip } from "antd";
|
|
14
14
|
import styles from "./MarkdownCodeBlock.module.less";
|
|
15
|
+
import { useIntl } from 'dumi';
|
|
15
16
|
|
|
16
17
|
// 定义 props 类型,它将接收 react-markdown 传递的所有属性
|
|
17
18
|
|
|
18
19
|
export var MarkdownCodeBlock = function MarkdownCodeBlock(_ref) {
|
|
19
20
|
var inline = _ref.inline,
|
|
20
21
|
className = _ref.className,
|
|
21
|
-
children = _ref.children
|
|
22
|
+
children = _ref.children,
|
|
23
|
+
_ref$showRunButton = _ref.showRunButton,
|
|
24
|
+
showRunButtonProp = _ref$showRunButton === void 0 ? true : _ref$showRunButton;
|
|
25
|
+
var intl = useIntl();
|
|
22
26
|
var _useCopyToClipboard = useCopyToClipboard(),
|
|
23
27
|
_useCopyToClipboard2 = _slicedToArray(_useCopyToClipboard, 2),
|
|
24
28
|
copyState = _useCopyToClipboard2[0],
|
|
@@ -38,7 +42,7 @@ export var MarkdownCodeBlock = function MarkdownCodeBlock(_ref) {
|
|
|
38
42
|
var codeString = String(children).replace(/\n$/, '');
|
|
39
43
|
|
|
40
44
|
// 4. 判断是否显示“运行”按钮
|
|
41
|
-
var showRunButton = /\bimport\b/.test(codeString);
|
|
45
|
+
var showRunButton = showRunButtonProp && /\bimport\b/.test(codeString);
|
|
42
46
|
|
|
43
47
|
// 5. 定义运行代码的逻辑
|
|
44
48
|
var handleRunCode = function handleRunCode() {
|
|
@@ -55,19 +59,29 @@ export var MarkdownCodeBlock = function MarkdownCodeBlock(_ref) {
|
|
|
55
59
|
}, /*#__PURE__*/React.createElement(Space, {
|
|
56
60
|
className: styles.button
|
|
57
61
|
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
58
|
-
title:
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
title: intl.formatMessage({
|
|
63
|
+
id: 'ai.markdown.copy'
|
|
64
|
+
})
|
|
65
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
66
|
+
variant: "link",
|
|
67
|
+
size: "small",
|
|
61
68
|
onClick: function onClick() {
|
|
62
69
|
return copyToClipboard(codeString);
|
|
63
70
|
},
|
|
64
|
-
title:
|
|
71
|
+
title: intl.formatMessage({
|
|
72
|
+
id: 'ai.markdown.copy'
|
|
73
|
+
})
|
|
65
74
|
}, copyState.value === codeString ? /*#__PURE__*/React.createElement(CheckOutlined, null) : /*#__PURE__*/React.createElement(CopyOutlined, null))), showRunButton && /*#__PURE__*/React.createElement(Tooltip, {
|
|
66
|
-
title:
|
|
67
|
-
|
|
68
|
-
|
|
75
|
+
title: intl.formatMessage({
|
|
76
|
+
id: 'ai.markdown.run'
|
|
77
|
+
})
|
|
78
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
79
|
+
variant: "link",
|
|
80
|
+
size: "small",
|
|
69
81
|
onClick: handleRunCode,
|
|
70
|
-
title:
|
|
82
|
+
title: intl.formatMessage({
|
|
83
|
+
id: 'ai.markdown.run'
|
|
84
|
+
})
|
|
71
85
|
}, /*#__PURE__*/React.createElement(PlaySquareOutlined, null)))), /*#__PURE__*/React.createElement(SyntaxHighlighter, {
|
|
72
86
|
style: a11yLight,
|
|
73
87
|
language: language,
|
|
@@ -9,7 +9,8 @@ import remarkGfm from 'remark-gfm';
|
|
|
9
9
|
import { MarkdownCodeBlock } from "./MarkdownCodeBlock"; // 引入我们创建的自定义组件
|
|
10
10
|
|
|
11
11
|
export var MarkdownComponent = function MarkdownComponent(_ref) {
|
|
12
|
-
var content = _ref.content
|
|
12
|
+
var content = _ref.content,
|
|
13
|
+
showRunButton = _ref.showRunButton;
|
|
13
14
|
return /*#__PURE__*/React.createElement(Markdown, {
|
|
14
15
|
remarkPlugins: [remarkGfm],
|
|
15
16
|
rehypePlugins: [rehypeRaw],
|
|
@@ -27,7 +28,9 @@ export var MarkdownComponent = function MarkdownComponent(_ref) {
|
|
|
27
28
|
},
|
|
28
29
|
// 2. 【核心】重写 `code` 标签的渲染,使用我们自己的组件
|
|
29
30
|
code: function code(props) {
|
|
30
|
-
return /*#__PURE__*/React.createElement(MarkdownCodeBlock,
|
|
31
|
+
return /*#__PURE__*/React.createElement(MarkdownCodeBlock, _extends({
|
|
32
|
+
showRunButton: showRunButton
|
|
33
|
+
}, props));
|
|
31
34
|
},
|
|
32
35
|
// 3. 重写非标准 `description` 标签的渲染
|
|
33
36
|
// @ts-expect-error - 告知 TypeScript 我们知道这是一个自定义的、非标准的 HTML 标签
|