@antv/dumi-theme-antv 0.8.0-beta.2 → 0.8.0-beta.21

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.
Files changed (88) hide show
  1. package/dist/builtins/Playground/index.module.less +0 -1
  2. package/dist/components/AI/HomeDialog/AntVBanner/index.module.less +2 -2
  3. package/dist/components/AI/HomeDialog/ModeSelector/ModeSelectorDropdown.js +42 -0
  4. package/dist/components/AI/HomeDialog/ModeSelector/index.module.less +39 -22
  5. package/dist/components/AI/HomeDialog/PromptTextarea/ChooseLib/index.js +12 -4
  6. package/dist/components/AI/HomeDialog/PromptTextarea/ChooseLib/index.module.less +0 -1
  7. package/dist/components/AI/HomeDialog/PromptTextarea/DatasourceCard/index.module.less +3 -3
  8. package/dist/components/AI/HomeDialog/PromptTextarea/index.js +38 -36
  9. package/dist/components/AI/HomeDialog/PromptTextarea/index.module.less +8 -8
  10. package/dist/components/AI/HomeDialog/RecommendCase/Card.js +14 -11
  11. package/dist/components/AI/HomeDialog/RecommendCase/card.module.less +3 -3
  12. package/dist/components/AI/HomeDialog/RecommendCase/index.js +73 -24
  13. package/dist/components/AI/HomeDialog/RecommendCase/index.module.less +4 -2
  14. package/dist/components/AI/HomeDialog/RecommendCase/recommend.json +41 -17
  15. package/dist/components/AI/HomeDialog/index.js +21 -33
  16. package/dist/components/AI/constant.js +4 -2
  17. package/dist/components/Login/Captcha/index.js +185 -0
  18. package/dist/components/Login/Captcha/index.less +91 -0
  19. package/dist/components/Login/CheckCode/index.js +244 -0
  20. package/dist/components/Login/CheckCode/index.less +137 -0
  21. package/dist/components/Login/CountDownButton/index.js +109 -0
  22. package/dist/components/Login/CountDownButton/index.less +8 -0
  23. package/dist/components/Login/LoginForm.js +239 -0
  24. package/dist/components/Login/LoginForm.less +409 -0
  25. package/dist/components/Login/index.js +24 -0
  26. package/dist/components/Login/openAuthWindow.js +54 -0
  27. package/dist/components/Login/types.js +5 -0
  28. package/dist/components/Login/utils.js +47 -0
  29. package/dist/hooks/useProducts.js +22 -1
  30. package/dist/layouts/DocLayout.js +2 -1
  31. package/dist/layouts/GlobalLayout/index.js +11 -4
  32. package/dist/locales/en.json +43 -2
  33. package/dist/locales/zh.json +43 -2
  34. package/dist/model/AIChat.js +93 -6
  35. package/dist/model/auth.js +147 -0
  36. package/dist/pages/AIPlayground/components/ConversationsMenu/index.js +15 -7
  37. package/dist/pages/AIPlayground/components/ConversationsMenu/index.module.less +2 -0
  38. package/dist/pages/AIPlayground/components/MarkdownComponent/MarkdownCodeBlock.js +26 -17
  39. package/dist/pages/AIPlayground/components/MarkdownComponent/MarkdownCodeBlock.module.less +1 -2
  40. package/dist/pages/AIPlayground/components/MarkdownComponent/index.js +7 -4
  41. package/dist/pages/AIPlayground/components/MsgBox/index.js +266 -149
  42. package/dist/pages/AIPlayground/components/MsgBox/index.module.less +3 -2
  43. package/dist/pages/AIPlayground/components/MsgBox/useAutoScroll.js +46 -0
  44. package/dist/pages/AIPlayground/components/SessionLayout/index.js +41 -12
  45. package/dist/pages/AIPlayground/components/SessionLayout/index.module.less +4 -4
  46. package/dist/pages/AIPlayground/components/TaskBox/generateCode.js +129 -8
  47. package/dist/pages/AIPlayground/components/TaskBox/index.js +92 -55
  48. package/dist/pages/AIPlayground/components/TaskBox/index.module.less +1 -0
  49. package/dist/pages/AIPlayground/index.js +4 -1
  50. package/dist/pages/AIPlayground/index.module.less +5 -0
  51. package/dist/pages/Examples/components/Accouncement/index.module.less +1 -1
  52. package/dist/pages/Examples/index.module.less +11 -11
  53. package/dist/pages/Index/components/Cases/index.module.less +8 -8
  54. package/dist/pages/Index/components/Companies/index.module.less +4 -3
  55. package/dist/pages/Index/components/Features/FeatureCard.module.less +4 -5
  56. package/dist/pages/Index/components/Features/index.module.less +5 -5
  57. package/dist/pages/Index/components/_.less +9 -9
  58. package/dist/slots/Banner/Notification.module.less +8 -8
  59. package/dist/slots/Banner/index.module.less +10 -9
  60. package/dist/slots/CodeEditor/Toolbar.js +7 -25
  61. package/dist/slots/CodeEditor/index.js +34 -12
  62. package/dist/slots/CodeEditor/index.module.less +3 -1
  63. package/dist/slots/CodeEditor/utils.js +2 -1
  64. package/dist/slots/CodePreview/index.module.less +0 -3
  65. package/dist/slots/CodeRunner/index.js +23 -11
  66. package/dist/slots/ContentTable/index.module.less +2 -1
  67. package/dist/slots/Detail/News.module.less +9 -9
  68. package/dist/slots/Detail/index.js +2 -1
  69. package/dist/slots/Detail/index.module.less +11 -14
  70. package/dist/slots/ExampleSider/index.module.less +3 -4
  71. package/dist/slots/Footer/index.module.less +2 -2
  72. package/dist/slots/Header/Products/Product.module.less +2 -2
  73. package/dist/slots/Header/Search/SearchResult.js +20 -8
  74. package/dist/slots/Header/Search/SearchResult.module.less +1 -0
  75. package/dist/slots/Header/index.js +51 -25
  76. package/dist/slots/Header/index.module.less +13 -5
  77. package/dist/slots/LiveExample/index.module.less +1 -1
  78. package/dist/slots/Loading/index.module.less +30 -28
  79. package/dist/slots/ManualContent/index.module.less +14 -17
  80. package/dist/slots/_.less +9 -9
  81. package/dist/static/user.svg +3 -0
  82. package/dist/typings.d.ts +6 -0
  83. package/dist/utils/analytics.js +16 -0
  84. package/dist/utils/env.js +63 -0
  85. package/dist/utils/index.js +7 -0
  86. package/dist/utils/request.js +42 -0
  87. package/package.json +9 -5
  88. package/dist/static/SearchAiIcon.svg +0 -14
@@ -0,0 +1,147 @@
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
+ import { history } from 'dumi';
8
+ import { message } from "antd";
9
+ import { subscribeKey } from "valtio/utils";
10
+ import { trackEvent } from "../utils/analytics";
11
+
12
+ /**
13
+ * 检查当前 URL 是否包含 'skipLogin=1' 参数
14
+ * @returns {boolean} 如果包含则返回 true, 否则返回 false
15
+ */
16
+ function hasSkipLoginParam() {
17
+ if (typeof window === 'undefined') {
18
+ return false;
19
+ }
20
+ // 1. 获取当前 URL 的查询字符串 (例如 "?foo=bar&skipLogin=1")
21
+ var queryString = window.location.search;
22
+
23
+ // 2. 创建一个 URLSearchParams 实例
24
+ var urlParams = new URLSearchParams(queryString);
25
+
26
+ // 3. 使用 .get() 方法获取 'skipLogin' 参数的值,并判断是否为 '1'
27
+ // 注意:URL参数的值总是字符串类型,所以我们用 '1' 而不是 1 进行比较。
28
+ return urlParams.get('skipLogin') === '1';
29
+ }
30
+
31
+ // 1. 定义 State (只包含数据)
32
+ export var authStore = proxy({
33
+ isModalOpen: false,
34
+ isAuthenticated: false,
35
+ loginCallback: function loginCallback() {}
36
+ });
37
+ subscribeKey(authStore, 'isModalOpen', function (open) {
38
+ if (open) {
39
+ trackEvent('login_modal_open');
40
+ }
41
+ });
42
+
43
+ // 2. 定义 Actions (作为独立函数)
44
+ export var showLoginModal = function showLoginModal(callback) {
45
+ authStore.isModalOpen = true;
46
+ authStore.loginCallback = callback;
47
+ };
48
+ export var hideLoginModal = function hideLoginModal() {
49
+ authStore.isModalOpen = false;
50
+ };
51
+ export var loginOrRegister = /*#__PURE__*/function () {
52
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
53
+ var _authStore$loginCallb, _error$response, errorMessage;
54
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
55
+ while (1) switch (_context.prev = _context.next) {
56
+ case 0:
57
+ _context.prev = 0;
58
+ _context.next = 3;
59
+ return request.post('/api/modules/user/api/accounts/login_or_register', params);
60
+ case 3:
61
+ authStore.isAuthenticated = true;
62
+ hideLoginModal();
63
+ (_authStore$loginCallb = authStore.loginCallback) === null || _authStore$loginCallb === void 0 || _authStore$loginCallb.call(authStore);
64
+ return _context.abrupt("return", true);
65
+ case 9:
66
+ _context.prev = 9;
67
+ _context.t0 = _context["catch"](0);
68
+ console.error('Login failed in store:', _context.t0);
69
+ errorMessage = _context.t0 === null || _context.t0 === void 0 || (_error$response = _context.t0.response) === null || _error$response === void 0 || (_error$response = _error$response.data) === null || _error$response === void 0 ? void 0 : _error$response.message;
70
+ if (errorMessage) {
71
+ message.error(errorMessage);
72
+ }
73
+ return _context.abrupt("return", false);
74
+ case 15:
75
+ case "end":
76
+ return _context.stop();
77
+ }
78
+ }, _callee, null, [[0, 9]]);
79
+ }));
80
+ return function loginOrRegister(_x) {
81
+ return _ref.apply(this, arguments);
82
+ };
83
+ }();
84
+ export var logout = /*#__PURE__*/function () {
85
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
86
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
87
+ while (1) switch (_context2.prev = _context2.next) {
88
+ case 0:
89
+ _context2.prev = 0;
90
+ _context2.next = 3;
91
+ return request.delete('/api/modules/user/api/accounts/logout');
92
+ case 3:
93
+ _context2.next = 8;
94
+ break;
95
+ case 5:
96
+ _context2.prev = 5;
97
+ _context2.t0 = _context2["catch"](0);
98
+ console.error('Logout failed in store:', _context2.t0);
99
+ case 8:
100
+ _context2.prev = 8;
101
+ authStore.isAuthenticated = false;
102
+ history.push('/');
103
+ return _context2.finish(8);
104
+ case 12:
105
+ case "end":
106
+ return _context2.stop();
107
+ }
108
+ }, _callee2, null, [[0, 5, 8, 12]]);
109
+ }));
110
+ return function logout() {
111
+ return _ref2.apply(this, arguments);
112
+ };
113
+ }();
114
+ export function sendValidationCode(data) {
115
+ return request.post('/api/modules/user/api/validation_code/send', data);
116
+ }
117
+ export var initializeAuth = /*#__PURE__*/function () {
118
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
119
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
120
+ while (1) switch (_context3.prev = _context3.next) {
121
+ case 0:
122
+ _context3.prev = 0;
123
+ if (hasSkipLoginParam()) {
124
+ _context3.next = 4;
125
+ break;
126
+ }
127
+ _context3.next = 4;
128
+ return request.get('/api/modules/user/api/accounts/get_company_info');
129
+ case 4:
130
+ authStore.isAuthenticated = true;
131
+ _context3.next = 11;
132
+ break;
133
+ case 7:
134
+ _context3.prev = 7;
135
+ _context3.t0 = _context3["catch"](0);
136
+ console.error('Initialize auth failed in store:', _context3.t0);
137
+ authStore.isAuthenticated = false;
138
+ case 11:
139
+ case "end":
140
+ return _context3.stop();
141
+ }
142
+ }, _callee3, null, [[0, 7]]);
143
+ }));
144
+ return function initializeAuth() {
145
+ return _ref3.apply(this, arguments);
146
+ };
147
+ }();
@@ -10,10 +10,10 @@ 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";
16
15
  import { useIntl } from 'dumi';
16
+ import { isUUID } from "../../../../utils";
17
17
  export var ConversationsMenu = function ConversationsMenu() {
18
18
  var _useSetState = useSetState({
19
19
  open: false,
@@ -29,7 +29,9 @@ export var ConversationsMenu = function ConversationsMenu() {
29
29
  setCollapsed = _useState2[1];
30
30
  var snap = useSnapshot(AIChatStore);
31
31
  var handleSelectSession = function handleSelectSession(sessionId) {
32
- AIChatStore.activeSessionId = sessionId;
32
+ if (isUUID(sessionId)) {
33
+ AIChatStore.activeSessionId = sessionId;
34
+ }
33
35
  };
34
36
  var toggleCollapsed = function toggleCollapsed() {
35
37
  setCollapsed(!collapsed);
@@ -54,7 +56,7 @@ export var ConversationsMenu = function ConversationsMenu() {
54
56
  id: 'ai.conversations.new'
55
57
  }),
56
58
  onClick: function onClick() {
57
- return history.push('/');
59
+ return createPureNewSession();
58
60
  }
59
61
  }, {
60
62
  key: 'history',
@@ -83,7 +85,7 @@ export var ConversationsMenu = function ConversationsMenu() {
83
85
  setState({
84
86
  open: true,
85
87
  session: session,
86
- rename: session.title
88
+ rename: session.title.slice(0, 100)
87
89
  });
88
90
  }
89
91
  }, {
@@ -154,10 +156,16 @@ export var ConversationsMenu = function ConversationsMenu() {
154
156
  },
155
157
  okButtonProps: {
156
158
  disabled: !state.rename
157
- }
159
+ },
160
+ okText: formatMessage({
161
+ id: 'ai.conversations.ok'
162
+ }),
163
+ cancelText: formatMessage({
164
+ id: 'ai.conversations.cancel'
165
+ })
158
166
  }, /*#__PURE__*/React.createElement(Input, {
159
167
  showCount: true,
160
- maxLength: 20,
168
+ maxLength: 100,
161
169
  onChange: function onChange(e) {
162
170
  return setState({
163
171
  rename: e.target.value
@@ -1,5 +1,6 @@
1
1
  .container {
2
2
  background: #fff;
3
+
3
4
  :global {
4
5
  .ant-menu {
5
6
  width: 16vw;
@@ -38,6 +39,7 @@
38
39
  border-radius: 50%;
39
40
  transition: background-color 0.3s ease;
40
41
  cursor: pointer;
42
+
41
43
  &:hover{
42
44
  background-color: #fbfcfd;
43
45
  }
@@ -6,26 +6,29 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
7
  import React from 'react';
8
8
  import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
9
- import { a11yLight } from "react-syntax-highlighter/dist/cjs/styles/hljs";
9
+ import { oneLight } from 'react-syntax-highlighter/dist/esm/styles/prism';
10
10
  import { AIChatStore } from "../../../../model/AIChat";
11
- import { useCopyToClipboard } from "react-use";
12
- import { CheckOutlined, CopyOutlined, PlaySquareOutlined } from "@ant-design/icons";
13
- import { Space, Tooltip } from "antd";
11
+ import { useCopyToClipboard } from 'react-use';
12
+ import { CheckOutlined, CopyOutlined, PlaySquareOutlined } from '@ant-design/icons';
13
+ import { Button, Space, Tooltip } from 'antd';
14
14
  import styles from "./MarkdownCodeBlock.module.less";
15
- import { useIntl } from 'dumi';
15
+ import { useIntl } from 'dumi'; // 定义 props 类型,它将接收 react-markdown 传递的所有属性
16
16
 
17
17
  // 定义 props 类型,它将接收 react-markdown 传递的所有属性
18
18
 
19
- export var MarkdownCodeBlock = function MarkdownCodeBlock(_ref) {
19
+ export var MarkdownCodeBlock = /*#__PURE__*/React.memo(function (_ref) {
20
20
  var inline = _ref.inline,
21
21
  className = _ref.className,
22
- 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();
23
26
  var _useCopyToClipboard = useCopyToClipboard(),
24
27
  _useCopyToClipboard2 = _slicedToArray(_useCopyToClipboard, 2),
25
28
  copyState = _useCopyToClipboard2[0],
26
29
  copyToClipboard = _useCopyToClipboard2[1];
27
30
  // 1. 处理行内代码:如果是行内代码,不做特殊处理,直接返回一个 <code> 标签
28
- if (inline || typeof children === 'string' && !children.includes("\n")) {
31
+ if (inline || typeof children === 'string' && !children.includes('\n')) {
29
32
  return /*#__PURE__*/React.createElement("code", {
30
33
  className: className
31
34
  }, children);
@@ -39,7 +42,7 @@ export var MarkdownCodeBlock = function MarkdownCodeBlock(_ref) {
39
42
  var codeString = String(children).replace(/\n$/, '');
40
43
 
41
44
  // 4. 判断是否显示“运行”按钮
42
- var showRunButton = /\bimport\b/.test(codeString);
45
+ var showRunButton = showRunButtonProp && /\bimport\b/.test(codeString);
43
46
 
44
47
  // 5. 定义运行代码的逻辑
45
48
  var handleRunCode = function handleRunCode() {
@@ -48,7 +51,6 @@ export var MarkdownCodeBlock = function MarkdownCodeBlock(_ref) {
48
51
  };
49
52
 
50
53
  // 6. 返回最终的 JSX 结构
51
- var intl = useIntl();
52
54
  return /*#__PURE__*/React.createElement("div", {
53
55
  style: {
54
56
  position: 'relative',
@@ -60,8 +62,9 @@ export var MarkdownCodeBlock = function MarkdownCodeBlock(_ref) {
60
62
  title: intl.formatMessage({
61
63
  id: 'ai.markdown.copy'
62
64
  })
63
- }, /*#__PURE__*/React.createElement("button", {
64
- type: "button",
65
+ }, /*#__PURE__*/React.createElement(Button, {
66
+ variant: "link",
67
+ size: "small",
65
68
  onClick: function onClick() {
66
69
  return copyToClipboard(codeString);
67
70
  },
@@ -72,17 +75,23 @@ export var MarkdownCodeBlock = function MarkdownCodeBlock(_ref) {
72
75
  title: intl.formatMessage({
73
76
  id: 'ai.markdown.run'
74
77
  })
75
- }, /*#__PURE__*/React.createElement("button", {
76
- type: "button",
78
+ }, /*#__PURE__*/React.createElement(Button, {
79
+ variant: "link",
80
+ size: "small",
77
81
  onClick: handleRunCode,
78
82
  title: intl.formatMessage({
79
83
  id: 'ai.markdown.run'
80
84
  })
81
85
  }, /*#__PURE__*/React.createElement(PlaySquareOutlined, null)))), /*#__PURE__*/React.createElement(SyntaxHighlighter, {
82
- style: a11yLight,
83
- language: language,
86
+ style: oneLight,
87
+ language: language === 'vue' ? 'html' : language,
84
88
  PreTag: "div" // 使用 div 作为外层标签,避免 pre 标签的默认样式冲突
85
89
  ,
86
90
  showLineNumbers: false // (可选) 显示行号
91
+ ,
92
+ customStyle: {
93
+ paddingTop: '2em',
94
+ background: '#fafafa'
95
+ }
87
96
  }, codeString));
88
- };
97
+ });
@@ -3,9 +3,8 @@
3
3
  top: 0.5em;
4
4
  right: 0.5em;
5
5
  z-index: 1;
6
+
6
7
  button {
7
- background-color: #4a4a4a;
8
- color: white;
9
8
  border: none;
10
9
  border-radius: 5px;
11
10
  cursor: pointer;
@@ -8,8 +8,9 @@ import rehypeRaw from 'rehype-raw';
8
8
  import remarkGfm from 'remark-gfm';
9
9
  import { MarkdownCodeBlock } from "./MarkdownCodeBlock"; // 引入我们创建的自定义组件
10
10
 
11
- export var MarkdownComponent = function MarkdownComponent(_ref) {
12
- var content = _ref.content;
11
+ export var MarkdownComponent = /*#__PURE__*/React.memo(function (_ref) {
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, props);
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 标签
@@ -44,4 +47,4 @@ export var MarkdownComponent = function MarkdownComponent(_ref) {
44
47
  // a: (props) => <a style={{ color: 'green' }} target="_blank" rel="noopener noreferrer" {...props} />,
45
48
  }
46
49
  }, content);
47
- };
50
+ });