@antv/dumi-theme-antv 0.7.9 → 0.8.0-alpha.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/builtins/Playground/index.js +1 -1
- package/dist/builtins/Playground/index.module.less +0 -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/ModeSelectorDropdown.js +42 -0
- package/dist/components/AI/HomeDialog/ModeSelector/index.js +32 -0
- package/dist/components/AI/HomeDialog/ModeSelector/index.module.less +289 -0
- package/dist/components/AI/HomeDialog/PromptTextarea/ChooseLib/index.js +62 -0
- package/dist/components/AI/HomeDialog/PromptTextarea/ChooseLib/index.module.less +4 -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/Uploader/DataUploader.js +225 -0
- package/dist/components/AI/HomeDialog/PromptTextarea/index.js +172 -0
- package/dist/components/AI/HomeDialog/PromptTextarea/index.module.less +128 -0
- package/dist/components/AI/HomeDialog/RecommendCase/Card.js +80 -0
- package/dist/components/AI/HomeDialog/RecommendCase/card.module.less +131 -0
- package/dist/components/AI/HomeDialog/RecommendCase/index.js +130 -0
- package/dist/components/AI/HomeDialog/RecommendCase/index.module.less +45 -0
- package/dist/components/AI/HomeDialog/RecommendCase/recommend.json +66 -0
- package/dist/components/AI/HomeDialog/index.js +62 -0
- package/dist/components/AI/HomeDialog/index.module.less +3 -0
- package/dist/components/AI/constant.js +37 -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/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 +408 -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 +39 -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 +2 -2
- package/dist/layouts/GlobalLayout/index.js +22 -0
- package/dist/locales/en.json +132 -1
- package/dist/locales/zh.json +132 -1
- package/dist/model/AIChat.js +313 -0
- package/dist/model/auth.js +147 -0
- package/dist/pages/AIPlayground/components/ConversationsMenu/index.js +176 -0
- package/dist/pages/AIPlayground/components/ConversationsMenu/index.module.less +46 -0
- package/dist/pages/AIPlayground/components/MarkdownComponent/MarkdownCodeBlock.js +97 -0
- package/dist/pages/AIPlayground/components/MarkdownComponent/MarkdownCodeBlock.module.less +13 -0
- package/dist/pages/AIPlayground/components/MarkdownComponent/index.js +50 -0
- package/dist/pages/AIPlayground/components/MsgBox/index.js +407 -0
- package/dist/pages/AIPlayground/components/MsgBox/index.module.less +43 -0
- package/dist/pages/AIPlayground/components/MsgBox/useAutoScroll.js +46 -0
- package/dist/pages/AIPlayground/components/SessionLayout/index.js +62 -0
- package/dist/pages/AIPlayground/components/SessionLayout/index.module.less +37 -0
- package/dist/pages/AIPlayground/components/TaskBox/generateCode.js +230 -0
- package/dist/pages/AIPlayground/components/TaskBox/index.js +101 -0
- package/dist/pages/AIPlayground/components/TaskBox/index.module.less +9 -0
- package/dist/pages/AIPlayground/demo.js +34 -0
- package/dist/pages/AIPlayground/index.js +12 -0
- 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 +13 -13
- package/dist/pages/Index/components/Cases/index.module.less +9 -9
- package/dist/pages/Index/components/Companies/index.module.less +5 -4
- package/dist/pages/Index/components/Features/FeatureCard.module.less +4 -5
- package/dist/pages/Index/components/Features/index.module.less +6 -6
- package/dist/pages/Index/components/_.less +9 -9
- package/dist/pages/Index/index.js +1 -1
- package/dist/plugin/index.js +14 -6
- package/dist/slots/Banner/Notification.module.less +8 -8
- package/dist/slots/Banner/index.module.less +11 -10
- package/dist/slots/CodeEditor/Toolbar.js +23 -27
- package/dist/slots/CodeEditor/Toolbar.module.less +7 -0
- package/dist/slots/CodeEditor/index.js +67 -5
- package/dist/slots/CodeEditor/index.module.less +24 -0
- package/dist/slots/CodeEditor/utils.js +2 -1
- package/dist/slots/CodePreview/index.module.less +0 -3
- package/dist/slots/CodeRunner/index.js +24 -11
- package/dist/slots/ContentTable/index.module.less +2 -1
- package/dist/{pages/Index/components → slots}/Detail/News.js +1 -1
- package/dist/{pages/Index/components → slots}/Detail/News.module.less +9 -9
- package/dist/{pages/Index/components → slots}/Detail/index.js +13 -29
- package/dist/{pages/Index/components → slots}/Detail/index.module.less +24 -21
- package/dist/slots/ExampleSider/index.module.less +3 -4
- package/dist/slots/Footer/index.module.less +3 -3
- package/dist/slots/Header/Products/Product.module.less +3 -3
- 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 +53 -14
- package/dist/slots/Header/Search/SearchResult.module.less +1 -0
- package/dist/slots/Header/Search/index.js +2 -1
- package/dist/slots/Header/index.js +72 -30
- package/dist/slots/Header/index.module.less +15 -7
- package/dist/slots/LiveExample/index.js +1 -1
- 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 +11 -0
- package/dist/utils/analytics.js +16 -0
- package/dist/utils/code.js +35 -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 +33 -17
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
height: 100%;
|
|
17
17
|
margin-left: 4.2%;
|
|
18
18
|
position: relative;
|
|
19
|
-
.container1440;
|
|
19
|
+
.container1440();
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
.title {
|
|
23
23
|
font-weight: 500;
|
|
24
|
-
margin: 17px 0 0
|
|
24
|
+
margin: 17px 0 0;
|
|
25
25
|
position: relative;
|
|
26
26
|
font-family: AlibabaPuHuiTiB;
|
|
27
27
|
font-size: 40px;
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
display: flex;
|
|
53
53
|
justify-content: center;
|
|
54
54
|
width: 100%;
|
|
55
|
-
background-color: #
|
|
55
|
+
background-color: #fff;
|
|
56
56
|
border: 1px solid #e5e8ef;
|
|
57
|
-
box-shadow: 0 8px 20px 0 rgba(0, 0, 0,
|
|
57
|
+
box-shadow: 0 8px 20px 0 rgba(0, 0, 0, 3%);
|
|
58
58
|
border-radius: 16px;
|
|
59
59
|
overflow: hidden;
|
|
60
60
|
}
|
|
@@ -77,12 +77,12 @@
|
|
|
77
77
|
|
|
78
78
|
.cardWrapper {
|
|
79
79
|
flex: none;
|
|
80
|
-
margin: 0 0 28px
|
|
80
|
+
margin: 0 0 28px;
|
|
81
81
|
width: 100%;
|
|
82
82
|
max-width: 100%;
|
|
83
83
|
|
|
84
84
|
&:last-child {
|
|
85
|
-
margin: 0 0 30px
|
|
85
|
+
margin: 0 0 30px;
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
}
|
|
@@ -81,30 +81,30 @@ h6 {
|
|
|
81
81
|
width: 100%;
|
|
82
82
|
height: 11px;
|
|
83
83
|
margin: -5px 0;
|
|
84
|
-
border-top: 5px solid rgba(255, 255, 255, 0);
|
|
85
|
-
border-bottom: 5px solid rgba(255, 255, 255, 0);
|
|
84
|
+
border-top: 5px solid rgba(255, 255, 255, 0%);
|
|
85
|
+
border-bottom: 5px solid rgba(255, 255, 255, 0%);
|
|
86
86
|
cursor: row-resize;
|
|
87
87
|
|
|
88
88
|
&:hover {
|
|
89
|
-
border-top: 5px solid rgba(0, 0, 0,
|
|
90
|
-
border-bottom: 5px solid rgba(0, 0, 0,
|
|
89
|
+
border-top: 5px solid rgba(0, 0, 0, 50%);
|
|
90
|
+
border-bottom: 5px solid rgba(0, 0, 0, 50%);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
&.vertical {
|
|
95
95
|
width: 11px;
|
|
96
96
|
margin: 0 -5px;
|
|
97
|
-
border-right: 5px solid rgba(255, 255, 255, 0);
|
|
98
|
-
border-left: 5px solid rgba(255, 255, 255, 0);
|
|
97
|
+
border-right: 5px solid rgba(255, 255, 255, 0%);
|
|
98
|
+
border-left: 5px solid rgba(255, 255, 255, 0%);
|
|
99
99
|
cursor: col-resize;
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
pane2 {
|
|
102
102
|
border-left: 1px solid #e6e6e6;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
&:hover {
|
|
106
|
-
border-right: 5px solid rgba(0, 0, 0,
|
|
107
|
-
border-left: 5px solid rgba(0, 0, 0,
|
|
106
|
+
border-right: 5px solid rgba(0, 0, 0, 50%);
|
|
107
|
+
border-left: 5px solid rgba(0, 0, 0, 50%);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
|
@@ -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",
|
|
172
|
+
path: ":language/ai-playground",
|
|
173
|
+
file: `${PAGES_DIR}/AIPlayground`
|
|
166
174
|
}
|
|
167
175
|
];
|
|
168
176
|
extraRoutesList.forEach((itemRoute) => {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
.content {
|
|
19
19
|
padding-left: 20px;
|
|
20
|
-
color: rgba(49, 70, 89,
|
|
20
|
+
color: rgba(49, 70, 89, 100%);
|
|
21
21
|
text-align: left;
|
|
22
22
|
|
|
23
23
|
.description {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
.date {
|
|
31
|
-
color: rgba(216, 203, 249,
|
|
31
|
+
color: rgba(216, 203, 249, 100%);
|
|
32
32
|
bottom: 0;
|
|
33
33
|
font-size: 1em;
|
|
34
34
|
margin-top: 4px;
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
&:hover .description {
|
|
41
|
-
color: rgba(89, 126, 247,
|
|
41
|
+
color: rgba(89, 126, 247, 100%);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -67,12 +67,12 @@
|
|
|
67
67
|
@keyframes showAndHide0 {
|
|
68
68
|
0% {
|
|
69
69
|
opacity: 1;
|
|
70
|
-
top:
|
|
70
|
+
top: 0;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
33.3% {
|
|
74
74
|
opacity: 1;
|
|
75
|
-
top:
|
|
75
|
+
top: 0;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
50% {
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
|
|
88
88
|
100% {
|
|
89
89
|
opacity: 1;
|
|
90
|
-
top:
|
|
90
|
+
top: 0;
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -105,12 +105,12 @@
|
|
|
105
105
|
|
|
106
106
|
50% {
|
|
107
107
|
opacity: 1;
|
|
108
|
-
top:
|
|
108
|
+
top: 0;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
83.3% {
|
|
112
112
|
opacity: 1;
|
|
113
|
-
top:
|
|
113
|
+
top: 0;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
100% {
|
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
.wrapper {
|
|
4
4
|
min-height: 650px;
|
|
5
5
|
max-height: 803px;
|
|
6
|
-
background: linear-gradient(225deg, #
|
|
6
|
+
background: linear-gradient(225deg, #fff, #f0f5ff);
|
|
7
7
|
height: calc(94vh);
|
|
8
8
|
position: relative;
|
|
9
9
|
overflow: hidden;
|
|
10
10
|
|
|
11
11
|
.content {
|
|
12
|
-
.container1440;
|
|
12
|
+
.container1440();
|
|
13
|
+
|
|
13
14
|
height: 100%;
|
|
14
15
|
position: relative;
|
|
15
16
|
}
|
|
@@ -23,14 +24,14 @@
|
|
|
23
24
|
.title {
|
|
24
25
|
font-size: 3.4em; //2.875em;
|
|
25
26
|
font-weight: 800;
|
|
26
|
-
color: rgba(0, 0, 0,
|
|
27
|
+
color: rgba(0, 0, 0, 100%);
|
|
27
28
|
position: relative;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
.description {
|
|
31
32
|
margin-top: 0.83%; //12px;
|
|
32
|
-
margin-bottom:
|
|
33
|
-
color: rgba(106, 123, 140,
|
|
33
|
+
margin-bottom: 0;
|
|
34
|
+
color: rgba(106, 123, 140, 100%);
|
|
34
35
|
font-size: 1.14em;
|
|
35
36
|
font-weight: 200;
|
|
36
37
|
position: relative;
|
|
@@ -162,6 +163,7 @@
|
|
|
162
163
|
.gh-count {
|
|
163
164
|
position: relative;
|
|
164
165
|
display: none;
|
|
166
|
+
|
|
165
167
|
/* hidden to start */
|
|
166
168
|
margin-left: 52px;
|
|
167
169
|
margin-top: 7px;
|
|
@@ -183,8 +185,8 @@
|
|
|
183
185
|
color: #4183c4;
|
|
184
186
|
}
|
|
185
187
|
|
|
186
|
-
.gh-count
|
|
187
|
-
.gh-count
|
|
188
|
+
.gh-count::before,
|
|
189
|
+
.gh-count::after {
|
|
188
190
|
content: '';
|
|
189
191
|
position: absolute;
|
|
190
192
|
display: inline-block;
|
|
@@ -194,7 +196,7 @@
|
|
|
194
196
|
border-style: solid;
|
|
195
197
|
}
|
|
196
198
|
|
|
197
|
-
.gh-count
|
|
199
|
+
.gh-count::before {
|
|
198
200
|
top: 50%;
|
|
199
201
|
left: -3px;
|
|
200
202
|
margin-top: -5px;
|
|
@@ -202,7 +204,7 @@
|
|
|
202
204
|
border-right-color: #fafafa;
|
|
203
205
|
}
|
|
204
206
|
|
|
205
|
-
.gh-count
|
|
207
|
+
.gh-count::after {
|
|
206
208
|
top: 50%;
|
|
207
209
|
border-width: 5px 5px 5px 0;
|
|
208
210
|
border-right-color: #d4d4d4;
|
|
@@ -228,7 +230,6 @@
|
|
|
228
230
|
display: flex;
|
|
229
231
|
position: absolute;
|
|
230
232
|
right: 0;
|
|
231
|
-
margin-top: -300px;
|
|
232
233
|
width: 52%;
|
|
233
234
|
max-width: 598px;
|
|
234
235
|
height: 324px;
|
|
@@ -10,10 +10,9 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
10
10
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
11
11
|
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); }
|
|
12
12
|
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); }
|
|
13
|
-
import {
|
|
13
|
+
import { PlayCircleOutlined, ReloadOutlined, ThunderboltOutlined } from '@ant-design/icons';
|
|
14
14
|
import stackblitzSdk from '@stackblitz/sdk';
|
|
15
15
|
import { Tooltip, Typography } from 'antd';
|
|
16
|
-
import { getParameters } from 'codesandbox/lib/api/define';
|
|
17
16
|
import { FormattedMessage, useLocale } from 'dumi';
|
|
18
17
|
import React, { useEffect, useState } from 'react';
|
|
19
18
|
import { ping } from "../utils";
|
|
@@ -42,7 +41,11 @@ export var Toolbar = function Toolbar(_ref) {
|
|
|
42
41
|
onEditorTabChange = _ref.onEditorTabChange,
|
|
43
42
|
_ref$onToggleFullscre = _ref.onToggleFullscreen,
|
|
44
43
|
onToggleFullscreen = _ref$onToggleFullscre === void 0 ? null : _ref$onToggleFullscre,
|
|
45
|
-
onExecuteCode = _ref.onExecuteCode
|
|
44
|
+
onExecuteCode = _ref.onExecuteCode,
|
|
45
|
+
onClickAI = _ref.onClickAI,
|
|
46
|
+
onReload = _ref.onReload,
|
|
47
|
+
_ref$showAI = _ref.showAI,
|
|
48
|
+
showAI = _ref$showAI === void 0 ? true : _ref$showAI;
|
|
46
49
|
var locale = useLocale();
|
|
47
50
|
var exampleTitle = _typeof(title) === 'object' ? title[locale.id] : title;
|
|
48
51
|
|
|
@@ -78,7 +81,19 @@ export var Toolbar = function Toolbar(_ref) {
|
|
|
78
81
|
return onEditorTabChange(tab);
|
|
79
82
|
}
|
|
80
83
|
}, tab, " ", slot && slot);
|
|
81
|
-
})),
|
|
84
|
+
})), showAI ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("a", {
|
|
85
|
+
className: styles.ai,
|
|
86
|
+
onClick: onClickAI
|
|
87
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
88
|
+
id: "ai.toolbar.assistant"
|
|
89
|
+
})), /*#__PURE__*/React.createElement(Tooltip, {
|
|
90
|
+
title: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
91
|
+
id: "ai.toolbar.restore"
|
|
92
|
+
})
|
|
93
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
94
|
+
className: styles.ai,
|
|
95
|
+
onClick: onReload
|
|
96
|
+
}, /*#__PURE__*/React.createElement(ReloadOutlined, null)))) : null, riddleVisible ? /*#__PURE__*/React.createElement("form", {
|
|
82
97
|
action: "//riddle.alibaba-inc.com/riddles/define",
|
|
83
98
|
method: "POST",
|
|
84
99
|
target: "_blank"
|
|
@@ -88,7 +103,7 @@ export var Toolbar = function Toolbar(_ref) {
|
|
|
88
103
|
value: JSON.stringify(riddlePrefillConfig)
|
|
89
104
|
}), /*#__PURE__*/React.createElement(Tooltip, {
|
|
90
105
|
title: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
91
|
-
id: "
|
|
106
|
+
id: "ai.toolbar.open.riddle"
|
|
92
107
|
})
|
|
93
108
|
}, /*#__PURE__*/React.createElement("input", {
|
|
94
109
|
type: "submit",
|
|
@@ -96,33 +111,14 @@ export var Toolbar = function Toolbar(_ref) {
|
|
|
96
111
|
className: styles.riddle
|
|
97
112
|
}))) : null, /*#__PURE__*/React.createElement(Tooltip, {
|
|
98
113
|
title: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
99
|
-
id: "
|
|
114
|
+
id: "ai.toolbar.open.stackblitz"
|
|
100
115
|
})
|
|
101
116
|
}, /*#__PURE__*/React.createElement(ThunderboltOutlined, {
|
|
102
117
|
className: styles.stackblitz,
|
|
103
118
|
onClick: function onClick() {
|
|
104
119
|
stackblitzSdk.openProject(stackblitzPrefillConfig);
|
|
105
120
|
}
|
|
106
|
-
})), /*#__PURE__*/React.createElement(
|
|
107
|
-
title: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
108
|
-
id: "\u5728 CodeSandbox \u4E2D\u6253\u5F00"
|
|
109
|
-
})
|
|
110
|
-
}, /*#__PURE__*/React.createElement("form", {
|
|
111
|
-
action: "https://codesandbox.io/api/v1/sandboxes/define",
|
|
112
|
-
method: "POST",
|
|
113
|
-
target: "_blank"
|
|
114
|
-
}, /*#__PURE__*/React.createElement("input", {
|
|
115
|
-
type: "hidden",
|
|
116
|
-
name: "parameters",
|
|
117
|
-
value: getParameters(codeSandboxConfig)
|
|
118
|
-
}), /*#__PURE__*/React.createElement("button", {
|
|
119
|
-
type: "submit",
|
|
120
|
-
className: styles.codesandbox
|
|
121
|
-
}, /*#__PURE__*/React.createElement(CodeSandboxOutlined, {
|
|
122
|
-
style: {
|
|
123
|
-
marginLeft: 8
|
|
124
|
-
}
|
|
125
|
-
})))), /*#__PURE__*/React.createElement(Paragraph, {
|
|
121
|
+
})), /*#__PURE__*/React.createElement(Paragraph, {
|
|
126
122
|
copyable: {
|
|
127
123
|
text: sourceCode
|
|
128
124
|
},
|
|
@@ -131,7 +127,7 @@ export var Toolbar = function Toolbar(_ref) {
|
|
|
131
127
|
}
|
|
132
128
|
}), /*#__PURE__*/React.createElement(Tooltip, {
|
|
133
129
|
title: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
134
|
-
id: "
|
|
130
|
+
id: "ai.toolbar.execute"
|
|
135
131
|
})
|
|
136
132
|
}, /*#__PURE__*/React.createElement(PlayCircleOutlined, {
|
|
137
133
|
onClick: onExecuteCode,
|
|
@@ -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 { 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 } 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';
|
|
@@ -25,6 +25,8 @@ import Loading from "dumi/theme/slots/Loading";
|
|
|
25
25
|
import styles from "./index.module.less";
|
|
26
26
|
import { EDITOR_TABS, Toolbar } from "./Toolbar";
|
|
27
27
|
import { compile, execute, replaceInsertCss } from "./utils";
|
|
28
|
+
import MsgBox from "../../pages/AIPlayground/components/MsgBox";
|
|
29
|
+
import { ClearOutlined } from '@ant-design/icons';
|
|
28
30
|
loader.config({
|
|
29
31
|
'vs/nls': {
|
|
30
32
|
availableLanguages: {
|
|
@@ -56,10 +58,15 @@ var CodeEditor = function CodeEditor(_ref) {
|
|
|
56
58
|
_ref$onError = _ref.onError,
|
|
57
59
|
onError = _ref$onError === void 0 ? noop : _ref$onError,
|
|
58
60
|
_ref$onFullscreen = _ref.onFullscreen,
|
|
59
|
-
onFullscreen = _ref$onFullscreen === void 0 ? noop : _ref$onFullscreen
|
|
61
|
+
onFullscreen = _ref$onFullscreen === void 0 ? noop : _ref$onFullscreen,
|
|
62
|
+
_ref$showAI = _ref.showAI,
|
|
63
|
+
showAI = _ref$showAI === void 0 ? true : _ref$showAI,
|
|
64
|
+
style = _ref.style;
|
|
65
|
+
var umiLocation = useLocation();
|
|
60
66
|
var locale = useLocale();
|
|
61
67
|
var _useSiteData = useSiteData(),
|
|
62
68
|
themeConfig = _useSiteData.themeConfig;
|
|
69
|
+
var intl = useIntl();
|
|
63
70
|
var _themeConfig$es = themeConfig.es5,
|
|
64
71
|
es5 = _themeConfig$es === void 0 ? true : _themeConfig$es,
|
|
65
72
|
_themeConfig$showSpec = themeConfig.showSpecTab,
|
|
@@ -100,6 +107,14 @@ var CodeEditor = function CodeEditor(_ref) {
|
|
|
100
107
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
101
108
|
currentEditorTab = _useState12[0],
|
|
102
109
|
setCurrentEditorTab = _useState12[1];
|
|
110
|
+
var _useState13 = useState(false),
|
|
111
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
112
|
+
showAIDrawer = _useState14[0],
|
|
113
|
+
setShowAIDrawer = _useState14[1];
|
|
114
|
+
var _useState15 = useState("_"),
|
|
115
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
116
|
+
msgBoxKey = _useState16[0],
|
|
117
|
+
setMsgBoxKey = _useState16[1];
|
|
103
118
|
var containerId = "playgroundScriptContainer_".concat(exampleId);
|
|
104
119
|
|
|
105
120
|
// 出发 auto resize
|
|
@@ -275,6 +290,7 @@ var CodeEditor = function CodeEditor(_ref) {
|
|
|
275
290
|
// 用于更新当前 example 的 spec 和 data
|
|
276
291
|
useEffect(function () {
|
|
277
292
|
setCurrentEditorTab(EDITOR_TABS.JAVASCRIPT);
|
|
293
|
+
setShowAIDrawer(false);
|
|
278
294
|
}, [exampleId]);
|
|
279
295
|
|
|
280
296
|
// hook 用户的数据
|
|
@@ -377,8 +393,15 @@ var CodeEditor = function CodeEditor(_ref) {
|
|
|
377
393
|
return null;
|
|
378
394
|
}
|
|
379
395
|
};
|
|
396
|
+
var onClickAI = function onClickAI() {
|
|
397
|
+
setShowAIDrawer(true);
|
|
398
|
+
};
|
|
399
|
+
var onReload = function onReload() {
|
|
400
|
+
setCode(source);
|
|
401
|
+
};
|
|
380
402
|
return /*#__PURE__*/React.createElement("div", {
|
|
381
|
-
className: styles.editor
|
|
403
|
+
className: styles.editor,
|
|
404
|
+
style: style
|
|
382
405
|
}, /*#__PURE__*/React.createElement(Toolbar, {
|
|
383
406
|
fileExtension: fileExtension,
|
|
384
407
|
sourceCode: code,
|
|
@@ -393,6 +416,9 @@ var CodeEditor = function CodeEditor(_ref) {
|
|
|
393
416
|
},
|
|
394
417
|
onEditorTabChange: onTabChange,
|
|
395
418
|
onToggleFullscreen: onFullscreen,
|
|
419
|
+
onClickAI: onClickAI,
|
|
420
|
+
showAI: showAI,
|
|
421
|
+
onReload: onReload,
|
|
396
422
|
slots: {
|
|
397
423
|
Spec: /*#__PURE__*/React.createElement("span", {
|
|
398
424
|
style: {
|
|
@@ -444,7 +470,43 @@ var CodeEditor = function CodeEditor(_ref) {
|
|
|
444
470
|
onMount: function onMount(editor) {
|
|
445
471
|
monacoRef.current = editor;
|
|
446
472
|
}
|
|
447
|
-
})
|
|
473
|
+
}), /*#__PURE__*/React.createElement(Drawer, {
|
|
474
|
+
closable: true,
|
|
475
|
+
open: showAIDrawer,
|
|
476
|
+
getContainer: false,
|
|
477
|
+
onClose: function onClose() {
|
|
478
|
+
return setShowAIDrawer(false);
|
|
479
|
+
},
|
|
480
|
+
rootClassName: styles.drawer,
|
|
481
|
+
width: '80%',
|
|
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),
|
|
495
|
+
simple: true,
|
|
496
|
+
messages: [{
|
|
497
|
+
id: crypto.randomUUID(),
|
|
498
|
+
role: 'assistant',
|
|
499
|
+
content: intl.formatMessage({
|
|
500
|
+
id: 'ai.assistant.editor.intro'
|
|
501
|
+
}),
|
|
502
|
+
createdAt: Date.now()
|
|
503
|
+
}],
|
|
504
|
+
context: valueOf(tab),
|
|
505
|
+
onCodegen: function onCodegen(codeBlock) {
|
|
506
|
+
setCode(codeBlock);
|
|
507
|
+
},
|
|
508
|
+
title: title
|
|
509
|
+
})));
|
|
448
510
|
}));
|
|
449
511
|
};
|
|
450
512
|
export default CodeEditor;
|
|
@@ -9,3 +9,27 @@
|
|
|
9
9
|
width: 100%;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
+
|
|
13
|
+
.drawer{
|
|
14
|
+
margin-top: 36px;
|
|
15
|
+
|
|
16
|
+
:global {
|
|
17
|
+
.ant-drawer-content {
|
|
18
|
+
background: #f8f9fc;
|
|
19
|
+
|
|
20
|
+
div.ant-drawer-header {
|
|
21
|
+
padding-bottom: unset;
|
|
22
|
+
border-bottom: unset;
|
|
23
|
+
|
|
24
|
+
.ant-drawer-header-title {
|
|
25
|
+
flex: unset;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.ant-drawer-body{
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -75,7 +75,8 @@ export function getStackblitzConfig(title, sourceCode, fileExtension, deps, devD
|
|
|
75
75
|
return {
|
|
76
76
|
title: title || '',
|
|
77
77
|
description: '',
|
|
78
|
-
|
|
78
|
+
// https://developer.stackblitz.com/platform/api/javascript-sdk-options#projecttemplate
|
|
79
|
+
template: playground.template || 'typescript',
|
|
79
80
|
dependencies: deps,
|
|
80
81
|
files: _defineProperty(_defineProperty({}, "index.".concat(fileExtension.startsWith('ts') ? 'ts' : 'js'), sourceCode), 'index.html', playground.container || '<div id="container" />')
|
|
81
82
|
};
|
|
@@ -32,7 +32,11 @@ 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,
|
|
38
|
+
_ref$showEditor = _ref.showEditor,
|
|
39
|
+
showEditor = _ref$showEditor === void 0 ? true : _ref$showEditor;
|
|
36
40
|
var demoInfo = getDemoInfo(exampleTopics, topic, example, demo);
|
|
37
41
|
|
|
38
42
|
// 找不到,啥也别干了,404 页面
|
|
@@ -59,18 +63,13 @@ var CodeRunner = function CodeRunner(_ref) {
|
|
|
59
63
|
githubUrl: githubUrl
|
|
60
64
|
});
|
|
61
65
|
var exampleId = "".concat(topic, "_").concat(example, "_").concat(demo);
|
|
62
|
-
|
|
63
|
-
fallback: null
|
|
64
|
-
}, /*#__PURE__*/React.createElement(SplitPane, {
|
|
65
|
-
split: "vertical",
|
|
66
|
-
defaultSize: "".concat((1 - size) * 100, "%"),
|
|
67
|
-
minSize: 100
|
|
68
|
-
}, /*#__PURE__*/React.createElement(CodePreview, {
|
|
66
|
+
var codePreview = /*#__PURE__*/React.createElement(CodePreview, {
|
|
69
67
|
exampleId: exampleId,
|
|
70
68
|
error: error,
|
|
71
69
|
header: header,
|
|
72
70
|
isPlayground: isPlayground
|
|
73
|
-
})
|
|
71
|
+
});
|
|
72
|
+
var codeEditor = /*#__PURE__*/React.createElement(ClientOnly, null, /*#__PURE__*/React.createElement(CodeEditor, {
|
|
74
73
|
exampleId: exampleId,
|
|
75
74
|
source: source,
|
|
76
75
|
relativePath: relativePath,
|
|
@@ -79,7 +78,21 @@ var CodeRunner = function CodeRunner(_ref) {
|
|
|
79
78
|
onFullscreen: setFullscreen,
|
|
80
79
|
onDestroy: noop,
|
|
81
80
|
onReady: noop,
|
|
82
|
-
playground: playground
|
|
83
|
-
|
|
81
|
+
playground: playground,
|
|
82
|
+
title: ic(title),
|
|
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));
|
|
84
97
|
};
|
|
85
98
|
export default CodeRunner;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Link, useLocale } from 'dumi';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { ic } from "
|
|
3
|
+
import { ic } from "../hooks";
|
|
4
4
|
import styles from "./News.module.less";
|
|
5
5
|
var numberImages = ['https://gw.alipayobjects.com/zos/antfincdn/IqREAm36K7/1.png', 'https://gw.alipayobjects.com/zos/antfincdn/3fG1Iqjfnz/2.png'];
|
|
6
6
|
export var News = function News(_ref) {
|