@antv/dumi-theme-antv 0.7.10 → 0.8.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builtins/Playground/index.js +1 -1
- package/dist/common/styles/Common.js +1 -1
- package/dist/common/styles/theme.js +1 -1
- package/dist/components/AI/HomeDialog/AntVBanner/index.js +4 -0
- package/dist/components/AI/HomeDialog/AntVBanner/index.module.less +35 -0
- package/dist/components/AI/HomeDialog/ModeSelector/index.js +29 -0
- package/dist/components/AI/HomeDialog/ModeSelector/index.module.less +272 -0
- package/dist/components/AI/HomeDialog/PromptTextarea/ChooseLib/index.js +51 -0
- package/dist/components/AI/HomeDialog/PromptTextarea/ChooseLib/index.module.less +5 -0
- package/dist/components/AI/HomeDialog/PromptTextarea/DatasourceCard/index.js +25 -0
- package/dist/components/AI/HomeDialog/PromptTextarea/DatasourceCard/index.module.less +42 -0
- package/dist/components/AI/HomeDialog/PromptTextarea/SendButton.js +23 -0
- package/dist/components/AI/HomeDialog/PromptTextarea/SendButton.module.less +9 -0
- package/dist/components/AI/HomeDialog/PromptTextarea/index.js +139 -0
- package/dist/components/AI/HomeDialog/PromptTextarea/index.module.less +127 -0
- package/dist/components/AI/HomeDialog/RecommendCase/Card.js +70 -0
- package/dist/components/AI/HomeDialog/RecommendCase/card.module.less +131 -0
- package/dist/components/AI/HomeDialog/RecommendCase/index.js +76 -0
- package/dist/components/AI/HomeDialog/RecommendCase/index.module.less +43 -0
- package/dist/components/AI/HomeDialog/RecommendCase/recommend.json +42 -0
- package/dist/components/AI/HomeDialog/index.js +66 -0
- package/dist/components/AI/HomeDialog/index.module.less +3 -0
- package/dist/components/AI/constant.js +35 -0
- package/dist/components/AI/index.js +1 -0
- package/dist/components/AI/types.js +1 -0
- package/dist/components/AI/utils.js +38 -0
- package/dist/hooks/useProducts.js +18 -0
- package/dist/hooks/useStreamingText.js +139 -0
- package/dist/hooks/useTypewriter.js +69 -0
- package/dist/hooks/useVisionsnapSdk.js +159 -0
- package/dist/layouts/DocLayout.js +0 -1
- package/dist/layouts/GlobalLayout/index.js +15 -0
- package/dist/model/AIChat.js +224 -0
- package/dist/pages/AIPlayground/components/ConversationsMenu/index.js +149 -0
- package/dist/pages/AIPlayground/components/ConversationsMenu/index.module.less +44 -0
- package/dist/pages/AIPlayground/components/MarkdownComponent/MarkdownCodeBlock.js +78 -0
- package/dist/pages/AIPlayground/components/MarkdownComponent/MarkdownCodeBlock.module.less +14 -0
- package/dist/pages/AIPlayground/components/MarkdownComponent/index.js +47 -0
- package/dist/pages/AIPlayground/components/MsgBox/index.js +269 -0
- package/dist/pages/AIPlayground/components/MsgBox/index.module.less +42 -0
- package/dist/pages/AIPlayground/components/SessionLayout/index.js +25 -0
- package/dist/pages/AIPlayground/components/SessionLayout/index.module.less +34 -0
- package/dist/pages/AIPlayground/components/TaskBox/generateCode.js +109 -0
- package/dist/pages/AIPlayground/components/TaskBox/index.js +61 -0
- package/dist/pages/AIPlayground/components/TaskBox/index.module.less +8 -0
- package/dist/pages/AIPlayground/demo.js +34 -0
- package/dist/pages/AIPlayground/index.js +9 -0
- package/dist/pages/AIPlayground/index.module.less +0 -0
- package/dist/pages/Index/index.js +1 -1
- package/dist/plugin/index.js +14 -6
- package/dist/slots/CodeEditor/Toolbar.js +13 -3
- package/dist/slots/CodeEditor/Toolbar.module.less +7 -0
- package/dist/slots/CodeEditor/index.js +39 -2
- package/dist/slots/CodeEditor/index.module.less +22 -0
- package/dist/slots/CodeRunner/index.js +2 -1
- package/dist/{pages/Index/components → slots}/Detail/News.js +1 -1
- package/dist/{pages/Index/components → slots}/Detail/index.js +11 -28
- package/dist/{pages/Index/components → slots}/Detail/index.module.less +12 -6
- package/dist/slots/Header/Products/getProducts.js +20 -26
- package/dist/slots/Header/Products/index.js +20 -16
- package/dist/slots/Header/Search/SearchResult.js +36 -14
- package/dist/slots/Header/Search/index.js +2 -1
- package/dist/slots/Header/index.module.less +1 -1
- package/dist/typings.d.ts +5 -0
- package/dist/utils/code.js +35 -0
- package/package.json +23 -4
- /package/dist/{pages/Index/components → slots}/Detail/News.module.less +0 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
4
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
+
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."); }
|
|
7
|
+
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); }
|
|
8
|
+
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; }
|
|
9
|
+
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; } }
|
|
10
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
+
import { CheckOutlined, CopyOutlined, DislikeOutlined, LikeOutlined, PlusSquareOutlined, SyncOutlined } from '@ant-design/icons';
|
|
12
|
+
import { Bubble } from '@ant-design/x';
|
|
13
|
+
import { Button, Flex, Space, Tooltip } from 'antd';
|
|
14
|
+
import { history, useSiteData } from 'dumi';
|
|
15
|
+
import { findLast } from 'lodash-es';
|
|
16
|
+
import React, { useEffect, useState } from 'react';
|
|
17
|
+
import { useCopyToClipboard } from 'react-use';
|
|
18
|
+
import { useSnapshot } from 'valtio';
|
|
19
|
+
import { PromptTextarea } from "../../../../components/AI/HomeDialog/PromptTextarea";
|
|
20
|
+
import { useStreamingText } from "../../../../hooks/useStreamingText";
|
|
21
|
+
import { AIChatStore, clearEmptySession, createPureNewSession, derivedState } from "../../../../model/AIChat";
|
|
22
|
+
import { getCodeFromMarkdown, isPreviewable } from "../../../../utils/code";
|
|
23
|
+
import { MarkdownComponent } from "../MarkdownComponent";
|
|
24
|
+
import styles from "./index.module.less";
|
|
25
|
+
var avatar = {
|
|
26
|
+
icon: /*#__PURE__*/React.createElement("img", {
|
|
27
|
+
draggable: false,
|
|
28
|
+
src: 'https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*7svFR6wkPMoAAAAAAAAAAAAADmJ7AQ/original',
|
|
29
|
+
alt: "AntV"
|
|
30
|
+
}),
|
|
31
|
+
style: {
|
|
32
|
+
borderRadius: 0,
|
|
33
|
+
backgroundColor: 'transparent'
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var chatScrollIntoView = function chatScrollIntoView() {
|
|
37
|
+
setTimeout(function () {
|
|
38
|
+
var nodeList = document.querySelectorAll('.ant-bubble');
|
|
39
|
+
nodeList[nodeList.length - 1].scrollIntoView({
|
|
40
|
+
behavior: 'smooth'
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
function MsgBox(props) {
|
|
45
|
+
var _derivedSnap$activeSe, _derivedSnap$activeSe2, _derivedSnap$activeSe3;
|
|
46
|
+
var _props$messages = props.messages,
|
|
47
|
+
messages = _props$messages === void 0 ? [] : _props$messages,
|
|
48
|
+
_props$simple = props.simple,
|
|
49
|
+
simple = _props$simple === void 0 ? false : _props$simple,
|
|
50
|
+
_props$context = props.context,
|
|
51
|
+
context = _props$context === void 0 ? '' : _props$context,
|
|
52
|
+
onCodegen = props.onCodegen,
|
|
53
|
+
title = props.title;
|
|
54
|
+
var _useSiteData = useSiteData(),
|
|
55
|
+
themeConfig = _useSiteData.themeConfig;
|
|
56
|
+
var _useState = useState(!themeConfig.isAntVSite ? themeConfig.title : undefined),
|
|
57
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
58
|
+
lib = _useState2[0],
|
|
59
|
+
setLib = _useState2[1];
|
|
60
|
+
var _useState3 = useState(''),
|
|
61
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
62
|
+
promptText = _useState4[0],
|
|
63
|
+
setPromptText = _useState4[1];
|
|
64
|
+
var _useState5 = useState(false),
|
|
65
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
66
|
+
isStreaming = _useState6[0],
|
|
67
|
+
setIsStreaming = _useState6[1]; // trigger
|
|
68
|
+
var _useState7 = useState(false),
|
|
69
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
70
|
+
loading = _useState8[0],
|
|
71
|
+
setLoading = _useState8[1];
|
|
72
|
+
var snap = useSnapshot(AIChatStore);
|
|
73
|
+
var derivedSnap = useSnapshot(derivedState);
|
|
74
|
+
var _useCopyToClipboard = useCopyToClipboard(),
|
|
75
|
+
_useCopyToClipboard2 = _slicedToArray(_useCopyToClipboard, 2),
|
|
76
|
+
copyState = _useCopyToClipboard2[0],
|
|
77
|
+
copyToClipboard = _useCopyToClipboard2[1];
|
|
78
|
+
var latestUserMessage = findLast((_derivedSnap$activeSe = derivedSnap.activeSession) === null || _derivedSnap$activeSe === void 0 ? void 0 : _derivedSnap$activeSe.messages, function (msg) {
|
|
79
|
+
return msg.role === 'user';
|
|
80
|
+
});
|
|
81
|
+
var streamingText = useStreamingText({
|
|
82
|
+
url: 'https://webgw-pre.alipay.com/visqaservice/external/chat',
|
|
83
|
+
method: 'POST',
|
|
84
|
+
body: {
|
|
85
|
+
gptConversationId: (_derivedSnap$activeSe2 = derivedSnap.activeSession) === null || _derivedSnap$activeSe2 === void 0 ? void 0 : _derivedSnap$activeSe2.id,
|
|
86
|
+
query: latestUserMessage === null || latestUserMessage === void 0 ? void 0 : latestUserMessage.content,
|
|
87
|
+
library: (latestUserMessage === null || latestUserMessage === void 0 ? void 0 : latestUserMessage.lib) || lib,
|
|
88
|
+
mode: latestUserMessage === null || latestUserMessage === void 0 ? void 0 : latestUserMessage.mode,
|
|
89
|
+
anonymousUserId: snap.anonymousUserId,
|
|
90
|
+
context: (latestUserMessage === null || latestUserMessage === void 0 ? void 0 : latestUserMessage.context) || context,
|
|
91
|
+
mountId: "container"
|
|
92
|
+
},
|
|
93
|
+
trigger: isStreaming,
|
|
94
|
+
// 将 isStreaming 状态作为 trigger
|
|
95
|
+
headers: {
|
|
96
|
+
'Content-Type': 'application/json',
|
|
97
|
+
'x-webgw-version': '2.0',
|
|
98
|
+
'x-webgw-appid': '180020010001210065'
|
|
99
|
+
},
|
|
100
|
+
beforeStart: function beforeStart() {
|
|
101
|
+
setLoading(true);
|
|
102
|
+
},
|
|
103
|
+
onFinish: function onFinish(finalText) {
|
|
104
|
+
try {
|
|
105
|
+
var _derivedState$activeS;
|
|
106
|
+
var finalJSON = JSON.parse(finalText);
|
|
107
|
+
(_derivedState$activeS = derivedState.activeSession) === null || _derivedState$activeS === void 0 || (_derivedState$activeS = _derivedState$activeS.messages) === null || _derivedState$activeS === void 0 || _derivedState$activeS.push({
|
|
108
|
+
id: crypto.randomUUID(),
|
|
109
|
+
role: 'assistant',
|
|
110
|
+
content: finalJSON.content,
|
|
111
|
+
createdAt: Date.now()
|
|
112
|
+
// mode,
|
|
113
|
+
// lib,
|
|
114
|
+
});
|
|
115
|
+
if (isPreviewable(finalJSON.content)) {
|
|
116
|
+
var codeBlock = getCodeFromMarkdown(finalJSON.content).code;
|
|
117
|
+
AIChatStore.codeBlock = codeBlock;
|
|
118
|
+
onCodegen === null || onCodegen === void 0 || onCodegen(codeBlock);
|
|
119
|
+
}
|
|
120
|
+
} catch (e) {
|
|
121
|
+
// 说明不是JSON格式
|
|
122
|
+
} finally {
|
|
123
|
+
// 当流结束时,更新最后一条消息并重置 trigger
|
|
124
|
+
setIsStreaming(false); // **关键:流结束后,关闭 trigger**
|
|
125
|
+
setLoading(false);
|
|
126
|
+
chatScrollIntoView();
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
onError: function onError(error) {
|
|
130
|
+
var _derivedState$activeS2;
|
|
131
|
+
console.log('回答失败', error);
|
|
132
|
+
// 处理错误
|
|
133
|
+
(_derivedState$activeS2 = derivedState.activeSession) === null || _derivedState$activeS2 === void 0 || (_derivedState$activeS2 = _derivedState$activeS2.messages) === null || _derivedState$activeS2 === void 0 || _derivedState$activeS2.push({
|
|
134
|
+
id: crypto.randomUUID(),
|
|
135
|
+
role: 'assistant',
|
|
136
|
+
content: "\u62B1\u6B49\uFF0C\u6211\u6CA1\u80FD\u6210\u529F\u5904\u7406\u60A8\u7684\u8BF7\u6C42\uFF0C\u8BF7\u7A0D\u540E\u518D\u6B21\u63D0\u95EE",
|
|
137
|
+
createdAt: Date.now()
|
|
138
|
+
// mode,
|
|
139
|
+
// lib,
|
|
140
|
+
});
|
|
141
|
+
setIsStreaming(false);
|
|
142
|
+
setLoading(false);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// 3. 处理用户提交
|
|
147
|
+
var handleSubmit = function handleSubmit() {
|
|
148
|
+
var _derivedState$activeS3;
|
|
149
|
+
if (!promptText.trim() || isStreaming) return; // 如果正在流式输出,则不允许发送
|
|
150
|
+
setPromptText('');
|
|
151
|
+
(_derivedState$activeS3 = derivedState.activeSession) === null || _derivedState$activeS3 === void 0 || (_derivedState$activeS3 = _derivedState$activeS3.messages) === null || _derivedState$activeS3 === void 0 || _derivedState$activeS3.push({
|
|
152
|
+
id: crypto.randomUUID(),
|
|
153
|
+
role: 'user',
|
|
154
|
+
content: promptText,
|
|
155
|
+
createdAt: Date.now(),
|
|
156
|
+
lib: lib
|
|
157
|
+
});
|
|
158
|
+
// **关键:开启 trigger,开始请求**
|
|
159
|
+
setIsStreaming(true);
|
|
160
|
+
chatScrollIntoView();
|
|
161
|
+
};
|
|
162
|
+
useEffect(function () {
|
|
163
|
+
// 检查是否存在临时消息
|
|
164
|
+
if (snap.tempMessage) {
|
|
165
|
+
var activeSession = derivedState.activeSession;
|
|
166
|
+
if (activeSession) {
|
|
167
|
+
// 1. 将临时消息正式添加到当前会话中
|
|
168
|
+
activeSession.messages.push(snap.tempMessage);
|
|
169
|
+
setIsStreaming(true);
|
|
170
|
+
AIChatStore.tempMessage = null;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (simple) {
|
|
174
|
+
createPureNewSession(title);
|
|
175
|
+
}
|
|
176
|
+
return function () {
|
|
177
|
+
clearEmptySession();
|
|
178
|
+
};
|
|
179
|
+
}, []);
|
|
180
|
+
useEffect(function () {
|
|
181
|
+
if (derivedState.activeSession && Date.now() - derivedState.activeSession.createdAt > 5000) {
|
|
182
|
+
setLoading(false);
|
|
183
|
+
setIsStreaming(false);
|
|
184
|
+
}
|
|
185
|
+
}, [snap.activeSessionId]);
|
|
186
|
+
var showMessages = [].concat(_toConsumableArray(messages), _toConsumableArray((_derivedSnap$activeSe3 = derivedSnap.activeSession) === null || _derivedSnap$activeSe3 === void 0 ? void 0 : _derivedSnap$activeSe3.messages));
|
|
187
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Flex, {
|
|
188
|
+
gap: "middle",
|
|
189
|
+
vertical: true,
|
|
190
|
+
className: styles.chatContainer
|
|
191
|
+
}, showMessages === null || showMessages === void 0 ? void 0 : showMessages.map(function (msg, index) {
|
|
192
|
+
return /*#__PURE__*/React.createElement(Bubble, {
|
|
193
|
+
key: index,
|
|
194
|
+
content: /*#__PURE__*/React.createElement(MarkdownComponent, {
|
|
195
|
+
content: msg.content
|
|
196
|
+
}),
|
|
197
|
+
avatar: msg.role === 'assistant' ? avatar : null,
|
|
198
|
+
footer: msg.role === 'assistant' && index > 0 ? /*#__PURE__*/React.createElement(Space, {
|
|
199
|
+
size: "small"
|
|
200
|
+
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
201
|
+
title: "\u70B9\u8D5E"
|
|
202
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
203
|
+
color: "default",
|
|
204
|
+
variant: "text",
|
|
205
|
+
size: "small",
|
|
206
|
+
icon: /*#__PURE__*/React.createElement(LikeOutlined, null)
|
|
207
|
+
})), /*#__PURE__*/React.createElement(Tooltip, {
|
|
208
|
+
title: "\u70B9\u8E29"
|
|
209
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
210
|
+
color: "default",
|
|
211
|
+
variant: "text",
|
|
212
|
+
size: "small",
|
|
213
|
+
icon: /*#__PURE__*/React.createElement(DislikeOutlined, null)
|
|
214
|
+
})), index === showMessages.length - 1 && /*#__PURE__*/React.createElement(Tooltip, {
|
|
215
|
+
title: "\u518D\u6765\u4E00\u6B21"
|
|
216
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
217
|
+
onClick: function onClick() {
|
|
218
|
+
derivedState.activeSession.messages.pop();
|
|
219
|
+
setIsStreaming(true);
|
|
220
|
+
},
|
|
221
|
+
color: "default",
|
|
222
|
+
variant: "text",
|
|
223
|
+
size: "small",
|
|
224
|
+
icon: /*#__PURE__*/React.createElement(SyncOutlined, null)
|
|
225
|
+
})), /*#__PURE__*/React.createElement(Tooltip, {
|
|
226
|
+
title: "\u590D\u5236"
|
|
227
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
228
|
+
color: "default",
|
|
229
|
+
variant: "text",
|
|
230
|
+
size: "small",
|
|
231
|
+
onClick: function onClick() {
|
|
232
|
+
return copyToClipboard(msg.content);
|
|
233
|
+
},
|
|
234
|
+
icon: copyState.value === msg.content ? /*#__PURE__*/React.createElement(CheckOutlined, null) : /*#__PURE__*/React.createElement(CopyOutlined, null)
|
|
235
|
+
}))) : null,
|
|
236
|
+
placement: msg.role === 'user' ? 'end' : 'start'
|
|
237
|
+
});
|
|
238
|
+
}), loading && /*#__PURE__*/React.createElement(Bubble, {
|
|
239
|
+
placement: "start",
|
|
240
|
+
avatar: avatar,
|
|
241
|
+
loading: loading
|
|
242
|
+
})), /*#__PURE__*/React.createElement("div", null, !props.simple && /*#__PURE__*/React.createElement("div", {
|
|
243
|
+
className: styles.newButtonContainer
|
|
244
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
245
|
+
type: "button",
|
|
246
|
+
onClick: function onClick() {
|
|
247
|
+
return history.push('/');
|
|
248
|
+
},
|
|
249
|
+
className: styles.newButton
|
|
250
|
+
}, /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(PlusSquareOutlined, null), "\u5F00\u59CB\u65B0\u5BF9\u8BDD"))), /*#__PURE__*/React.createElement(PromptTextarea, {
|
|
251
|
+
size: "compact",
|
|
252
|
+
mode: "implement",
|
|
253
|
+
value: promptText,
|
|
254
|
+
onChange: setPromptText,
|
|
255
|
+
loading: loading,
|
|
256
|
+
onCancel: function onCancel() {
|
|
257
|
+
setIsStreaming(false);
|
|
258
|
+
setLoading(false);
|
|
259
|
+
},
|
|
260
|
+
showAction: !props.simple,
|
|
261
|
+
style: {
|
|
262
|
+
marginBottom: 0
|
|
263
|
+
},
|
|
264
|
+
onConfirm: handleSubmit,
|
|
265
|
+
lib: lib,
|
|
266
|
+
onLibChange: setLib
|
|
267
|
+
})));
|
|
268
|
+
}
|
|
269
|
+
export default MsgBox;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
.msg {
|
|
2
|
+
display: flex;
|
|
3
|
+
justify-content: flex-end;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.query {
|
|
7
|
+
background: #c9dfff;
|
|
8
|
+
box-shadow: 0 4px 10px rgba(51, 113, 242, .1);
|
|
9
|
+
border-radius: 8px;
|
|
10
|
+
padding: 8px 16px;
|
|
11
|
+
max-width: calc(100% - 100px);
|
|
12
|
+
word-break: break-all;
|
|
13
|
+
font-size: 14px;
|
|
14
|
+
line-height: 26px;
|
|
15
|
+
font-weight: 400;
|
|
16
|
+
color: #1d2129;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.newButton {
|
|
20
|
+
display: inline-flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
border: none;
|
|
24
|
+
outline: none;
|
|
25
|
+
height: 30px;
|
|
26
|
+
padding: 0 8px;
|
|
27
|
+
color: var(--primary-color);
|
|
28
|
+
font-size: 14px;
|
|
29
|
+
background: rgba(135, 59, 244, .145);
|
|
30
|
+
border-radius: 6px;
|
|
31
|
+
line-height: 22px;
|
|
32
|
+
margin: 12px auto;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.newButtonContainer {
|
|
36
|
+
display: flex;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.chatContainer {
|
|
40
|
+
height: 100%;
|
|
41
|
+
overflow: auto;
|
|
42
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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); }
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import styles from "./index.module.less";
|
|
7
|
+
import { ConversationsMenu } from "../ConversationsMenu";
|
|
8
|
+
import { AIChatStore } from "../../../../model/AIChat";
|
|
9
|
+
import { useSnapshot } from "valtio";
|
|
10
|
+
import classnames from "classnames";
|
|
11
|
+
function SessionLayout(props) {
|
|
12
|
+
var children = props.children;
|
|
13
|
+
var snap = useSnapshot(AIChatStore);
|
|
14
|
+
if (!Array.isArray(children)) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
18
|
+
className: styles.container
|
|
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", {
|
|
22
|
+
className: styles.taskBox
|
|
23
|
+
}, children[1]));
|
|
24
|
+
}
|
|
25
|
+
export { SessionLayout };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
display: flex;
|
|
3
|
+
gap: 12px;
|
|
4
|
+
background: #f6f7fb;
|
|
5
|
+
height: calc(100vh - 64px);
|
|
6
|
+
padding: 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.msgBox, .taskBox{
|
|
10
|
+
box-shadow: 0 2px 7px #e0e0e080;
|
|
11
|
+
border-radius: 12px;
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.msgBox {
|
|
17
|
+
padding: 16px;
|
|
18
|
+
min-width: 400px;
|
|
19
|
+
justify-content: space-between;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.msgBoxHalf {
|
|
23
|
+
max-width: 30vw;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.msgBoxFull {
|
|
27
|
+
width: 100%;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.taskBox {
|
|
31
|
+
margin: 16px;
|
|
32
|
+
flex-grow: 1;
|
|
33
|
+
background: #ffffff;
|
|
34
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2
|
+
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); }
|
|
3
|
+
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; }
|
|
4
|
+
/**
|
|
5
|
+
* 从代码字符串中提取依赖,并生成 package.json 的 dependencies 对象。
|
|
6
|
+
*
|
|
7
|
+
* @param {string} codeString 包含代码的字符串。
|
|
8
|
+
* @returns {object} 一个符合 package.json dependencies 格式的对象。
|
|
9
|
+
*/
|
|
10
|
+
export function generateDependencies(codeString) {
|
|
11
|
+
// 1. 初始化固定的依赖
|
|
12
|
+
var dependencies = {};
|
|
13
|
+
|
|
14
|
+
// 2. 定义正则表达式来匹配 import 语句的来源
|
|
15
|
+
// 这个正则表达式可以处理以下情况:
|
|
16
|
+
// - import defaultExport from 'package-name';
|
|
17
|
+
// - import { namedExport } from 'package-name';
|
|
18
|
+
// - import * as name from 'package-name';
|
|
19
|
+
// - import 'package-name'; (用于副作用)
|
|
20
|
+
// - import defaultExport from '@scoped/package-name/sub-path';
|
|
21
|
+
//
|
|
22
|
+
// 解析:
|
|
23
|
+
// - `import(?:.*from)?` : 匹配 "import" 关键字,以及可选的 "... from" 部分。
|
|
24
|
+
// - `\s+` : 匹配一个或多个空格。
|
|
25
|
+
// - `['"]` : 匹配单引号或双引号。
|
|
26
|
+
// - `([^'"]+)` : 核心捕获组。匹配引号内的所有字符,这就是我们需要的包路径。
|
|
27
|
+
// - `['"]` : 匹配结束的引号。
|
|
28
|
+
// - `/g` : 全局匹配,查找所有符合条件的导入。
|
|
29
|
+
var importRegex = /import(?:.*from)?\s+['"]([^'"]+)['"]/g;
|
|
30
|
+
|
|
31
|
+
// 使用 Set 来存储找到的包,可以自动去重
|
|
32
|
+
var foundPackages = new Set();
|
|
33
|
+
|
|
34
|
+
// 3. 遍历所有匹配项
|
|
35
|
+
var match;
|
|
36
|
+
while ((match = importRegex.exec(codeString)) !== null) {
|
|
37
|
+
// 捕获组 match[1] 包含了完整的导入路径,例如 '@antv/g2' 或 'react-dom/client'
|
|
38
|
+
var importPath = match[1];
|
|
39
|
+
|
|
40
|
+
// 4. 过滤掉相对路径和绝对路径
|
|
41
|
+
if (importPath.startsWith('.') || importPath.startsWith('/')) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 5. 提取根包名
|
|
46
|
+
// 这可以处理像 'react-dom/client' 这样的深层导入,我们只需要 'react-dom'
|
|
47
|
+
// 或者像 '@antv/g2/es/chart',我们只需要 '@antv/g2'
|
|
48
|
+
var rootPackage = void 0;
|
|
49
|
+
var pathParts = importPath.split('/');
|
|
50
|
+
if (importPath.startsWith('@')) {
|
|
51
|
+
// 对于作用域包 (scoped package),例如 @antv/g2,根包名是前两部分
|
|
52
|
+
rootPackage = "".concat(pathParts[0], "/").concat(pathParts[1]);
|
|
53
|
+
} else {
|
|
54
|
+
// 对于普通包,根包名是第一部分
|
|
55
|
+
rootPackage = pathParts[0];
|
|
56
|
+
}
|
|
57
|
+
foundPackages.add(rootPackage);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 6. 将找到的包添加到最终的依赖对象中
|
|
61
|
+
var _iterator = _createForOfIteratorHelper(foundPackages),
|
|
62
|
+
_step;
|
|
63
|
+
try {
|
|
64
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
65
|
+
var pkg = _step.value;
|
|
66
|
+
// 如果不是固定的依赖,就添加并设置为 'latest'
|
|
67
|
+
if (!Object.prototype.hasOwnProperty.call(dependencies, pkg)) {
|
|
68
|
+
dependencies[pkg] = "latest";
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
} catch (err) {
|
|
72
|
+
_iterator.e(err);
|
|
73
|
+
} finally {
|
|
74
|
+
_iterator.f();
|
|
75
|
+
}
|
|
76
|
+
return dependencies;
|
|
77
|
+
}
|
|
78
|
+
export function wrap2VisionSnap() {
|
|
79
|
+
var codeBlock = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
80
|
+
return {
|
|
81
|
+
modules: {
|
|
82
|
+
'/package.json': {
|
|
83
|
+
fpath: '/package.json',
|
|
84
|
+
code: "{\n \"name\": \"AntV-master\",\n \"version\": \"1.0.0\",\n \"main\": \"/src/index.jsx\",\n \"dependencies\": ".concat(JSON.stringify(generateDependencies(codeBlock), null, 2), "\n}")
|
|
85
|
+
},
|
|
86
|
+
'/src/index.jsx': {
|
|
87
|
+
fpath: '/src/index.jsx',
|
|
88
|
+
code: codeBlock
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
export function wrap2Sandpack() {
|
|
94
|
+
var codeBlock = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
95
|
+
// const regex = /^```[\w-]*\n([\s\S]*?)\n?```$/m;
|
|
96
|
+
// const match = codeBlock.match(regex);
|
|
97
|
+
// if (match) {
|
|
98
|
+
return {
|
|
99
|
+
"/package.json": {
|
|
100
|
+
code: "{\n \"name\": \"AntV-AI-Code\",\n \"version\": \"1.0.0\",\n \"main\": \"/index.tsx\",\n \"dependencies\": ".concat(JSON.stringify(generateDependencies(codeBlock), null, 2), "\n }")
|
|
101
|
+
},
|
|
102
|
+
"/index.tsx": {
|
|
103
|
+
code: codeBlock
|
|
104
|
+
},
|
|
105
|
+
"/index.html": {
|
|
106
|
+
code: "<!DOCTYPE html>\n<html>\n<head>\n <title>Vanilla JS Example</title>\n</head>\n<body>\n <div id=\"root\"></div>\n <div id=\"container\"></div>\n <script src=\"index.tsx\"></script>\n</body>\n</html>"
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Sandpack } from "@codesandbox/sandpack-react";
|
|
3
|
+
import styles from "./index.module.less";
|
|
4
|
+
import { AIChatStore } from "../../../../model/AIChat";
|
|
5
|
+
import { useSnapshot } from "valtio";
|
|
6
|
+
import { wrap2Sandpack } from "./generateCode";
|
|
7
|
+
// import {code} from "../../demo";
|
|
8
|
+
// import {requestProxy, useVisionsnapSdk} from "../../../../hooks/useVisionsnapSdk";
|
|
9
|
+
|
|
10
|
+
function TaskBox() {
|
|
11
|
+
var snap = useSnapshot(AIChatStore);
|
|
12
|
+
|
|
13
|
+
// const { sdk, loading } = useVisionsnapSdk('3.2.4');
|
|
14
|
+
//
|
|
15
|
+
// if (loading) {
|
|
16
|
+
// return <div>Loading...</div>;
|
|
17
|
+
// }
|
|
18
|
+
//
|
|
19
|
+
// return (
|
|
20
|
+
// <sdk.VisionPreview id="visionIframe"
|
|
21
|
+
// bizCode="vision-preview-demo"
|
|
22
|
+
// style={{ height: '100vh' }}
|
|
23
|
+
// userId="263347"
|
|
24
|
+
// displayMode="preview-only"
|
|
25
|
+
// editable={false}
|
|
26
|
+
// code={code}
|
|
27
|
+
// // requestProxy={requestProxy}
|
|
28
|
+
// isStreaming={false} />
|
|
29
|
+
// );
|
|
30
|
+
|
|
31
|
+
return /*#__PURE__*/React.createElement(Sandpack, {
|
|
32
|
+
template: "vanilla" // 指定项目模板,Sandpack 会据此配置环境
|
|
33
|
+
,
|
|
34
|
+
files: wrap2Sandpack(snap.codeBlock),
|
|
35
|
+
options: {
|
|
36
|
+
showLineNumbers: true,
|
|
37
|
+
// 显示行号
|
|
38
|
+
showTabs: true,
|
|
39
|
+
closableTabs: false,
|
|
40
|
+
editorHeight: 'calc(100vh - 150px)',
|
|
41
|
+
rtl: true,
|
|
42
|
+
classes: {
|
|
43
|
+
'sp-layout': styles['antv-sp-layout']
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
theme: "light" // 主题:dark, light, auto
|
|
47
|
+
,
|
|
48
|
+
customSetup: {
|
|
49
|
+
entry: "/index.tsx",
|
|
50
|
+
npmRegistries: [{
|
|
51
|
+
limitToScopes: false,
|
|
52
|
+
// 设为 false 使所有包都从自定义 registry 获取
|
|
53
|
+
registryUrl: 'https://registry.npmmirror.com',
|
|
54
|
+
// 使用淘宝镜像
|
|
55
|
+
enabledScopes: [],
|
|
56
|
+
proxyEnabled: false
|
|
57
|
+
}]
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
export default TaskBox;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export var projectFiles = {
|
|
2
|
+
"/package.json": {
|
|
3
|
+
code: "{\n \"name\": \"antv-g2-example\",\n \"version\": \"1.0.0\",\n \"main\": \"/index.js\",\n \"dependencies\": {\n \"@antv/g2\": \"^5\"\n }\n }"
|
|
4
|
+
},
|
|
5
|
+
"/index.js": {
|
|
6
|
+
// 入口文件是纯 JS
|
|
7
|
+
code: "import { Chart } from '@antv/g2';\n\n const chart = new Chart({\n container: 'root',\n });\n\n chart.options({\n type: 'interval',\n autoFit: true,\n data: [\n { grade: '\u4E00\u5E74\u7EA7', count: 200 },\n { grade: '\u4E8C\u5E74\u7EA7', count: 250 },\n { grade: '\u4E09\u5E74\u7EA7', count: 300 },\n { grade: '\u56DB\u5E74\u7EA7', count: 350 },\n ],\n encode: { x: 'grade', y: 'count' },\n });\n\n chart.render();\n "
|
|
8
|
+
},
|
|
9
|
+
"/index.html": {
|
|
10
|
+
code: "<!DOCTYPE html>\n<html>\n<head>\n <title>Vanilla JS Example</title>\n</head>\n<body>\n <div id=\"root\"></div>\n <div id=\"container\"></div>\n <script src=\"index.js\"></script>\n</body>\n</html>"
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export var code = {
|
|
14
|
+
modules: {
|
|
15
|
+
// package.json 文件是必须要的,其中 name, version, main, dependencies 必填
|
|
16
|
+
'/package.json': {
|
|
17
|
+
fpath: '/package.json',
|
|
18
|
+
code: "{\n \"name\": \"dark-card-app\",\n \"version\": \"1.0.0\",\n \"private\": true,\n \"dependencies\": {\n \"@ant-design/icons\": \"^5.2.6\",\n \"@alipay/bigfish\": \"^4.3.0\"\n },\n\"main\": \"src/index.jsx\"\n}\n"
|
|
19
|
+
},
|
|
20
|
+
// 入口文件默认是 /src/index.tsx,也可以配合 package.json main 字段指定其他入口
|
|
21
|
+
'/src/index.jsx': {
|
|
22
|
+
fpath: '/src/index.jsx',
|
|
23
|
+
code: "import React from '@alipay/bigfish/react';\n import ReactDOM from '@alipay/bigfish/react-dom';\nimport { ConfigProvider, theme } from '@alipay/bigfish/antd';\nimport App from './App';\nReactDOM.createRoot(document.getElementById('root')).render(\n <React.StrictMode>\n <ConfigProvider\n theme={{\n algorithm: theme.darkAlgorithm,\n token: {\n colorBgContainer: '#141414',\n colorBorderSecondary: '#303030',\n }\n }}\n >\n <App />\n </ConfigProvider>\n </React.StrictMode>\n);\n"
|
|
24
|
+
},
|
|
25
|
+
'/src/App.jsx': {
|
|
26
|
+
fpath: '/src/App.jsx',
|
|
27
|
+
code: "import React from '@alipay/bigfish/react';\nimport { Card, Avatar, Typography, Space } from '@alipay/bigfish/antd';\nimport { UserOutlined, ClockCircleOutlined, HeartOutlined, MessageOutlined } from '@ant-design/icons';\nimport './App.less';\nimport {styled} from '@alipay/bigfish';\nconst Title = styled.div`\n color: palevioletred;\n`;\n\nconst { Text } = Typography;\n\nconst DarkCard = () => {\n return (\n <div className=\"dark-card-container\">\n <Card\n className=\"dark-card\"\n cover={\n <div className=\"card-cover\">\n <div className=\"cover-image-placeholder\" />\n </div>\n }\n actions={[\n <Space key=\"time\">\n <ClockCircleOutlined />\n <Text className=\"action-text\">2 hours ago</Text>\n </Space>,\n <Space key=\"likes\">\n <HeartOutlined />\n <Text className=\"action-text\">128</Text>\n </Space>,\n <Space key=\"comments\">\n <MessageOutlined />\n <Text className=\"action-text\">24</Text>\n </Space>\n ]}\n >\n <Card.Meta\n avatar={<Avatar size={40} icon={<UserOutlined />} />}\n title={<Title>Dark Theme Card</Title>}\n description={\n <Text className=\"card-description\">\n This is a dark themed card with modern design elements.\n Perfect for displaying content in low-light interfaces.\n </Text>\n }\n />\n </Card>\n </div>\n );\n};\n\nexport default DarkCard;\n"
|
|
28
|
+
},
|
|
29
|
+
'/src/App.less': {
|
|
30
|
+
fpath: '/src/App.less',
|
|
31
|
+
code: ".dark-card-container {\n display: flex;\n justify-content: center;\n align-items: center;\n min-height: 100vh;\n background-color: #0a0a0a;\n padding: 20px;\n}\n\n.dark-card {\n width: 100%;\n max-width: 400px;\n border-radius: 12px;\n overflow: hidden;\n box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);\n\n .ant-card-head {\n border-bottom: 1px solid #303030;\n }\n\n .ant-card-actions {\n background: #1a1a1a;\n border-top: 1px solid #303030;\n\n > li {\n border-right: 1px solid #303030 !important;\n }\n }\n}\n\n.card-cover {\n height: 200px;\n background: linear-gradient(135deg, #2c2c2c, #1a1a1a);\n position: relative;\n overflow: hidden;\n\n .cover-image-placeholder {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background:\n radial-gradient(circle at center, #3a3a3a 0%, #1f1f1f 100%);\n }\n}\n\n.card-description {\n color: rgba(255, 255, 255, 0.65) !important;\n}\n\n.action-text {\n color: rgba(255, 255, 255, 0.45) !important;\n font-size: 12px;\n}\n"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SessionLayout } from "./components/SessionLayout";
|
|
3
|
+
import MsgBox from "./components/MsgBox";
|
|
4
|
+
import TaskBox from "./components/TaskBox";
|
|
5
|
+
import Header from "dumi/theme/slots/Header";
|
|
6
|
+
function AIPlayground() {
|
|
7
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Header, null), /*#__PURE__*/React.createElement(SessionLayout, null, /*#__PURE__*/React.createElement(MsgBox, null), /*#__PURE__*/React.createElement(TaskBox, null)));
|
|
8
|
+
}
|
|
9
|
+
export default AIPlayground;
|
|
File without changes
|
|
@@ -11,7 +11,7 @@ import CommonHelmet from "../../common/CommonHelmet";
|
|
|
11
11
|
import { ic } from "../../slots/hooks";
|
|
12
12
|
import { Cases } from "./components/Cases";
|
|
13
13
|
import { Companies } from "./components/Companies";
|
|
14
|
-
import { Detail } from "
|
|
14
|
+
import { Detail } from "dumi/theme/slots/Detail";
|
|
15
15
|
import { Features } from "./components/Features";
|
|
16
16
|
var Index = function Index() {
|
|
17
17
|
var _useSiteData = useSiteData(),
|
package/dist/plugin/index.js
CHANGED
|
@@ -47,12 +47,14 @@ var MOCK_META = { frontmatter: { title: "mock-meta" }, texts: [], toc: [] };
|
|
|
47
47
|
var plugin_default = (api) => {
|
|
48
48
|
api.describe({ key: `dumi-theme:${require("../../package.json").name}` });
|
|
49
49
|
api.chainWebpack((config) => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
if (api.env === "production") {
|
|
51
|
+
config.plugin("critters").use(import_critters_webpack_plugin.default, [
|
|
52
|
+
{
|
|
53
|
+
preload: "js-lazy",
|
|
54
|
+
inlineThreshold: 10240
|
|
55
|
+
}
|
|
56
|
+
]);
|
|
57
|
+
}
|
|
56
58
|
});
|
|
57
59
|
api.modifyDefaultConfig((memo) => {
|
|
58
60
|
memo.resolve.codeBlockMode = "passive";
|
|
@@ -163,6 +165,12 @@ export default function ThemeAntVContextWrapper() {
|
|
|
163
165
|
absPath: "/:language/examples/:topic/:example",
|
|
164
166
|
path: ":language/examples/:topic/:example",
|
|
165
167
|
file: `${PAGES_DIR}/Example`
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
id: "dumi-theme-antv-ai-playground-lang",
|
|
171
|
+
absPath: "/:language/ai-playground/:id",
|
|
172
|
+
path: ":language/ai-playground/:id",
|
|
173
|
+
file: `${PAGES_DIR}/AIPlayground`
|
|
166
174
|
}
|
|
167
175
|
];
|
|
168
176
|
extraRoutesList.forEach((itemRoute) => {
|