@antv/dumi-theme-antv 0.8.0-beta.2 → 0.8.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builtins/Playground/index.module.less +0 -1
- package/dist/components/AI/HomeDialog/AntVBanner/index.module.less +2 -2
- package/dist/components/AI/HomeDialog/ModeSelector/ModeSelectorDropdown.js +42 -0
- package/dist/components/AI/HomeDialog/ModeSelector/index.module.less +39 -22
- package/dist/components/AI/HomeDialog/PromptTextarea/ChooseLib/index.js +12 -4
- package/dist/components/AI/HomeDialog/PromptTextarea/ChooseLib/index.module.less +0 -1
- package/dist/components/AI/HomeDialog/PromptTextarea/DatasourceCard/index.module.less +3 -3
- package/dist/components/AI/HomeDialog/PromptTextarea/index.js +38 -36
- package/dist/components/AI/HomeDialog/PromptTextarea/index.module.less +8 -8
- package/dist/components/AI/HomeDialog/RecommendCase/Card.js +14 -11
- package/dist/components/AI/HomeDialog/RecommendCase/card.module.less +3 -3
- package/dist/components/AI/HomeDialog/RecommendCase/index.js +73 -24
- package/dist/components/AI/HomeDialog/RecommendCase/index.module.less +4 -2
- package/dist/components/AI/HomeDialog/RecommendCase/recommend.json +41 -17
- package/dist/components/AI/HomeDialog/index.js +21 -33
- package/dist/components/AI/constant.js +4 -2
- package/dist/components/Login/Captcha/index.js +185 -0
- package/dist/components/Login/Captcha/index.less +91 -0
- package/dist/components/Login/CheckCode/index.js +244 -0
- package/dist/components/Login/CheckCode/index.less +137 -0
- package/dist/components/Login/CountDownButton/index.js +109 -0
- package/dist/components/Login/CountDownButton/index.less +8 -0
- package/dist/components/Login/LoginForm.js +239 -0
- package/dist/components/Login/LoginForm.less +409 -0
- package/dist/components/Login/index.js +24 -0
- package/dist/components/Login/openAuthWindow.js +54 -0
- package/dist/components/Login/types.js +5 -0
- package/dist/components/Login/utils.js +47 -0
- package/dist/hooks/useProducts.js +22 -1
- package/dist/layouts/DocLayout.js +2 -1
- package/dist/layouts/GlobalLayout/index.js +11 -4
- package/dist/locales/en.json +43 -2
- package/dist/locales/zh.json +43 -2
- package/dist/model/AIChat.js +93 -6
- package/dist/model/auth.js +147 -0
- package/dist/pages/AIPlayground/components/ConversationsMenu/index.js +15 -7
- package/dist/pages/AIPlayground/components/ConversationsMenu/index.module.less +2 -0
- package/dist/pages/AIPlayground/components/MarkdownComponent/MarkdownCodeBlock.js +26 -17
- package/dist/pages/AIPlayground/components/MarkdownComponent/MarkdownCodeBlock.module.less +1 -2
- package/dist/pages/AIPlayground/components/MarkdownComponent/index.js +7 -4
- package/dist/pages/AIPlayground/components/MsgBox/index.js +266 -149
- package/dist/pages/AIPlayground/components/MsgBox/index.module.less +3 -2
- package/dist/pages/AIPlayground/components/MsgBox/useAutoScroll.js +46 -0
- package/dist/pages/AIPlayground/components/SessionLayout/index.js +41 -12
- package/dist/pages/AIPlayground/components/SessionLayout/index.module.less +4 -4
- package/dist/pages/AIPlayground/components/TaskBox/generateCode.js +129 -8
- package/dist/pages/AIPlayground/components/TaskBox/index.js +92 -55
- package/dist/pages/AIPlayground/components/TaskBox/index.module.less +1 -0
- package/dist/pages/AIPlayground/index.js +4 -1
- package/dist/pages/AIPlayground/index.module.less +5 -0
- package/dist/pages/Examples/components/Accouncement/index.module.less +1 -1
- package/dist/pages/Examples/index.module.less +11 -11
- package/dist/pages/Index/components/Cases/index.module.less +8 -8
- package/dist/pages/Index/components/Companies/index.module.less +4 -3
- package/dist/pages/Index/components/Features/FeatureCard.module.less +4 -5
- package/dist/pages/Index/components/Features/index.module.less +5 -5
- package/dist/pages/Index/components/_.less +9 -9
- package/dist/slots/Banner/Notification.module.less +8 -8
- package/dist/slots/Banner/index.module.less +10 -9
- package/dist/slots/CodeEditor/Toolbar.js +7 -25
- package/dist/slots/CodeEditor/index.js +34 -12
- package/dist/slots/CodeEditor/index.module.less +3 -1
- package/dist/slots/CodeEditor/utils.js +2 -1
- package/dist/slots/CodePreview/index.module.less +0 -3
- package/dist/slots/CodeRunner/index.js +23 -11
- package/dist/slots/ContentTable/index.module.less +2 -1
- package/dist/slots/Detail/News.module.less +9 -9
- package/dist/slots/Detail/index.js +2 -1
- package/dist/slots/Detail/index.module.less +11 -14
- package/dist/slots/ExampleSider/index.module.less +3 -4
- package/dist/slots/Footer/index.module.less +2 -2
- package/dist/slots/Header/Products/Product.module.less +2 -2
- package/dist/slots/Header/Search/SearchResult.js +20 -8
- package/dist/slots/Header/Search/SearchResult.module.less +1 -0
- package/dist/slots/Header/index.js +51 -25
- package/dist/slots/Header/index.module.less +13 -5
- package/dist/slots/LiveExample/index.module.less +1 -1
- package/dist/slots/Loading/index.module.less +30 -28
- package/dist/slots/ManualContent/index.module.less +14 -17
- package/dist/slots/_.less +9 -9
- package/dist/static/user.svg +3 -0
- package/dist/typings.d.ts +6 -0
- package/dist/utils/analytics.js +16 -0
- package/dist/utils/env.js +63 -0
- package/dist/utils/index.js +7 -0
- package/dist/utils/request.js +42 -0
- package/package.json +9 -5
- package/dist/static/SearchAiIcon.svg +0 -14
|
@@ -1,33 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
29
|
+
React.createElement(SplitPane, {
|
|
19
30
|
split: "vertical",
|
|
20
|
-
defaultSize:
|
|
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:
|
|
24
|
-
}
|
|
40
|
+
position: 'unset'
|
|
41
|
+
},
|
|
42
|
+
minSize: 100
|
|
25
43
|
}, /*#__PURE__*/React.createElement("div", {
|
|
26
44
|
className: classnames(styles.msgBox)
|
|
27
45
|
}, children[0]), /*#__PURE__*/React.createElement("div", {
|
|
28
46
|
className: styles.taskBox
|
|
29
47
|
}, children[1])) : /*#__PURE__*/React.createElement("div", {
|
|
30
|
-
className: classnames(styles.msgBox, styles.msgBoxFull)
|
|
31
|
-
|
|
48
|
+
className: classnames(styles.msgBox, styles.msgBoxFull),
|
|
49
|
+
key: snap.codeBlock
|
|
50
|
+
}, children[0]), isDragging && /*#__PURE__*/React.createElement("div", {
|
|
51
|
+
style: {
|
|
52
|
+
position: 'fixed',
|
|
53
|
+
top: 0,
|
|
54
|
+
left: 0,
|
|
55
|
+
right: 0,
|
|
56
|
+
bottom: 0,
|
|
57
|
+
zIndex: 9999,
|
|
58
|
+
cursor: 'col-resize' // 或 'row-resize' 用于水平分割
|
|
59
|
+
}
|
|
60
|
+
}));
|
|
32
61
|
}
|
|
33
62
|
export { SessionLayout };
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
display: flex;
|
|
3
3
|
gap: 12px;
|
|
4
4
|
background: #f6f7fb;
|
|
5
|
-
height: calc(100vh - 64px);
|
|
6
5
|
padding: 0;
|
|
6
|
+
flex-grow: 1;
|
|
7
|
+
overflow-y: auto;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
.msgBox, .taskBox{
|
|
@@ -21,7 +22,7 @@
|
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
.msgBoxHalf {
|
|
24
|
-
max-width:
|
|
25
|
+
max-width: 40vw;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
.msgBoxFull {
|
|
@@ -31,7 +32,6 @@
|
|
|
31
32
|
.taskBox {
|
|
32
33
|
height: calc(100% - 32px);
|
|
33
34
|
margin: 16px;
|
|
34
|
-
padding: 16px;
|
|
35
35
|
flex-grow: 1;
|
|
36
|
-
background:
|
|
36
|
+
background: transparent;
|
|
37
37
|
}
|
|
@@ -1,3 +1,9 @@
|
|
|
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 ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
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
7
|
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
8
|
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
9
|
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; }
|
|
@@ -7,7 +13,9 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
7
13
|
* @param {string} codeString 包含代码的字符串。
|
|
8
14
|
* @returns {object} 一个符合 package.json dependencies 格式的对象。
|
|
9
15
|
*/
|
|
10
|
-
export function generateDependencies(
|
|
16
|
+
export function generateDependencies() {
|
|
17
|
+
var codeString = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
18
|
+
var ext = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'js';
|
|
11
19
|
// 1. 初始化固定的依赖
|
|
12
20
|
var dependencies = {};
|
|
13
21
|
|
|
@@ -68,26 +76,139 @@ export function generateDependencies(codeString) {
|
|
|
68
76
|
dependencies[pkg] = "latest";
|
|
69
77
|
}
|
|
70
78
|
}
|
|
79
|
+
|
|
80
|
+
// VisionSnap限制只要是jsx就必须装React。
|
|
71
81
|
} catch (err) {
|
|
72
82
|
_iterator.e(err);
|
|
73
83
|
} finally {
|
|
74
84
|
_iterator.f();
|
|
75
85
|
}
|
|
86
|
+
if (ext === 'jsx' || ext === 'tsx') {
|
|
87
|
+
dependencies["react"] = "^18";
|
|
88
|
+
dependencies["react-dom"] = "^18";
|
|
89
|
+
}
|
|
90
|
+
if (ext === 'vue') {
|
|
91
|
+
dependencies["vue"] = "^3";
|
|
92
|
+
}
|
|
93
|
+
if (dependencies['@antv/s2'] || dependencies['@antv/s2-react'] || dependencies['@antv/s2-react-components']) {
|
|
94
|
+
dependencies = _objectSpread(_objectSpread({}, dependencies), {}, {
|
|
95
|
+
"@ant-design/icons": "^6.1.0",
|
|
96
|
+
"@antv/s2": "^2.4.9",
|
|
97
|
+
"@antv/s2-react": "^2.2.3",
|
|
98
|
+
"@antv/s2-react-components": "^2.1.2",
|
|
99
|
+
"antd": "^5.27.6",
|
|
100
|
+
"insert-css": "^2.0.0",
|
|
101
|
+
"react": "^18.3.1",
|
|
102
|
+
"react-color": "^2.19.3",
|
|
103
|
+
"react-dom": "^18.3.1",
|
|
104
|
+
"@antv/g2": "^5.4.2"
|
|
105
|
+
});
|
|
106
|
+
}
|
|
76
107
|
return dependencies;
|
|
77
108
|
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* 基于代码内容,启发式地判断其最合适的文件扩展名。
|
|
112
|
+
* @param {string} code - 要分析的前端代码字符串。
|
|
113
|
+
* @returns {'vue' | 'tsx' | 'jsx' | 'ts' | 'js'} - 推断出的文件扩展名(不含点)。
|
|
114
|
+
*/
|
|
115
|
+
export function getLanguageExtension(code) {
|
|
116
|
+
// --- 特征检测函数 ---
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* 检查代码是否包含 Vue 单文件组件 (SFC) 的特征。
|
|
120
|
+
* 这是最优先的检查,因为Vue的SFC结构非常独特。
|
|
121
|
+
*/
|
|
122
|
+
var containsVue = function containsVue(text) {
|
|
123
|
+
// 检查点 1: Vue 3 <script setup> 语法(最强信号)
|
|
124
|
+
// 匹配 <script setup> 或 <script lang="ts" setup>
|
|
125
|
+
var scriptSetupRegex = /<script\s+(?:lang="ts"\s+)?setup>/;
|
|
126
|
+
if (scriptSetupRegex.test(text)) {
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// 检查点 2: 顶层 <template> 块(非常强的信号)
|
|
131
|
+
// 使用 'm' (multiline) 标志,'^' 匹配每行的开头。
|
|
132
|
+
var templateRegex = /^\s*<template.*>/m;
|
|
133
|
+
if (templateRegex.test(text)) {
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// 检查点 3: 导入 Vue 核心库(通用信号)
|
|
138
|
+
// 匹配 import ... from 'vue'
|
|
139
|
+
var vueImportRegex = /import\s+.*?\s+from\s*['"]vue['"]/;
|
|
140
|
+
if (vueImportRegex.test(text)) {
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// 检查点 4: Vue 2 Options API 特征(辅助信号)
|
|
145
|
+
// 匹配 export default { ... data|methods|computed ... } 结构
|
|
146
|
+
var optionsApiRegex = /\bexport\s+default\s*{[\s\S]*?\b(data|methods|computed|watch)\b/;
|
|
147
|
+
if (optionsApiRegex.test(text)) {
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
return false;
|
|
151
|
+
};
|
|
152
|
+
var containsJsx = function containsJsx(text) {
|
|
153
|
+
var jsxRegex = /<(?![\s!=])([a-zA-Z][a-zA-Z0-9-]*|\/|)/;
|
|
154
|
+
return jsxRegex.test(text);
|
|
155
|
+
};
|
|
156
|
+
var containsTypeScript = function containsTypeScript(text) {
|
|
157
|
+
var typeDefinitionRegex = /\b(interface|type)\s+[A-Z][a-zA-Z0-9]*\b/;
|
|
158
|
+
if (typeDefinitionRegex.test(text)) return true;
|
|
159
|
+
var typeAnnotationRegex = /:\s*([A-Z][a-zA-Z0-9<>.]*|string|number|boolean|any\[?\]?)/;
|
|
160
|
+
if (typeAnnotationRegex.test(text)) return true;
|
|
161
|
+
var tsKeywordsRegex = /\b(as|implements|private|public|protected|readonly)\s+[a-zA-Z]/;
|
|
162
|
+
if (tsKeywordsRegex.test(text)) return true;
|
|
163
|
+
return false;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// --- 决策逻辑(Vue优先) ---
|
|
167
|
+
|
|
168
|
+
if (containsVue(code)) {
|
|
169
|
+
return 'vue';
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// 如果不是Vue,则回退到原有的React/JS逻辑
|
|
173
|
+
if (containsJsx(code)) {
|
|
174
|
+
if (containsTypeScript(code)) {
|
|
175
|
+
return 'tsx';
|
|
176
|
+
}
|
|
177
|
+
return 'jsx';
|
|
178
|
+
} else {
|
|
179
|
+
if (containsTypeScript(code)) {
|
|
180
|
+
return 'ts';
|
|
181
|
+
}
|
|
182
|
+
return 'js';
|
|
183
|
+
}
|
|
184
|
+
}
|
|
78
185
|
export function wrap2VisionSnap() {
|
|
79
186
|
var codeBlock = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
187
|
+
var ext = getLanguageExtension(codeBlock);
|
|
188
|
+
var mainFile = ext === 'vue' ? "/src/index.js" : "/src/index.".concat(ext);
|
|
189
|
+
var appFile = "/src/App.".concat(ext);
|
|
190
|
+
var dependencies = generateDependencies(codeBlock, ext);
|
|
191
|
+
var rootElementType = dependencies['@antv/f2'] ? 'canvas' : 'div';
|
|
192
|
+
var dependenciesJSON = {
|
|
193
|
+
"name": "AntV-adapted-project",
|
|
194
|
+
"version": "1.0.0",
|
|
195
|
+
"main": mainFile,
|
|
196
|
+
"dependencies": dependencies
|
|
197
|
+
};
|
|
198
|
+
var mainFileCode = ext === 'vue' ? "import { createApp } from 'vue';\nimport App from './App.vue';\n\nconst app = createApp(App);\napp.mount('#app');\n" : "\n// --- Adapter Script ---\n\n// 1. \u627E\u5230\u7F16\u8F91\u5668\u73AF\u5883\u63D0\u4F9B\u7684\u6839\u8282\u70B9 #root\nconst rootElement = document.getElementById('root');\n\nif (rootElement) {\n // 2. \u5728 #root \u5185\u90E8\u521B\u5EFA\u4E00\u4E2A ".concat(rootElementType, "\n const containerElement = document.createElement('").concat(rootElementType, "');\n\n // 3. \u5C06\u8FD9\u4E2A div \u7684 id \u8BBE\u7F6E\u4E3A 'container'\uFF0C\u4EE5\u6EE1\u8DB3\u7528\u6237\u4EE3\u7801\u7684\u9700\u6C42\n containerElement.id = 'container';\n\n // 4. \u5C06\u5B83\u6DFB\u52A0\u5230 #root \u4E2D\n rootElement.appendChild(containerElement);\n\n // 5. \u73B0\u5728 DOM \u4E2D\u5DF2\u7ECF\u5B58\u5728 #container\uFF0C\u5B89\u5168\u5730\u5BFC\u5165\u5E76\u6267\u884C\u7528\u6237\u7684\u4EE3\u7801\n import('./App.").concat(ext, "');\n\n}\n ");
|
|
80
199
|
return {
|
|
81
|
-
modules: {
|
|
200
|
+
modules: _defineProperty(_defineProperty({
|
|
82
201
|
'/package.json': {
|
|
83
202
|
fpath: '/package.json',
|
|
84
|
-
code:
|
|
85
|
-
},
|
|
86
|
-
'/src/index.jsx': {
|
|
87
|
-
fpath: '/src/index.jsx',
|
|
88
|
-
code: codeBlock
|
|
203
|
+
code: JSON.stringify(dependenciesJSON, null, 2)
|
|
89
204
|
}
|
|
90
|
-
}
|
|
205
|
+
}, mainFile, {
|
|
206
|
+
fpath: mainFile,
|
|
207
|
+
code: mainFileCode
|
|
208
|
+
}), appFile, {
|
|
209
|
+
fpath: appFile,
|
|
210
|
+
code: codeBlock
|
|
211
|
+
})
|
|
91
212
|
};
|
|
92
213
|
}
|
|
93
214
|
export function wrap2Sandpack() {
|
|
@@ -1,61 +1,98 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { useSiteData } from 'dumi';
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
|
+
import { useSnapshot } from 'valtio';
|
|
4
4
|
import { AIChatStore } from "../../../../model/AIChat";
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
import CodeRunner from "dumi/theme/slots/CodeRunner";
|
|
6
|
+
import { wrap2VisionSnap } from "./generateCode";
|
|
7
|
+
import { requestProxy, useVisionsnapSdk } from "../../../../hooks/useVisionsnapSdk";
|
|
8
|
+
import { ErrorBoundary } from 'react-error-boundary';
|
|
9
|
+
import Loading from "dumi/theme/slots/Loading";
|
|
10
|
+
import { ErrorFallback } from "../../../../builtins/Playground";
|
|
11
|
+
import { useAntVConfig } from "../../../../hooks/useProducts";
|
|
10
12
|
function TaskBox() {
|
|
13
|
+
var _themeConfig$ai, _themeConfig$ai2;
|
|
14
|
+
var _useAntVConfig = useAntVConfig(),
|
|
15
|
+
_useAntVConfig$data = _useAntVConfig.data,
|
|
16
|
+
_useAntVConfig$data2 = _useAntVConfig$data === void 0 ? {
|
|
17
|
+
VisionSnapVersion: '3.4.11'
|
|
18
|
+
} : _useAntVConfig$data,
|
|
19
|
+
version = _useAntVConfig$data2.VisionSnapVersion;
|
|
11
20
|
var snap = useSnapshot(AIChatStore);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
|
21
|
+
var _useSiteData = useSiteData(),
|
|
22
|
+
themeConfig = _useSiteData.themeConfig;
|
|
23
|
+
var demoId = useMemo(function () {
|
|
24
|
+
return crypto.randomUUID();
|
|
25
|
+
}, [snap.codeBlock]);
|
|
26
|
+
var exampleTopics = useMemo(function () {
|
|
27
|
+
return [{
|
|
28
|
+
icon: '',
|
|
29
|
+
title: {},
|
|
30
|
+
id: snap.anonymousUserId,
|
|
31
|
+
examples: [
|
|
32
|
+
// 这是一个 Example 对象
|
|
33
|
+
{
|
|
34
|
+
icon: '',
|
|
35
|
+
title: {},
|
|
36
|
+
id: snap.activeSessionId,
|
|
37
|
+
api: 'https://example.com/api/pie-chart',
|
|
38
|
+
// 必须的 api 属性
|
|
39
|
+
demos: [
|
|
40
|
+
// 这是一个 Demo 对象
|
|
41
|
+
{
|
|
42
|
+
id: demoId,
|
|
43
|
+
screenshot: '',
|
|
44
|
+
title: {},
|
|
45
|
+
filename: 'index.tsx',
|
|
46
|
+
// 必须的 filename 属性
|
|
47
|
+
source: snap.codeBlock
|
|
48
|
+
}]
|
|
57
49
|
}]
|
|
58
|
-
}
|
|
59
|
-
});
|
|
50
|
+
}];
|
|
51
|
+
}, [demoId, snap.activeSessionId, snap.anonymousUserId, snap.codeBlock]);
|
|
52
|
+
var _useVisionsnapSdk = useVisionsnapSdk(version),
|
|
53
|
+
sdk = _useVisionsnapSdk.sdk,
|
|
54
|
+
loading = _useVisionsnapSdk.loading;
|
|
55
|
+
if (loading) {
|
|
56
|
+
return /*#__PURE__*/React.createElement(Loading, null);
|
|
57
|
+
}
|
|
58
|
+
var wrappedVisionSnapCode = wrap2VisionSnap(snap.codeBlock);
|
|
59
|
+
var handleEsmLoadFailed = function handleEsmLoadFailed(err) {
|
|
60
|
+
var _err$data;
|
|
61
|
+
AIChatStore.errorMsg = ((_err$data = err.data) === null || _err$data === void 0 || (_err$data = _err$data.error) === null || _err$data === void 0 || (_err$data = _err$data.split('\n')) === null || _err$data === void 0 ? void 0 : _err$data[0]) || JSON.stringify(err) || err.message;
|
|
62
|
+
};
|
|
63
|
+
if (themeConfig.isAntVSite || ((_themeConfig$ai = themeConfig.ai) === null || _themeConfig$ai === void 0 ? void 0 : _themeConfig$ai.codeRunner) === "VisionSnap" || !((_themeConfig$ai2 = themeConfig.ai) !== null && _themeConfig$ai2 !== void 0 && _themeConfig$ai2.codeRunner) || !wrappedVisionSnapCode.modules["/package.json"].code.includes("@antv/f2")) {
|
|
64
|
+
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
65
|
+
FallbackComponent: ErrorFallback
|
|
66
|
+
}, /*#__PURE__*/React.createElement(sdk.VisionPreview, {
|
|
67
|
+
id: "visionIframe",
|
|
68
|
+
bizCode: "antv",
|
|
69
|
+
style: {
|
|
70
|
+
height: '100vh'
|
|
71
|
+
},
|
|
72
|
+
userId: "antv",
|
|
73
|
+
displayMode: "code-and-preview",
|
|
74
|
+
initialView: "preview",
|
|
75
|
+
theme: "light",
|
|
76
|
+
code: wrappedVisionSnapCode,
|
|
77
|
+
requestProxy: requestProxy,
|
|
78
|
+
isStreaming: false,
|
|
79
|
+
proxyOptions: {
|
|
80
|
+
isWAN: true
|
|
81
|
+
},
|
|
82
|
+
src: "https://www.weavefox.cn/_visionsnap_render".concat(wrappedVisionSnapCode.modules["/package.json"].code.includes("vue") ? '_vue' : '', "/index.html?version=").concat(version, "&enableInspector=1"),
|
|
83
|
+
onEsmLoadFailed: handleEsmLoadFailed
|
|
84
|
+
}));
|
|
85
|
+
} else {
|
|
86
|
+
return /*#__PURE__*/React.createElement(CodeRunner, {
|
|
87
|
+
isPlayground: true,
|
|
88
|
+
showAI: false,
|
|
89
|
+
showEditor: false,
|
|
90
|
+
size: 0.5,
|
|
91
|
+
topic: snap.anonymousUserId,
|
|
92
|
+
example: snap.activeSessionId,
|
|
93
|
+
demo: demoId,
|
|
94
|
+
exampleTopics: exampleTopics
|
|
95
|
+
});
|
|
96
|
+
}
|
|
60
97
|
}
|
|
61
98
|
export default TaskBox;
|
|
@@ -3,7 +3,10 @@ import { SessionLayout } from "./components/SessionLayout";
|
|
|
3
3
|
import MsgBox from "./components/MsgBox";
|
|
4
4
|
import TaskBox from "./components/TaskBox";
|
|
5
5
|
import Header from "dumi/theme/slots/Header";
|
|
6
|
+
import styles from "./index.module.less";
|
|
6
7
|
function AIPlayground() {
|
|
7
|
-
return /*#__PURE__*/React.createElement(
|
|
8
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
9
|
+
className: styles.aiPlayground
|
|
10
|
+
}, /*#__PURE__*/React.createElement(Header, null), /*#__PURE__*/React.createElement(SessionLayout, null, /*#__PURE__*/React.createElement(MsgBox, null), /*#__PURE__*/React.createElement(TaskBox, null)));
|
|
8
11
|
}
|
|
9
12
|
export default AIPlayground;
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
pre[class*='language-'] {
|
|
80
|
-
background-color: rgba(0, 0, 0,
|
|
80
|
+
background-color: rgba(0, 0, 0, 3%);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
code[class*='language-'] {
|
|
@@ -155,7 +155,7 @@
|
|
|
155
155
|
table th {
|
|
156
156
|
color: #5c6b77;
|
|
157
157
|
font-weight: 500;
|
|
158
|
-
background: rgba(0, 0, 0,
|
|
158
|
+
background: rgba(0, 0, 0, 2%);
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
table th,
|
|
@@ -174,7 +174,7 @@
|
|
|
174
174
|
width: 20%;
|
|
175
175
|
font-weight: 500;
|
|
176
176
|
background: #fcfcfc;
|
|
177
|
-
color: rgba(0, 0, 0,
|
|
177
|
+
color: rgba(0, 0, 0, 85%);
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
blockquote {
|
|
@@ -197,15 +197,16 @@
|
|
|
197
197
|
|
|
198
198
|
.layout {
|
|
199
199
|
margin: 24px 0 32px;
|
|
200
|
+
|
|
200
201
|
:global {
|
|
201
202
|
.ant-layout-content {
|
|
202
|
-
background-color: #
|
|
203
|
+
background-color: #fff;
|
|
203
204
|
}
|
|
204
205
|
}
|
|
205
206
|
}
|
|
206
207
|
|
|
207
208
|
.main {
|
|
208
|
-
background-color: #
|
|
209
|
+
background-color: #fff;
|
|
209
210
|
width: calc(100% - @toc-width);
|
|
210
211
|
padding-left: 48px;
|
|
211
212
|
padding-right: 24px;
|
|
@@ -248,7 +249,6 @@
|
|
|
248
249
|
background: #fff;
|
|
249
250
|
max-height: 100vh;
|
|
250
251
|
overflow: hidden;
|
|
251
|
-
|
|
252
252
|
position: sticky;
|
|
253
253
|
top: 0;
|
|
254
254
|
padding: 8px 0;
|
|
@@ -288,6 +288,7 @@
|
|
|
288
288
|
|
|
289
289
|
.affix {
|
|
290
290
|
background-color: #fff;
|
|
291
|
+
|
|
291
292
|
& > div {
|
|
292
293
|
height: 100%;
|
|
293
294
|
}
|
|
@@ -325,7 +326,7 @@
|
|
|
325
326
|
justify-content: center;
|
|
326
327
|
align-items: center;
|
|
327
328
|
background: #fff;
|
|
328
|
-
box-shadow: 2px 0 8px rgba(0, 0, 0,
|
|
329
|
+
box-shadow: 2px 0 8px rgba(0, 0, 0, 15%);
|
|
329
330
|
border-radius: 0 4px 4px 0;
|
|
330
331
|
}
|
|
331
332
|
}
|
|
@@ -401,7 +402,7 @@
|
|
|
401
402
|
&:hover > div {
|
|
402
403
|
transform: translateY(-4px);
|
|
403
404
|
border-color: transparent;
|
|
404
|
-
box-shadow: 0 6px 16px rgba(107, 147, 224,
|
|
405
|
+
box-shadow: 0 6px 16px rgba(107, 147, 224, 14%);
|
|
405
406
|
}
|
|
406
407
|
|
|
407
408
|
h4 {
|
|
@@ -455,7 +456,7 @@
|
|
|
455
456
|
:global {
|
|
456
457
|
.SplitPane {
|
|
457
458
|
overflow: auto;
|
|
458
|
-
left:
|
|
459
|
+
left: 0;
|
|
459
460
|
height: calc(100vh - 64px) !important;
|
|
460
461
|
}
|
|
461
462
|
|
|
@@ -603,10 +604,9 @@
|
|
|
603
604
|
}
|
|
604
605
|
|
|
605
606
|
.backTop {
|
|
606
|
-
transition: color 0.3s;
|
|
607
607
|
color: #868484;
|
|
608
608
|
background-color: #fff;
|
|
609
|
-
box-shadow: 0 3px 6px -4px rgba(0, 0, 0,
|
|
609
|
+
box-shadow: 0 3px 6px -4px rgba(0, 0, 0, 12%), 0 6px 16px 0 rgba(0, 0, 0, 8%), 0 9px 28px 8px rgba(0, 0, 0, 5%);
|
|
610
610
|
transition: color 0.3s;
|
|
611
611
|
width: 44px;
|
|
612
612
|
height: 44px;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
position: relative;
|
|
7
7
|
padding: 0;
|
|
8
8
|
overflow: hidden;
|
|
9
|
-
background: rgba(250, 251, 252,
|
|
9
|
+
background: rgba(250, 251, 252, 100%);
|
|
10
10
|
|
|
11
11
|
.slider {
|
|
12
12
|
.container1440();
|
|
@@ -38,22 +38,22 @@
|
|
|
38
38
|
.appTitle {
|
|
39
39
|
font-size: 1.2857em;
|
|
40
40
|
font-weight: 500;
|
|
41
|
-
margin: 48px 0 0
|
|
41
|
+
margin: 48px 0 0;
|
|
42
42
|
position: relative;
|
|
43
43
|
height: min-content;
|
|
44
|
-
color: rgba(0, 0, 0,
|
|
44
|
+
color: rgba(0, 0, 0, 100%);
|
|
45
45
|
user-select: text;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
.appDescription {
|
|
49
|
-
color: rgba(105, 123, 140,
|
|
49
|
+
color: rgba(105, 123, 140, 60%);
|
|
50
50
|
font-size: 1em;
|
|
51
|
-
margin: 16px 0 0
|
|
51
|
+
margin: 16px 0 0;
|
|
52
52
|
user-select: text;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
.detailWrapper {
|
|
56
|
-
margin: 20px 0 0
|
|
56
|
+
margin: 20px 0 0;
|
|
57
57
|
|
|
58
58
|
.detail {
|
|
59
59
|
color: var(--primary-color);
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
|
|
82
82
|
&:hover {
|
|
83
83
|
border: 1px solid #ced4d9;
|
|
84
|
-
fill: #
|
|
84
|
+
fill: #000;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
&:hover :only-child {
|
|
@@ -228,7 +228,7 @@
|
|
|
228
228
|
bottom: 100px;
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
-
.slick-dots li.slick-active button
|
|
231
|
+
.slick-dots li.slick-active button::before {
|
|
232
232
|
opacity: 1;
|
|
233
233
|
color: #1890ff;
|
|
234
234
|
}
|
|
@@ -14,17 +14,18 @@
|
|
|
14
14
|
margin-bottom: 5%;
|
|
15
15
|
position: relative;
|
|
16
16
|
.container1440();
|
|
17
|
+
|
|
17
18
|
padding-left: 4.5%;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
.title {
|
|
21
22
|
font-size: 2.714em;
|
|
22
23
|
font-weight: 500;
|
|
23
|
-
margin: 118px 0 0
|
|
24
|
+
margin: 118px 0 0;
|
|
24
25
|
position: relative;
|
|
25
26
|
height: min-content;
|
|
26
27
|
text-align: center;
|
|
27
|
-
color: rgba(0, 0, 0,
|
|
28
|
+
color: rgba(0, 0, 0, 100%);
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
.companiesContainer {
|
|
@@ -73,7 +74,7 @@
|
|
|
73
74
|
.wrapper {
|
|
74
75
|
.title {
|
|
75
76
|
font-size: 1.9rem;
|
|
76
|
-
margin: 98px 0 0
|
|
77
|
+
margin: 98px 0 0;
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
.content {
|