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

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:
@@ -1,4 +1,5 @@
1
1
  .container {
2
+ position: relative;
2
3
  margin-top: 32px;
3
4
  margin-left: auto;
4
5
  margin-right: auto;
@@ -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
  // --- 初始化逻辑 ---
@@ -13,6 +13,7 @@ import { useSnapshot } from 'valtio';
13
13
  import { AIChatStore, 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,
@@ -28,7 +29,9 @@ export var ConversationsMenu = function ConversationsMenu() {
28
29
  setCollapsed = _useState2[1];
29
30
  var snap = useSnapshot(AIChatStore);
30
31
  var handleSelectSession = function handleSelectSession(sessionId) {
31
- AIChatStore.activeSessionId = sessionId;
32
+ if (isUUID(sessionId)) {
33
+ AIChatStore.activeSessionId = sessionId;
34
+ }
32
35
  };
33
36
  var toggleCollapsed = function toggleCollapsed() {
34
37
  setCollapsed(!collapsed);
@@ -6,13 +6,13 @@ 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 { a11yLight } from 'react-syntax-highlighter/dist/cjs/styles/hljs';
10
10
  import { AIChatStore } from "../../../../model/AIChat";
11
- import { useCopyToClipboard } from "react-use";
12
- import { CheckOutlined, CopyOutlined, PlaySquareOutlined } from "@ant-design/icons";
13
- import { Button, 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
 
@@ -28,7 +28,7 @@ export var MarkdownCodeBlock = function MarkdownCodeBlock(_ref) {
28
28
  copyState = _useCopyToClipboard2[0],
29
29
  copyToClipboard = _useCopyToClipboard2[1];
30
30
  // 1. 处理行内代码:如果是行内代码,不做特殊处理,直接返回一个 <code> 标签
31
- if (inline || typeof children === 'string' && !children.includes("\n")) {
31
+ if (inline || typeof children === 'string' && !children.includes('\n')) {
32
32
  return /*#__PURE__*/React.createElement("code", {
33
33
  className: className
34
34
  }, children);
@@ -88,5 +88,9 @@ export var MarkdownCodeBlock = function MarkdownCodeBlock(_ref) {
88
88
  PreTag: "div" // 使用 div 作为外层标签,避免 pre 标签的默认样式冲突
89
89
  ,
90
90
  showLineNumbers: false // (可选) 显示行号
91
+ ,
92
+ customStyle: {
93
+ paddingTop: '2em'
94
+ }
91
95
  }, codeString));
92
96
  };
@@ -9,13 +9,13 @@ 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';
16
16
  import { useSnapshot } from 'valtio';
17
17
  import { PromptTextarea } from "../../../../components/AI/HomeDialog/PromptTextarea";
18
- import { AIChatStore, createPureNewSession, derivedState } from "../../../../model/AIChat";
18
+ import { AIChatStore, clearEmptySession, createPureNewSession, derivedState } from "../../../../model/AIChat";
19
19
  import { getCodeFromMarkdown, isPreviewable } from "../../../../utils/code";
20
20
  import { MarkdownComponent } from "../MarkdownComponent";
21
21
  import styles from "./index.module.less";
@@ -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(),
@@ -118,13 +112,15 @@ function MsgBox(props) {
118
112
  // xxx
119
113
  },
120
114
  // body 可以是函数,用于获取最新的动态值
121
- body: {
122
- gptConversationId: activeSessionIdRef.current,
123
- anonymousUserId: anonymousUserIdRef.current,
124
- mountId: 'container',
125
- antvContext: (latestUserMessage === null || latestUserMessage === void 0 ? void 0 : latestUserMessage.context) || props.context,
126
- library: (latestUserMessage === null || latestUserMessage === void 0 ? void 0 : latestUserMessage.lib) || lib,
127
- mode: latestUserMessage === null || latestUserMessage === void 0 ? void 0 : latestUserMessage.mode
115
+ body: function body() {
116
+ return {
117
+ gptConversationId: activeSessionIdRef.current,
118
+ anonymousUserId: anonymousUserIdRef.current,
119
+ mountId: 'container',
120
+ antvContext: (latestUserMessage === null || latestUserMessage === void 0 ? void 0 : latestUserMessage.context) || props.context,
121
+ library: AIChatStore.lib,
122
+ mode: latestUserMessage === null || latestUserMessage === void 0 ? void 0 : latestUserMessage.mode
123
+ };
128
124
  }
129
125
  }),
130
126
  messages: convertedInitialMessages,
@@ -141,6 +137,8 @@ function MsgBox(props) {
141
137
  var codeBlock = getCodeFromMarkdown(messageContent).code;
142
138
  AIChatStore.codeBlock = codeBlock;
143
139
  onCodegen === null || onCodegen === void 0 || onCodegen(codeBlock);
140
+ } else {
141
+ AIChatStore.codeBlock = '';
144
142
  }
145
143
  (_derivedState$activeS = derivedState.activeSession) === null || _derivedState$activeS === void 0 || (_derivedState$activeS = _derivedState$activeS.messages) === null || _derivedState$activeS === void 0 || _derivedState$activeS.push({
146
144
  id: crypto.randomUUID(),
@@ -188,7 +186,7 @@ function MsgBox(props) {
188
186
  }, {
189
187
  body: {
190
188
  context: fileSummary,
191
- lib: lib,
189
+ lib: snap.lib,
192
190
  mode: 'implement'
193
191
  }
194
192
  });
@@ -199,7 +197,7 @@ function MsgBox(props) {
199
197
  content: promptText,
200
198
  createdAt: Date.now(),
201
199
  context: fileSummary,
202
- lib: lib
200
+ lib: snap.lib
203
201
  });
204
202
  chatScrollIntoView();
205
203
  };
@@ -240,6 +238,11 @@ function MsgBox(props) {
240
238
  if (simple) {
241
239
  createPureNewSession(title);
242
240
  }
241
+ return function () {
242
+ if (simple) {
243
+ clearEmptySession();
244
+ }
245
+ };
243
246
  }, []);
244
247
  useEffect(function () {
245
248
  chatScrollIntoView();
@@ -323,8 +326,6 @@ function MsgBox(props) {
323
326
  marginBottom: 0
324
327
  },
325
328
  onConfirm: handleSubmit,
326
- lib: lib,
327
- onLibChange: setLib,
328
329
  onDataSummaryChange: setFileSummary
329
330
  })));
330
331
  }
@@ -1,26 +1,43 @@
1
- import React from 'react';
2
- import styles from "./index.module.less";
3
- import { ConversationsMenu } from "../ConversationsMenu";
4
- import { AIChatStore } from "../../../../model/AIChat";
5
- import { useSnapshot } from 'valtio';
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
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
+ 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
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
6
7
  import classnames from 'classnames';
8
+ import React, { useState } from 'react';
7
9
  import SplitPane from 'react-split-pane';
10
+ import { useSnapshot } from 'valtio';
11
+ import { AIChatStore } from "../../../../model/AIChat";
12
+ import { ConversationsMenu } from "../ConversationsMenu";
13
+ import styles from "./index.module.less";
8
14
  function SessionLayout(props) {
9
15
  var children = props.children;
10
16
  var snap = useSnapshot(AIChatStore);
17
+ var _useState = useState(false),
18
+ _useState2 = _slicedToArray(_useState, 2),
19
+ isDragging = _useState2[0],
20
+ setIsDragging = _useState2[1];
11
21
  if (!Array.isArray(children)) {
12
22
  return null;
13
23
  }
14
24
  return /*#__PURE__*/React.createElement("div", {
15
25
  className: styles.container
16
- }, /*#__PURE__*/React.createElement(ConversationsMenu, null),
26
+ }, /*#__PURE__*/React.createElement(ConversationsMenu, null), snap.codeBlock ?
27
+ /*#__PURE__*/
17
28
  // @ts-ignore
18
- snap.codeBlock ? /*#__PURE__*/React.createElement(SplitPane, {
29
+ React.createElement(SplitPane, {
19
30
  split: "vertical",
20
- defaultSize: "50vw",
31
+ defaultSize: '50vw',
32
+ onDragStarted: function onDragStarted() {
33
+ return setIsDragging(true);
34
+ },
35
+ onDragFinished: function onDragFinished() {
36
+ return setIsDragging(false);
37
+ },
21
38
  primary: "second",
22
39
  style: {
23
- position: "unset"
40
+ position: 'unset'
24
41
  }
25
42
  }, /*#__PURE__*/React.createElement("div", {
26
43
  className: classnames(styles.msgBox)
@@ -28,6 +45,16 @@ function SessionLayout(props) {
28
45
  className: styles.taskBox
29
46
  }, children[1])) : /*#__PURE__*/React.createElement("div", {
30
47
  className: classnames(styles.msgBox, styles.msgBoxFull)
31
- }, children[0]));
48
+ }, children[0]), isDragging && /*#__PURE__*/React.createElement("div", {
49
+ style: {
50
+ position: 'fixed',
51
+ top: 0,
52
+ left: 0,
53
+ right: 0,
54
+ bottom: 0,
55
+ zIndex: 9999,
56
+ cursor: 'col-resize' // 或 'row-resize' 用于水平分割
57
+ }
58
+ }));
32
59
  }
33
60
  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 {
@@ -32,5 +32,5 @@
32
32
  height: calc(100% - 32px);
33
33
  margin: 16px;
34
34
  flex-grow: 1;
35
- background: #fff;
35
+ background: transparent;
36
36
  }
@@ -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,
@@ -74,6 +73,7 @@ function TaskBox() {
74
73
  return /*#__PURE__*/React.createElement(CodeRunner, {
75
74
  isPlayground: true,
76
75
  showAI: false,
76
+ showEditor: false,
77
77
  size: 0.5,
78
78
  topic: snap.anonymousUserId,
79
79
  example: snap.activeSessionId,
@@ -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: {
@@ -59,7 +60,8 @@ var CodeEditor = function CodeEditor(_ref) {
59
60
  _ref$onFullscreen = _ref.onFullscreen,
60
61
  onFullscreen = _ref$onFullscreen === void 0 ? noop : _ref$onFullscreen,
61
62
  _ref$showAI = _ref.showAI,
62
- showAI = _ref$showAI === void 0 ? true : _ref$showAI;
63
+ showAI = _ref$showAI === void 0 ? true : _ref$showAI,
64
+ style = _ref.style;
63
65
  var umiLocation = useLocation();
64
66
  var locale = useLocale();
65
67
  var _useSiteData = useSiteData(),
@@ -109,6 +111,10 @@ var CodeEditor = function CodeEditor(_ref) {
109
111
  _useState14 = _slicedToArray(_useState13, 2),
110
112
  showAIDrawer = _useState14[0],
111
113
  setShowAIDrawer = _useState14[1];
114
+ var _useState15 = useState("_"),
115
+ _useState16 = _slicedToArray(_useState15, 2),
116
+ msgBoxKey = _useState16[0],
117
+ setMsgBoxKey = _useState16[1];
112
118
  var containerId = "playgroundScriptContainer_".concat(exampleId);
113
119
 
114
120
  // 出发 auto resize
@@ -394,7 +400,8 @@ var CodeEditor = function CodeEditor(_ref) {
394
400
  setCode(source);
395
401
  };
396
402
  return /*#__PURE__*/React.createElement("div", {
397
- className: styles.editor
403
+ className: styles.editor,
404
+ style: style
398
405
  }, /*#__PURE__*/React.createElement(Toolbar, {
399
406
  fileExtension: fileExtension,
400
407
  sourceCode: code,
@@ -464,7 +471,6 @@ var CodeEditor = function CodeEditor(_ref) {
464
471
  monacoRef.current = editor;
465
472
  }
466
473
  }), /*#__PURE__*/React.createElement(Drawer, {
467
- placement: "right",
468
474
  closable: true,
469
475
  open: showAIDrawer,
470
476
  getContainer: false,
@@ -473,9 +479,19 @@ var CodeEditor = function CodeEditor(_ref) {
473
479
  },
474
480
  rootClassName: styles.drawer,
475
481
  width: '80%',
476
- key: "".concat(umiLocation.hash, "_").concat(umiLocation.key)
477
- }, /*#__PURE__*/React.createElement(MsgBox, {
478
482
  key: "".concat(umiLocation.hash, "_").concat(umiLocation.key),
483
+ extra: /*#__PURE__*/React.createElement(Tooltip, {
484
+ title: intl.formatMessage({
485
+ id: 'ai.toolbar.clear.conversation'
486
+ })
487
+ }, /*#__PURE__*/React.createElement(Button, {
488
+ type: "link",
489
+ onClick: function onClick() {
490
+ return setMsgBoxKey(crypto.randomUUID());
491
+ }
492
+ }, /*#__PURE__*/React.createElement(ClearOutlined, null)))
493
+ }, /*#__PURE__*/React.createElement(MsgBox, {
494
+ key: "".concat(umiLocation.hash, "_").concat(umiLocation.key, "_").concat(msgBoxKey),
479
495
  simple: true,
480
496
  messages: [{
481
497
  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;
@@ -34,7 +34,9 @@ var CodeRunner = function CodeRunner(_ref) {
34
34
  _ref$notFound = _ref.notFound,
35
35
  notFound = _ref$notFound === void 0 ? /*#__PURE__*/React.createElement(NotFound, null) : _ref$notFound,
36
36
  _ref$showAI = _ref.showAI,
37
- showAI = _ref$showAI === void 0 ? true : _ref$showAI;
37
+ showAI = _ref$showAI === void 0 ? true : _ref$showAI,
38
+ _ref$showEditor = _ref.showEditor,
39
+ showEditor = _ref$showEditor === void 0 ? true : _ref$showEditor;
38
40
  var demoInfo = getDemoInfo(exampleTopics, topic, example, demo);
39
41
 
40
42
  // 找不到,啥也别干了,404 页面
@@ -61,18 +63,13 @@ var CodeRunner = function CodeRunner(_ref) {
61
63
  githubUrl: githubUrl
62
64
  });
63
65
  var exampleId = "".concat(topic, "_").concat(example, "_").concat(demo);
64
- return /*#__PURE__*/React.createElement(InViewSuspense, {
65
- fallback: null
66
- }, /*#__PURE__*/React.createElement(SplitPane, {
67
- split: "vertical",
68
- defaultSize: "".concat((1 - size) * 100, "%"),
69
- minSize: 100
70
- }, /*#__PURE__*/React.createElement(CodePreview, {
66
+ var codePreview = /*#__PURE__*/React.createElement(CodePreview, {
71
67
  exampleId: exampleId,
72
68
  error: error,
73
69
  header: header,
74
70
  isPlayground: isPlayground
75
- }), /*#__PURE__*/React.createElement(ClientOnly, null, /*#__PURE__*/React.createElement(CodeEditor, {
71
+ });
72
+ var codeEditor = /*#__PURE__*/React.createElement(ClientOnly, null, /*#__PURE__*/React.createElement(CodeEditor, {
76
73
  exampleId: exampleId,
77
74
  source: source,
78
75
  relativePath: relativePath,
@@ -83,7 +80,19 @@ var CodeRunner = function CodeRunner(_ref) {
83
80
  onReady: noop,
84
81
  playground: playground,
85
82
  title: ic(title),
86
- showAI: showAI
87
- }))));
83
+ showAI: showAI,
84
+ style: {
85
+ display: showEditor ? 'block' : 'none'
86
+ }
87
+ }));
88
+ return /*#__PURE__*/React.createElement(InViewSuspense, {
89
+ fallback: null
90
+ },
91
+ // @ts-ignore
92
+ showEditor ? /*#__PURE__*/React.createElement(SplitPane, {
93
+ split: "vertical",
94
+ defaultSize: "".concat((1 - size) * 100, "%"),
95
+ minSize: 100
96
+ }, codePreview, codeEditor) : /*#__PURE__*/React.createElement(React.Fragment, null, codePreview, codeEditor));
88
97
  };
89
98
  export default CodeRunner;
@@ -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.12",
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",