@antv/dumi-theme-antv 0.8.0-beta.10 → 0.8.0-beta.11

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.
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { Dropdown } from "antd";
3
3
  import { useProducts } from "../../../../../hooks/useProducts";
4
- import { useLocale, useIntl, FormattedMessage } from "dumi";
4
+ import { useLocale, FormattedMessage } from "dumi";
5
5
  import styles from "./index.module.less";
6
6
  export function ChooseLib(props) {
7
7
  var _data$find;
@@ -35,7 +35,6 @@ export function ChooseLib(props) {
35
35
  }
36
36
  };
37
37
  });
38
- var intl = useIntl();
39
38
  return /*#__PURE__*/React.createElement(Dropdown, {
40
39
  menu: {
41
40
  items: items
@@ -12,7 +12,7 @@ import { DatasourceCard } from "./DatasourceCard";
12
12
  import { useEventListener } from 'ahooks';
13
13
  import classnames from 'classnames';
14
14
  import _ from 'lodash';
15
- import React, { useRef, useState } from 'react';
15
+ import React, { useEffect, useRef, useState } from 'react';
16
16
  import styles from "./index.module.less";
17
17
  import { SendButton } from "./SendButton";
18
18
  import { ChooseLib } from "./ChooseLib";
@@ -21,6 +21,7 @@ import { ic } from "../../../../slots/hooks";
21
21
  import { useTypewriter } from "../../../../hooks/useTypewriter";
22
22
  import { authStore, showLoginModal } from "../../../../model/auth";
23
23
  import { useSnapshot } from "valtio";
24
+ import { AIChatStore } from "../../../../model/AIChat";
24
25
  var PLACEHOLDER = {
25
26
  implement: 'ai.placeholder.implement',
26
27
  solve: 'ai.placeholder.solve'
@@ -34,15 +35,20 @@ export var PromptTextarea = /*#__PURE__*/React.memo(function PromptTextareaInner
34
35
  onCancel = props.onCancel,
35
36
  loading = props.loading,
36
37
  mode = props.mode,
37
- lib = props.lib,
38
- onLibChange = props.onLibChange,
39
38
  _props$showAction = props.showAction,
40
39
  showAction = _props$showAction === void 0 ? true : _props$showAction;
40
+ var snap = useSnapshot(AIChatStore);
41
41
  var authSnap = useSnapshot(authStore);
42
42
  var _useIntl = useIntl(),
43
43
  formatMessage = _useIntl.formatMessage;
44
44
  var textareaRef = useRef(null);
45
-
45
+ var _useSiteData = useSiteData(),
46
+ themeConfig = _useSiteData.themeConfig;
47
+ useEffect(function () {
48
+ if (!themeConfig.isAntVSite && !snap.lib) {
49
+ AIChatStore.lib = themeConfig.title;
50
+ }
51
+ }, [themeConfig.isAntVSite, themeConfig.title]);
46
52
  // 将fileMeta状态移到组件内部管理
47
53
  var _useState = useState(null),
48
54
  _useState2 = _slicedToArray(_useState, 2),
@@ -55,8 +61,6 @@ export var PromptTextarea = /*#__PURE__*/React.memo(function PromptTextareaInner
55
61
  focus = _useState4[0],
56
62
  setFocus = _useState4[1];
57
63
  var isCompact = size === 'compact';
58
- var _useSiteData = useSiteData(),
59
- themeConfig = _useSiteData.themeConfig;
60
64
  var typedPlaceholder = useTypewriter({
61
65
  texts: [formatMessage({
62
66
  id: 'ai.placeholder.whatis'
@@ -145,9 +149,11 @@ export var PromptTextarea = /*#__PURE__*/React.memo(function PromptTextareaInner
145
149
  }, /*#__PURE__*/React.createElement("div", {
146
150
  className: styles.dataActions
147
151
  }, showAction && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ChooseLib, {
148
- value: lib,
149
- onChange: onLibChange,
150
- size: size
152
+ size: size,
153
+ value: snap.lib,
154
+ onChange: function onChange(s) {
155
+ return AIChatStore.lib = s;
156
+ }
151
157
  }))), /*#__PURE__*/React.createElement("div", {
152
158
  className: styles.actions
153
159
  }, loading ? /*#__PURE__*/React.createElement("img", {
@@ -29,19 +29,19 @@ export var RecommendCase = function RecommendCase(props) {
29
29
  list = _useState4[0],
30
30
  setList = _useState4[1];
31
31
  var fetchList = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
32
- var data;
32
+ var _themeConfig$ai, data;
33
33
  return _regeneratorRuntime().wrap(function _callee$(_context) {
34
34
  while (1) switch (_context.prev = _context.next) {
35
35
  case 0:
36
36
  _context.prev = 0;
37
37
  setLoading(true);
38
38
  data = [];
39
- if (!(themeConfig !== null && themeConfig !== void 0 && themeConfig.recommend)) {
39
+ if (!(themeConfig !== null && themeConfig !== void 0 && (_themeConfig$ai = themeConfig.ai) !== null && _themeConfig$ai !== void 0 && _themeConfig$ai.recommend)) {
40
40
  _context.next = 9;
41
41
  break;
42
42
  }
43
43
  _context.next = 6;
44
- return fetch(themeConfig.recommend).then(function (res) {
44
+ return fetch(themeConfig.ai.recommend).then(function (res) {
45
45
  return res.json();
46
46
  });
47
47
  case 6:
@@ -13,30 +13,24 @@ import { ModeSelector } from "./ModeSelector";
13
13
  import { useLocalStorageState } from 'ahooks';
14
14
  import { AIMode } from "../constant";
15
15
  import classnames from 'classnames';
16
- import { useSiteData, useLocale } from 'dumi';
16
+ import { useLocale } from 'dumi';
17
17
  import { createNewSession } from "../../../model/AIChat";
18
18
  export function HomeDialog(props) {
19
19
  var locale = useLocale();
20
- var _useSiteData = useSiteData(),
21
- themeConfig = _useSiteData.themeConfig;
22
- var _useState = useState(!themeConfig.isAntVSite ? themeConfig.title : undefined),
23
- _useState2 = _slicedToArray(_useState, 2),
24
- lib = _useState2[0],
25
- setLib = _useState2[1];
26
20
  var _useLocalStorageState = useLocalStorageState('use-local-storage-ai-mode-type', {
27
21
  defaultValue: AIMode.implement
28
22
  }),
29
23
  _useLocalStorageState2 = _slicedToArray(_useLocalStorageState, 2),
30
24
  mode = _useLocalStorageState2[0],
31
25
  setMode = _useLocalStorageState2[1];
26
+ var _useState = useState(''),
27
+ _useState2 = _slicedToArray(_useState, 2),
28
+ promptText = _useState2[0],
29
+ setPromptText = _useState2[1];
32
30
  var _useState3 = useState(''),
33
31
  _useState4 = _slicedToArray(_useState3, 2),
34
- promptText = _useState4[0],
35
- setPromptText = _useState4[1];
36
- var _useState5 = useState(''),
37
- _useState6 = _slicedToArray(_useState5, 2),
38
- fileSummary = _useState6[0],
39
- setFileSummary = _useState6[1];
32
+ fileSummary = _useState4[0],
33
+ setFileSummary = _useState4[1];
40
34
  return /*#__PURE__*/React.createElement("div", {
41
35
  className: classnames(styles.content, props.className),
42
36
  style: props.style
@@ -49,10 +43,6 @@ export function HomeDialog(props) {
49
43
  }), /*#__PURE__*/React.createElement(PromptTextarea, {
50
44
  mode: mode,
51
45
  value: promptText,
52
- lib: lib,
53
- onLibChange: function onLibChange(v) {
54
- setLib(v);
55
- },
56
46
  onChange: function onChange(val) {
57
47
  setPromptText(val);
58
48
  },
@@ -60,7 +50,6 @@ export function HomeDialog(props) {
60
50
  createNewSession({
61
51
  promptText: promptText,
62
52
  mode: mode,
63
- lib: lib,
64
53
  jump: true,
65
54
  context: fileSummary,
66
55
  lang: locale.id
@@ -218,6 +218,7 @@
218
218
  "ai.toolbar.open.stackblitz": "Open in StackBlitz",
219
219
  "ai.toolbar.open.riddle": "Open in Riddle",
220
220
  "ai.toolbar.html.code": "HTML Code",
221
+ "ai.toolbar.clear.conversation": "Clear Conversation",
221
222
  "ai.conversations.expand": "Expand",
222
223
  "ai.conversations.collapse": "Collapse",
223
224
  "ai.conversations.new": "Start New Chat",
@@ -232,6 +233,9 @@
232
233
  "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
234
  "ai.placeholder.whatis": "What is {title}?",
234
235
  "header.ai.code": "AI Code Generation",
236
+ "header.user.history": "History",
237
+ "header.user.logout": "Logout",
238
+ "header.user.deleteAccount": "Delete Account",
235
239
  "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
240
  "header.china.mirror.temp.close": "Close Temporarily",
237
241
  "header.china.mirror.no.more": "Don't Remind Again",
@@ -217,6 +217,7 @@
217
217
  "ai.toolbar.open.stackblitz": "在 StackBlitz 中打开",
218
218
  "ai.toolbar.open.riddle": "在 Riddle 中打开",
219
219
  "ai.toolbar.html.code": "HTML 代码",
220
+ "ai.toolbar.clear.conversation": "清空对话",
220
221
  "ai.conversations.expand": "展开",
221
222
  "ai.conversations.collapse": "收起",
222
223
  "ai.conversations.new": "开始新对话",
@@ -231,6 +232,9 @@
231
232
  "ai.assistant.editor.intro": "我是AntV AI助手。您可以随时向我提问,让我为您:\n\n1、解读当前图表的代码配置。\n2、通过自然语言对话,基于当前案例生成新代码以定制图表。",
232
233
  "ai.placeholder.whatis": "{title}是什么?",
233
234
  "header.ai.code": "AI生码",
235
+ "header.user.history": "历史会话",
236
+ "header.user.logout": "退出登录",
237
+ "header.user.deleteAccount": "注销账号",
234
238
  "header.china.mirror.title": "AntV 系列网站部署在 gh-pages 上,若访问速度不佳,可以前往国内镜像站点。",
235
239
  "header.china.mirror.temp.close": "暂时关闭",
236
240
  "header.china.mirror.no.more": "不再提醒",
@@ -27,7 +27,8 @@ var initialState = {
27
27
  sessions: [],
28
28
  activeSessionId: null,
29
29
  tempMessage: null,
30
- codeBlock: null
30
+ codeBlock: null,
31
+ lib: null
31
32
  };
32
33
 
33
34
  // --- valtio Store 创建 ---
@@ -53,6 +54,11 @@ export var clearEmptySession = function clearEmptySession() {
53
54
  AIChatStore.sessions = AIChatStore.sessions.filter(function (s) {
54
55
  return s.messages.length > 0;
55
56
  });
57
+ if (AIChatStore.sessions.every(function (s) {
58
+ return s.id !== AIChatStore.activeSessionId;
59
+ }) && AIChatStore.sessions.length > 0) {
60
+ AIChatStore.activeSessionId = AIChatStore.sessions[0].id;
61
+ }
56
62
  };
57
63
 
58
64
  // --- 初始化逻辑 ---
@@ -4,15 +4,16 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
4
4
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
5
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import React, { useState } from 'react';
7
+ import React, { useEffect, useState } from 'react';
8
8
  import { DeleteOutlined, EditOutlined, EllipsisOutlined, HistoryOutlined, MenuFoldOutlined, MenuUnfoldOutlined, PlusSquareOutlined, VerticalAlignTopOutlined } from '@ant-design/icons';
9
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, createPureNewSession, handleDeleteSession, handlePinSession, handleRenameSession } from "../../../../model/AIChat";
13
+ import { AIChatStore, clearEmptySession, createPureNewSession, handleDeleteSession, handlePinSession, handleRenameSession } from "../../../../model/AIChat";
14
14
  import { useSetState } from "ahooks";
15
15
  import { useIntl } from 'dumi';
16
+ import { isUUID } from "../../../../utils";
16
17
  export var ConversationsMenu = function ConversationsMenu() {
17
18
  var _useSetState = useSetState({
18
19
  open: false,
@@ -27,8 +28,13 @@ export var ConversationsMenu = function ConversationsMenu() {
27
28
  collapsed = _useState2[0],
28
29
  setCollapsed = _useState2[1];
29
30
  var snap = useSnapshot(AIChatStore);
31
+ useEffect(function () {
32
+ clearEmptySession();
33
+ }, []);
30
34
  var handleSelectSession = function handleSelectSession(sessionId) {
31
- AIChatStore.activeSessionId = sessionId;
35
+ if (isUUID(sessionId)) {
36
+ AIChatStore.activeSessionId = sessionId;
37
+ }
32
38
  };
33
39
  var toggleCollapsed = function toggleCollapsed() {
34
40
  setCollapsed(!collapsed);
@@ -9,7 +9,7 @@ import { Bubble } from '@ant-design/x';
9
9
  import { Button, Flex, Space, Tooltip } from 'antd';
10
10
  import { useChat } from '@ai-sdk/react';
11
11
  import { TextStreamChatTransport } from 'ai';
12
- import { useIntl, useSiteData } from 'dumi';
12
+ import { useIntl } from 'dumi';
13
13
  import { findLast } from 'lodash-es';
14
14
  import React, { useEffect, useState, useMemo, useRef } from 'react';
15
15
  import { useCopyToClipboard } from 'react-use';
@@ -70,22 +70,16 @@ function MsgBox(props) {
70
70
  simple = _props$simple === void 0 ? false : _props$simple,
71
71
  onCodegen = props.onCodegen,
72
72
  title = props.title;
73
- var _useSiteData = useSiteData(),
74
- themeConfig = _useSiteData.themeConfig;
75
73
  var _useIntl = useIntl(),
76
74
  formatMessage = _useIntl.formatMessage;
77
- var _useState = useState(!themeConfig.isAntVSite ? themeConfig.title : undefined),
75
+ var _useState = useState(''),
78
76
  _useState2 = _slicedToArray(_useState, 2),
79
- lib = _useState2[0],
80
- setLib = _useState2[1];
77
+ promptText = _useState2[0],
78
+ setPromptText = _useState2[1];
81
79
  var _useState3 = useState(''),
82
80
  _useState4 = _slicedToArray(_useState3, 2),
83
- promptText = _useState4[0],
84
- setPromptText = _useState4[1];
85
- var _useState5 = useState(''),
86
- _useState6 = _slicedToArray(_useState5, 2),
87
- fileSummary = _useState6[0],
88
- setFileSummary = _useState6[1];
81
+ fileSummary = _useState4[0],
82
+ setFileSummary = _useState4[1];
89
83
  var snap = useSnapshot(AIChatStore);
90
84
  var derivedSnap = useSnapshot(derivedState);
91
85
  var _useCopyToClipboard = useCopyToClipboard(),
@@ -123,7 +117,7 @@ function MsgBox(props) {
123
117
  anonymousUserId: anonymousUserIdRef.current,
124
118
  mountId: 'container',
125
119
  antvContext: (latestUserMessage === null || latestUserMessage === void 0 ? void 0 : latestUserMessage.context) || props.context,
126
- library: (latestUserMessage === null || latestUserMessage === void 0 ? void 0 : latestUserMessage.lib) || lib,
120
+ library: snap.lib,
127
121
  mode: latestUserMessage === null || latestUserMessage === void 0 ? void 0 : latestUserMessage.mode
128
122
  }
129
123
  }),
@@ -141,6 +135,8 @@ function MsgBox(props) {
141
135
  var codeBlock = getCodeFromMarkdown(messageContent).code;
142
136
  AIChatStore.codeBlock = codeBlock;
143
137
  onCodegen === null || onCodegen === void 0 || onCodegen(codeBlock);
138
+ } else {
139
+ AIChatStore.codeBlock = '';
144
140
  }
145
141
  (_derivedState$activeS = derivedState.activeSession) === null || _derivedState$activeS === void 0 || (_derivedState$activeS = _derivedState$activeS.messages) === null || _derivedState$activeS === void 0 || _derivedState$activeS.push({
146
142
  id: crypto.randomUUID(),
@@ -188,7 +184,7 @@ function MsgBox(props) {
188
184
  }, {
189
185
  body: {
190
186
  context: fileSummary,
191
- lib: lib,
187
+ lib: snap.lib,
192
188
  mode: 'implement'
193
189
  }
194
190
  });
@@ -199,7 +195,7 @@ function MsgBox(props) {
199
195
  content: promptText,
200
196
  createdAt: Date.now(),
201
197
  context: fileSummary,
202
- lib: lib
198
+ lib: snap.lib
203
199
  });
204
200
  chatScrollIntoView();
205
201
  };
@@ -323,8 +319,6 @@ function MsgBox(props) {
323
319
  marginBottom: 0
324
320
  },
325
321
  onConfirm: handleSubmit,
326
- lib: lib,
327
- onLibChange: setLib,
328
322
  onDataSummaryChange: setFileSummary
329
323
  })));
330
324
  }
@@ -1,10 +1,13 @@
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); }
1
5
  import React from 'react';
2
6
  import styles from "./index.module.less";
3
7
  import { ConversationsMenu } from "../ConversationsMenu";
4
8
  import { AIChatStore } from "../../../../model/AIChat";
5
9
  import { useSnapshot } from 'valtio';
6
10
  import classnames from 'classnames';
7
- import SplitPane from 'react-split-pane';
8
11
  function SessionLayout(props) {
9
12
  var children = props.children;
10
13
  var snap = useSnapshot(AIChatStore);
@@ -13,21 +16,10 @@ function SessionLayout(props) {
13
16
  }
14
17
  return /*#__PURE__*/React.createElement("div", {
15
18
  className: styles.container
16
- }, /*#__PURE__*/React.createElement(ConversationsMenu, null),
17
- // @ts-ignore
18
- snap.codeBlock ? /*#__PURE__*/React.createElement(SplitPane, {
19
- split: "vertical",
20
- defaultSize: "50vw",
21
- primary: "second",
22
- style: {
23
- position: "unset"
24
- }
25
- }, /*#__PURE__*/React.createElement("div", {
26
- className: classnames(styles.msgBox)
27
- }, children[0]), /*#__PURE__*/React.createElement("div", {
19
+ }, /*#__PURE__*/React.createElement(ConversationsMenu, null), /*#__PURE__*/React.createElement("div", {
20
+ className: classnames(styles.msgBox, _defineProperty(_defineProperty({}, styles.msgBoxHalf, snap.codeBlock), styles.msgBoxFull, !snap.codeBlock))
21
+ }, children[0]), snap.codeBlock && /*#__PURE__*/React.createElement("div", {
28
22
  className: styles.taskBox
29
- }, children[1])) : /*#__PURE__*/React.createElement("div", {
30
- className: classnames(styles.msgBox, styles.msgBoxFull)
31
- }, children[0]));
23
+ }, children[1]));
32
24
  }
33
25
  export { SessionLayout };
@@ -21,7 +21,7 @@
21
21
  }
22
22
 
23
23
  .msgBoxHalf {
24
- max-width: 30vw;
24
+ max-width: 40vw;
25
25
  }
26
26
 
27
27
  .msgBoxFull {
@@ -61,7 +61,6 @@ function TaskBox() {
61
61
  displayMode: "code-and-preview",
62
62
  initialView: "preview",
63
63
  theme: "light",
64
- editable: true,
65
64
  code: wrap2VisionSnap(snap.codeBlock),
66
65
  requestProxy: requestProxy,
67
66
  isStreaming: false,
@@ -13,9 +13,9 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
13
13
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
14
14
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
15
  import MonacoEditor, { loader } from '@monaco-editor/react';
16
- import { Drawer, Switch } from 'antd';
16
+ import { Button, Drawer, Switch, Tooltip } from 'antd';
17
17
  import { autoType as d3AutoType, dsvFormat } from 'd3-dsv';
18
- import { useLocale, useSiteData, useIntl, useLocation } from 'dumi';
18
+ import { useIntl, useLocale, useLocation, useSiteData } from 'dumi';
19
19
  import { debounce, noop } from 'lodash-es';
20
20
  import { format } from 'prettier';
21
21
  import parserBabel from 'prettier/parser-babel';
@@ -26,6 +26,7 @@ import styles from "./index.module.less";
26
26
  import { EDITOR_TABS, Toolbar } from "./Toolbar";
27
27
  import { compile, execute, replaceInsertCss } from "./utils";
28
28
  import MsgBox from "../../pages/AIPlayground/components/MsgBox";
29
+ import { ClearOutlined } from '@ant-design/icons';
29
30
  loader.config({
30
31
  'vs/nls': {
31
32
  availableLanguages: {
@@ -109,6 +110,10 @@ var CodeEditor = function CodeEditor(_ref) {
109
110
  _useState14 = _slicedToArray(_useState13, 2),
110
111
  showAIDrawer = _useState14[0],
111
112
  setShowAIDrawer = _useState14[1];
113
+ var _useState15 = useState("_"),
114
+ _useState16 = _slicedToArray(_useState15, 2),
115
+ msgBoxKey = _useState16[0],
116
+ setMsgBoxKey = _useState16[1];
112
117
  var containerId = "playgroundScriptContainer_".concat(exampleId);
113
118
 
114
119
  // 出发 auto resize
@@ -464,7 +469,6 @@ var CodeEditor = function CodeEditor(_ref) {
464
469
  monacoRef.current = editor;
465
470
  }
466
471
  }), /*#__PURE__*/React.createElement(Drawer, {
467
- placement: "right",
468
472
  closable: true,
469
473
  open: showAIDrawer,
470
474
  getContainer: false,
@@ -473,9 +477,19 @@ var CodeEditor = function CodeEditor(_ref) {
473
477
  },
474
478
  rootClassName: styles.drawer,
475
479
  width: '80%',
476
- key: "".concat(umiLocation.hash, "_").concat(umiLocation.key)
477
- }, /*#__PURE__*/React.createElement(MsgBox, {
478
480
  key: "".concat(umiLocation.hash, "_").concat(umiLocation.key),
481
+ extra: /*#__PURE__*/React.createElement(Tooltip, {
482
+ title: intl.formatMessage({
483
+ id: 'ai.toolbar.clear.conversation'
484
+ })
485
+ }, /*#__PURE__*/React.createElement(Button, {
486
+ type: "link",
487
+ onClick: function onClick() {
488
+ return setMsgBoxKey(crypto.randomUUID());
489
+ }
490
+ }, /*#__PURE__*/React.createElement(ClearOutlined, null)))
491
+ }, /*#__PURE__*/React.createElement(MsgBox, {
492
+ key: "".concat(umiLocation.hash, "_").concat(umiLocation.key, "_").concat(msgBoxKey),
479
493
  simple: true,
480
494
  messages: [{
481
495
  id: crypto.randomUUID(),
@@ -20,7 +20,6 @@
20
20
  div.ant-drawer-header {
21
21
  padding-bottom: unset;
22
22
  border-bottom: unset;
23
- flex-direction: row-reverse;
24
23
 
25
24
  .ant-drawer-header-title {
26
25
  flex: unset;
@@ -13,10 +13,10 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
13
13
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
14
14
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
15
15
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
- import { CaretDownFilled, DownOutlined, GithubOutlined, LinkOutlined, LogoutOutlined, MenuOutlined, UserDeleteOutlined, WechatOutlined } from '@ant-design/icons';
16
+ import { CaretDownFilled, DownOutlined, GithubOutlined, LinkOutlined, LogoutOutlined, MenuOutlined, MessageOutlined, UserDeleteOutlined, WechatOutlined } from '@ant-design/icons';
17
17
  import { Alert, Button, Dropdown, Menu, Modal, Popover } from 'antd';
18
18
  import cx from 'classnames';
19
- import { FormattedMessage, Link, useLocale, useSiteData } from 'dumi';
19
+ import { FormattedMessage, Link, useLocale, useSiteData, useIntl, history } from 'dumi';
20
20
  import { get, map, size } from 'lodash-es';
21
21
  import React, { useEffect, useMemo, useState } from 'react';
22
22
  import { useMedia } from 'react-use';
@@ -85,6 +85,7 @@ var HeaderComponent = function HeaderComponent(_ref) {
85
85
  _useState2 = _slicedToArray(_useState, 2),
86
86
  bannerVisible = _useState2[0],
87
87
  setBannerVisible = _useState2[1];
88
+ var intl = useIntl();
88
89
  var showChinaMirror = !!internalSite;
89
90
  var chinaMirrorUrl = get(internalSite, 'url');
90
91
  var _useState3 = useState(false),
@@ -412,12 +413,24 @@ var HeaderComponent = function HeaderComponent(_ref) {
412
413
  }, /*#__PURE__*/React.createElement(Dropdown, {
413
414
  menu: {
414
415
  items: [{
416
+ key: 'history',
417
+ label: /*#__PURE__*/React.createElement("a", {
418
+ onClick: function onClick() {
419
+ return history.push("/".concat(lang || 'zh', "/ai-playground"));
420
+ }
421
+ }, intl.formatMessage({
422
+ id: 'header.user.history'
423
+ })),
424
+ icon: /*#__PURE__*/React.createElement(MessageOutlined, null)
425
+ }, {
415
426
  key: 'logout',
416
427
  label: /*#__PURE__*/React.createElement("a", {
417
428
  onClick: function onClick() {
418
429
  return logout();
419
430
  }
420
- }, "\u9000\u51FA\u767B\u5F55"),
431
+ }, intl.formatMessage({
432
+ id: 'header.user.logout'
433
+ })),
421
434
  icon: /*#__PURE__*/React.createElement(LogoutOutlined, null)
422
435
  }, {
423
436
  key: 'deleteAccount',
@@ -426,7 +439,9 @@ var HeaderComponent = function HeaderComponent(_ref) {
426
439
  logout();
427
440
  clearAllChatData();
428
441
  }
429
- }, "\u6CE8\u9500\u8D26\u53F7"),
442
+ }, intl.formatMessage({
443
+ id: 'header.user.deleteAccount'
444
+ })),
430
445
  icon: /*#__PURE__*/React.createElement(UserDeleteOutlined, null)
431
446
  }]
432
447
  }
@@ -0,0 +1,7 @@
1
+ export function isUUID(str) {
2
+ if (typeof str !== 'string') {
3
+ return false;
4
+ }
5
+ var regex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
6
+ return regex.test(str);
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/dumi-theme-antv",
3
- "version": "0.8.0-beta.10",
3
+ "version": "0.8.0-beta.11",
4
4
  "description": "AntV website theme based on dumi2.",
5
5
  "keywords": [
6
6
  "dumi",
@@ -62,7 +62,6 @@
62
62
  "@ant-design/x": "^1.6.1",
63
63
  "@babel/plugin-syntax-unicode-sets-regex": "^7.18.6",
64
64
  "@babel/standalone": "^7.26.2",
65
- "@codesandbox/sandpack-react": "^2.20.0",
66
65
  "@docsearch/css": "^3.8.0",
67
66
  "@docsearch/react": "^3.8.0",
68
67
  "@emotion/server": "^11.11.0",