@antv/dumi-theme-antv 0.8.0-beta.2 → 0.8.0-beta.3
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/components/AI/HomeDialog/PromptTextarea/ChooseLib/index.module.less +0 -1
- package/dist/hooks/useProducts.js +3 -2
- package/dist/pages/AIPlayground/components/SessionLayout/index.module.less +0 -1
- package/dist/pages/AIPlayground/components/TaskBox/index.js +77 -33
- package/dist/slots/CodeEditor/Toolbar.js +5 -3
- package/dist/slots/CodeEditor/index.js +10 -7
- package/dist/slots/CodeRunner/index.js +5 -2
- package/package.json +1 -1
- package/dist/static/SearchAiIcon.svg +0 -14
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { useQuery } from '@tanstack/react-query';
|
|
2
2
|
export function getProducts() {
|
|
3
3
|
// 如需要修改产品信息,请到 https://yuyan.antfin-inc.com/antv/site-data/sprints 修改区块内容
|
|
4
|
-
return fetch(
|
|
5
|
-
// 'https://
|
|
4
|
+
return fetch(
|
|
5
|
+
// 'https://assets.antv.antgroup.com/antv/products.json', // 生产环境
|
|
6
|
+
'https://site-data-pre.alipay.com/antv/products.json' // 预发测试
|
|
6
7
|
).then(function (res) {
|
|
7
8
|
return res.json();
|
|
8
9
|
});
|
|
@@ -1,14 +1,47 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { Sandpack } from '@codesandbox/sandpack-react';
|
|
2
|
+
import { useSiteData } from 'dumi';
|
|
3
|
+
import React, { useMemo } from 'react';
|
|
4
|
+
import { useSnapshot } from 'valtio';
|
|
4
5
|
import { AIChatStore } from "../../../../model/AIChat";
|
|
5
|
-
import
|
|
6
|
+
import CodeRunner from "dumi/theme/slots/CodeRunner";
|
|
6
7
|
import { wrap2Sandpack } from "./generateCode";
|
|
8
|
+
import styles from "./index.module.less";
|
|
7
9
|
// import {code} from "../../demo";
|
|
8
10
|
// import {requestProxy, useVisionsnapSdk} from "../../../../hooks/useVisionsnapSdk";
|
|
9
11
|
|
|
10
12
|
function TaskBox() {
|
|
11
13
|
var snap = useSnapshot(AIChatStore);
|
|
14
|
+
var _useSiteData = useSiteData(),
|
|
15
|
+
themeConfig = _useSiteData.themeConfig;
|
|
16
|
+
var demoId = useMemo(function () {
|
|
17
|
+
return crypto.randomUUID();
|
|
18
|
+
}, [snap.codeBlock]);
|
|
19
|
+
var exampleTopics = useMemo(function () {
|
|
20
|
+
return [{
|
|
21
|
+
icon: '',
|
|
22
|
+
title: {},
|
|
23
|
+
id: snap.anonymousUserId,
|
|
24
|
+
examples: [
|
|
25
|
+
// 这是一个 Example 对象
|
|
26
|
+
{
|
|
27
|
+
icon: '',
|
|
28
|
+
title: {},
|
|
29
|
+
id: snap.activeSessionId,
|
|
30
|
+
api: 'https://example.com/api/pie-chart',
|
|
31
|
+
// 必须的 api 属性
|
|
32
|
+
demos: [
|
|
33
|
+
// 这是一个 Demo 对象
|
|
34
|
+
{
|
|
35
|
+
id: demoId,
|
|
36
|
+
screenshot: '',
|
|
37
|
+
title: {},
|
|
38
|
+
filename: 'index.tsx',
|
|
39
|
+
// 必须的 filename 属性
|
|
40
|
+
source: snap.codeBlock
|
|
41
|
+
}]
|
|
42
|
+
}]
|
|
43
|
+
}];
|
|
44
|
+
}, [demoId, snap.activeSessionId, snap.anonymousUserId, snap.codeBlock]);
|
|
12
45
|
|
|
13
46
|
// const { sdk, loading } = useVisionsnapSdk('3.2.4');
|
|
14
47
|
//
|
|
@@ -27,35 +60,46 @@ function TaskBox() {
|
|
|
27
60
|
// // requestProxy={requestProxy}
|
|
28
61
|
// isStreaming={false} />
|
|
29
62
|
// );
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
63
|
+
if (themeConfig.isAntVSite) {
|
|
64
|
+
return /*#__PURE__*/React.createElement(Sandpack, {
|
|
65
|
+
template: "vanilla" // 指定项目模板,Sandpack 会据此配置环境
|
|
66
|
+
,
|
|
67
|
+
files: wrap2Sandpack(snap.codeBlock),
|
|
68
|
+
options: {
|
|
69
|
+
showLineNumbers: true,
|
|
70
|
+
// 显示行号
|
|
71
|
+
showTabs: true,
|
|
72
|
+
closableTabs: false,
|
|
73
|
+
editorHeight: 'calc(100vh - 150px)',
|
|
74
|
+
rtl: true,
|
|
75
|
+
classes: {
|
|
76
|
+
'sp-layout': styles['antv-sp-layout']
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
theme: "light" // 主题:dark, light, auto
|
|
80
|
+
,
|
|
81
|
+
customSetup: {
|
|
82
|
+
entry: '/index.tsx',
|
|
83
|
+
npmRegistries: [{
|
|
84
|
+
limitToScopes: false,
|
|
85
|
+
// 设为 false 使所有包都从自定义 registry 获取
|
|
86
|
+
registryUrl: 'https://registry.npmmirror.com',
|
|
87
|
+
// 使用淘宝镜像
|
|
88
|
+
enabledScopes: [],
|
|
89
|
+
proxyEnabled: false
|
|
90
|
+
}]
|
|
44
91
|
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}]
|
|
58
|
-
}
|
|
59
|
-
});
|
|
92
|
+
});
|
|
93
|
+
} else {
|
|
94
|
+
return /*#__PURE__*/React.createElement(CodeRunner, {
|
|
95
|
+
isPlayground: true,
|
|
96
|
+
showAI: false,
|
|
97
|
+
size: 0.5,
|
|
98
|
+
topic: snap.anonymousUserId,
|
|
99
|
+
example: snap.activeSessionId,
|
|
100
|
+
demo: demoId,
|
|
101
|
+
exampleTopics: exampleTopics
|
|
102
|
+
});
|
|
103
|
+
}
|
|
60
104
|
}
|
|
61
105
|
export default TaskBox;
|
|
@@ -44,7 +44,9 @@ export var Toolbar = function Toolbar(_ref) {
|
|
|
44
44
|
onToggleFullscreen = _ref$onToggleFullscre === void 0 ? null : _ref$onToggleFullscre,
|
|
45
45
|
onExecuteCode = _ref.onExecuteCode,
|
|
46
46
|
onClickAI = _ref.onClickAI,
|
|
47
|
-
onReload = _ref.onReload
|
|
47
|
+
onReload = _ref.onReload,
|
|
48
|
+
_ref$showAI = _ref.showAI,
|
|
49
|
+
showAI = _ref$showAI === void 0 ? true : _ref$showAI;
|
|
48
50
|
var locale = useLocale();
|
|
49
51
|
var exampleTitle = _typeof(title) === 'object' ? title[locale.id] : title;
|
|
50
52
|
|
|
@@ -80,7 +82,7 @@ export var Toolbar = function Toolbar(_ref) {
|
|
|
80
82
|
return onEditorTabChange(tab);
|
|
81
83
|
}
|
|
82
84
|
}, tab, " ", slot && slot);
|
|
83
|
-
})), /*#__PURE__*/React.createElement("a", {
|
|
85
|
+
})), showAI ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("a", {
|
|
84
86
|
className: styles.ai,
|
|
85
87
|
onClick: onClickAI
|
|
86
88
|
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
@@ -92,7 +94,7 @@ export var Toolbar = function Toolbar(_ref) {
|
|
|
92
94
|
}, /*#__PURE__*/React.createElement("span", {
|
|
93
95
|
className: styles.ai,
|
|
94
96
|
onClick: onReload
|
|
95
|
-
}, /*#__PURE__*/React.createElement(ReloadOutlined, null))), riddleVisible ? /*#__PURE__*/React.createElement("form", {
|
|
97
|
+
}, /*#__PURE__*/React.createElement(ReloadOutlined, null)))) : null, riddleVisible ? /*#__PURE__*/React.createElement("form", {
|
|
96
98
|
action: "//riddle.alibaba-inc.com/riddles/define",
|
|
97
99
|
method: "POST",
|
|
98
100
|
target: "_blank"
|
|
@@ -57,7 +57,9 @@ var CodeEditor = function CodeEditor(_ref) {
|
|
|
57
57
|
_ref$onError = _ref.onError,
|
|
58
58
|
onError = _ref$onError === void 0 ? noop : _ref$onError,
|
|
59
59
|
_ref$onFullscreen = _ref.onFullscreen,
|
|
60
|
-
onFullscreen = _ref$onFullscreen === void 0 ? noop : _ref$onFullscreen
|
|
60
|
+
onFullscreen = _ref$onFullscreen === void 0 ? noop : _ref$onFullscreen,
|
|
61
|
+
_ref$showAI = _ref.showAI,
|
|
62
|
+
showAI = _ref$showAI === void 0 ? true : _ref$showAI;
|
|
61
63
|
var locale = useLocale();
|
|
62
64
|
var _useSiteData = useSiteData(),
|
|
63
65
|
themeConfig = _useSiteData.themeConfig;
|
|
@@ -104,8 +106,8 @@ var CodeEditor = function CodeEditor(_ref) {
|
|
|
104
106
|
setCurrentEditorTab = _useState12[1];
|
|
105
107
|
var _useState13 = useState(false),
|
|
106
108
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
107
|
-
|
|
108
|
-
|
|
109
|
+
showAIDrawer = _useState14[0],
|
|
110
|
+
setShowAIDrawer = _useState14[1];
|
|
109
111
|
var containerId = "playgroundScriptContainer_".concat(exampleId);
|
|
110
112
|
|
|
111
113
|
// 出发 auto resize
|
|
@@ -281,7 +283,7 @@ var CodeEditor = function CodeEditor(_ref) {
|
|
|
281
283
|
// 用于更新当前 example 的 spec 和 data
|
|
282
284
|
useEffect(function () {
|
|
283
285
|
setCurrentEditorTab(EDITOR_TABS.JAVASCRIPT);
|
|
284
|
-
|
|
286
|
+
setShowAIDrawer(false);
|
|
285
287
|
}, [exampleId]);
|
|
286
288
|
|
|
287
289
|
// hook 用户的数据
|
|
@@ -385,7 +387,7 @@ var CodeEditor = function CodeEditor(_ref) {
|
|
|
385
387
|
}
|
|
386
388
|
};
|
|
387
389
|
var onClickAI = function onClickAI() {
|
|
388
|
-
|
|
390
|
+
setShowAIDrawer(true);
|
|
389
391
|
};
|
|
390
392
|
var onReload = function onReload() {
|
|
391
393
|
setCode(source);
|
|
@@ -407,6 +409,7 @@ var CodeEditor = function CodeEditor(_ref) {
|
|
|
407
409
|
onEditorTabChange: onTabChange,
|
|
408
410
|
onToggleFullscreen: onFullscreen,
|
|
409
411
|
onClickAI: onClickAI,
|
|
412
|
+
showAI: showAI,
|
|
410
413
|
onReload: onReload,
|
|
411
414
|
slots: {
|
|
412
415
|
Spec: /*#__PURE__*/React.createElement("span", {
|
|
@@ -462,10 +465,10 @@ var CodeEditor = function CodeEditor(_ref) {
|
|
|
462
465
|
}), /*#__PURE__*/React.createElement(Drawer, {
|
|
463
466
|
placement: "right",
|
|
464
467
|
closable: true,
|
|
465
|
-
open:
|
|
468
|
+
open: showAIDrawer,
|
|
466
469
|
getContainer: false,
|
|
467
470
|
onClose: function onClose() {
|
|
468
|
-
return
|
|
471
|
+
return setShowAIDrawer(false);
|
|
469
472
|
},
|
|
470
473
|
rootClassName: styles.drawer,
|
|
471
474
|
width: '90%'
|
|
@@ -32,7 +32,9 @@ var CodeRunner = function CodeRunner(_ref) {
|
|
|
32
32
|
replaceId = _ref.replaceId,
|
|
33
33
|
isPlayground = _ref.isPlayground,
|
|
34
34
|
_ref$notFound = _ref.notFound,
|
|
35
|
-
notFound = _ref$notFound === void 0 ? /*#__PURE__*/React.createElement(NotFound, null) : _ref$notFound
|
|
35
|
+
notFound = _ref$notFound === void 0 ? /*#__PURE__*/React.createElement(NotFound, null) : _ref$notFound,
|
|
36
|
+
_ref$showAI = _ref.showAI,
|
|
37
|
+
showAI = _ref$showAI === void 0 ? true : _ref$showAI;
|
|
36
38
|
var demoInfo = getDemoInfo(exampleTopics, topic, example, demo);
|
|
37
39
|
|
|
38
40
|
// 找不到,啥也别干了,404 页面
|
|
@@ -80,7 +82,8 @@ var CodeRunner = function CodeRunner(_ref) {
|
|
|
80
82
|
onDestroy: noop,
|
|
81
83
|
onReady: noop,
|
|
82
84
|
playground: playground,
|
|
83
|
-
title: ic(title)
|
|
85
|
+
title: ic(title),
|
|
86
|
+
showAI: showAI
|
|
84
87
|
}))));
|
|
85
88
|
};
|
|
86
89
|
export default CodeRunner;
|
package/package.json
CHANGED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="100%" height="100%">
|
|
2
|
-
<g
|
|
3
|
-
fill="none"
|
|
4
|
-
stroke="currentColor"
|
|
5
|
-
stroke-width="65"
|
|
6
|
-
stroke-linecap="round"
|
|
7
|
-
stroke-linejoin="round"
|
|
8
|
-
>
|
|
9
|
-
<circle cx="448" cy="447" r="380" />
|
|
10
|
-
<line x1="715" y1="715" x2="900" y2="900" />
|
|
11
|
-
<path d="M 290 605 L 382 290 L 475 605 M 320 500 L 445 500" />
|
|
12
|
-
<line x1="600" y1="290" x2="600" y2="605" />
|
|
13
|
-
</g>
|
|
14
|
-
</svg>
|