@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
|
@@ -0,0 +1,42 @@
|
|
|
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; }
|
|
7
|
+
import { Dropdown, Space } from 'antd';
|
|
8
|
+
import { useIntl } from 'dumi';
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { useSnapshot } from 'valtio';
|
|
11
|
+
import { AIChatStore } from "../../../../model/AIChat";
|
|
12
|
+
import { AIModeMeta } from "../../constant";
|
|
13
|
+
export function ModeSelectorDropdown() {
|
|
14
|
+
var _useIntl = useIntl(),
|
|
15
|
+
formatMessage = _useIntl.formatMessage;
|
|
16
|
+
var snap = useSnapshot(AIChatStore);
|
|
17
|
+
var items = Object.entries(AIModeMeta).map(function (_ref) {
|
|
18
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
19
|
+
key = _ref2[0],
|
|
20
|
+
value = _ref2[1];
|
|
21
|
+
return {
|
|
22
|
+
key: key,
|
|
23
|
+
label: formatMessage({
|
|
24
|
+
id: value.shortName
|
|
25
|
+
}),
|
|
26
|
+
icon: value.icon,
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
onClick: function onClick() {
|
|
29
|
+
return AIChatStore.mode = key;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
return /*#__PURE__*/React.createElement(Dropdown, {
|
|
34
|
+
menu: {
|
|
35
|
+
items: items
|
|
36
|
+
}
|
|
37
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
38
|
+
type: "button"
|
|
39
|
+
}, /*#__PURE__*/React.createElement("a", null, /*#__PURE__*/React.createElement(Space, null, AIModeMeta[snap.mode].icon, formatMessage({
|
|
40
|
+
id: AIModeMeta[snap.mode].shortName
|
|
41
|
+
})))));
|
|
42
|
+
}
|
|
@@ -21,11 +21,10 @@
|
|
|
21
21
|
display: flex;
|
|
22
22
|
flex-direction: row;
|
|
23
23
|
gap: 6px;
|
|
24
|
-
|
|
25
24
|
backdrop-filter: blur(12px);
|
|
26
25
|
padding: 4px;
|
|
27
26
|
border-radius: 26px;
|
|
28
|
-
box-shadow: inset 1px -1px 0 0 rgba(255, 255, 255,
|
|
27
|
+
box-shadow: inset 1px -1px 0 0 rgba(255, 255, 255, 89%);
|
|
29
28
|
|
|
30
29
|
&::before {
|
|
31
30
|
border-radius: 26px;
|
|
@@ -40,12 +39,12 @@
|
|
|
40
39
|
opacity: 0.75;
|
|
41
40
|
background-image: linear-gradient(
|
|
42
41
|
90deg,
|
|
43
|
-
rgba(255, 255, 255,
|
|
44
|
-
rgba(217, 217, 217,
|
|
45
|
-
rgba(29, 33, 41, 0) 100%
|
|
42
|
+
rgba(255, 255, 255, 2%) 0%,
|
|
43
|
+
rgba(217, 217, 217, 6%) 50%,
|
|
44
|
+
rgba(29, 33, 41, 0%) 100%
|
|
46
45
|
);
|
|
47
|
-
box-shadow: inset 1px -1px 0 0 rgba(255, 255, 255,
|
|
48
|
-
background: rgba(255, 255, 255,
|
|
46
|
+
box-shadow: inset 1px -1px 0 0 rgba(255, 255, 255, 89%);
|
|
47
|
+
background: rgba(255, 255, 255, 50%);
|
|
49
48
|
}
|
|
50
49
|
|
|
51
50
|
.switchBtn {
|
|
@@ -53,7 +52,6 @@
|
|
|
53
52
|
align-items: center;
|
|
54
53
|
justify-content: center;
|
|
55
54
|
gap: 8px;
|
|
56
|
-
|
|
57
55
|
width: 120px;
|
|
58
56
|
height: 38px;
|
|
59
57
|
cursor: pointer;
|
|
@@ -68,42 +66,48 @@
|
|
|
68
66
|
&.active {
|
|
69
67
|
color: #1d2129;
|
|
70
68
|
font-weight: 500;
|
|
71
|
-
|
|
72
|
-
background: #ffffff;
|
|
69
|
+
background: #fff;
|
|
73
70
|
border-color: #eeeef0;
|
|
74
|
-
box-shadow: 0 0 4px 0 rgba(0, 0, 0,
|
|
71
|
+
box-shadow: 0 0 4px 0 rgba(0, 0, 0, 8%);
|
|
75
72
|
}
|
|
76
73
|
}
|
|
77
74
|
}
|
|
78
75
|
|
|
79
76
|
.datasetSelectorModal {
|
|
80
|
-
top:
|
|
81
|
-
padding-bottom:
|
|
77
|
+
top: 0;
|
|
78
|
+
padding-bottom: 0;
|
|
82
79
|
|
|
83
80
|
.listItemContent {
|
|
84
81
|
cursor: pointer;
|
|
85
82
|
border: none;
|
|
86
83
|
line-height: 22px;
|
|
84
|
+
|
|
87
85
|
&.disabled {
|
|
88
86
|
color: #86909c;
|
|
89
87
|
cursor: not-allowed;
|
|
90
88
|
}
|
|
89
|
+
|
|
91
90
|
&:hover {
|
|
92
91
|
background: #1677ff1a;
|
|
93
92
|
}
|
|
93
|
+
|
|
94
94
|
&:not(.disabled):hover {
|
|
95
95
|
color: #1677ff;
|
|
96
96
|
}
|
|
97
|
+
|
|
97
98
|
padding: 7px 16px 7px 7px;
|
|
99
|
+
|
|
98
100
|
&--multiline {
|
|
99
101
|
padding: 4px 16px 4px 7px;
|
|
100
102
|
}
|
|
101
103
|
}
|
|
104
|
+
|
|
102
105
|
.selected {
|
|
103
106
|
background: #1677ff1a;
|
|
104
107
|
font-weight: 500;
|
|
105
108
|
color: #1677ff;
|
|
106
109
|
}
|
|
110
|
+
|
|
107
111
|
.nameWrapper {
|
|
108
112
|
flex: 1 1;
|
|
109
113
|
min-width: 0;
|
|
@@ -122,20 +126,24 @@
|
|
|
122
126
|
min-width: 0;
|
|
123
127
|
}
|
|
124
128
|
}
|
|
129
|
+
|
|
125
130
|
.desc {
|
|
126
131
|
font-size: 12px;
|
|
127
132
|
color: #86909ccc;
|
|
128
133
|
line-height: 22px;
|
|
129
134
|
}
|
|
130
135
|
}
|
|
136
|
+
|
|
131
137
|
.list {
|
|
132
138
|
background: #ffffffdb;
|
|
133
|
-
padding: 10px 18px 18px
|
|
139
|
+
padding: 10px 18px 18px;
|
|
140
|
+
|
|
134
141
|
:global {
|
|
135
142
|
.ant-input-affix-wrapper {
|
|
136
143
|
margin-bottom: 8px;
|
|
137
144
|
border-radius: 6px;
|
|
138
145
|
color: #5a607f65;
|
|
146
|
+
|
|
139
147
|
.ant-input-prefix {
|
|
140
148
|
margin-right: 8px;
|
|
141
149
|
}
|
|
@@ -148,13 +156,16 @@
|
|
|
148
156
|
.ant-alert-info .ant-alert-icon {
|
|
149
157
|
color: #1677ff;
|
|
150
158
|
}
|
|
159
|
+
|
|
151
160
|
.ant-modal-footer {
|
|
152
161
|
button {
|
|
153
162
|
box-shadow: none;
|
|
163
|
+
|
|
154
164
|
&.ant-btn-primary {
|
|
155
165
|
color: white;
|
|
156
166
|
background: #1677ff;
|
|
157
167
|
}
|
|
168
|
+
|
|
158
169
|
background: none;
|
|
159
170
|
border: none;
|
|
160
171
|
border-radius: 6px;
|
|
@@ -162,15 +173,18 @@
|
|
|
162
173
|
width: 60px;
|
|
163
174
|
height: 32px;
|
|
164
175
|
color: #4e5969e6;
|
|
176
|
+
|
|
165
177
|
&:disabled {
|
|
166
178
|
background: #4e59693c;
|
|
167
179
|
color: white;
|
|
168
180
|
}
|
|
169
181
|
}
|
|
170
182
|
}
|
|
183
|
+
|
|
171
184
|
.ant-modal-close-x {
|
|
172
185
|
display: none;
|
|
173
186
|
}
|
|
187
|
+
|
|
174
188
|
.ant-modal-body {
|
|
175
189
|
padding: 0;
|
|
176
190
|
}
|
|
@@ -178,21 +192,26 @@
|
|
|
178
192
|
.ant-modal-header {
|
|
179
193
|
border-radius: 8px 8px 0 0;
|
|
180
194
|
}
|
|
195
|
+
|
|
181
196
|
.ant-modal-content {
|
|
182
197
|
border-radius: 8px;
|
|
183
198
|
}
|
|
199
|
+
|
|
184
200
|
.ant-modal-content {
|
|
185
201
|
background-color: rgb(251, 252, 253);
|
|
186
202
|
}
|
|
203
|
+
|
|
187
204
|
.ant-tabs-nav {
|
|
188
205
|
padding-left: 18px;
|
|
189
206
|
padding-right: 18px;
|
|
190
207
|
margin-bottom: 0;
|
|
191
208
|
}
|
|
209
|
+
|
|
192
210
|
.ant-tabs-tab {
|
|
193
211
|
font-size: 14px;
|
|
194
|
-
padding: 14px 0 13px
|
|
212
|
+
padding: 14px 0 13px;
|
|
195
213
|
}
|
|
214
|
+
|
|
196
215
|
.ant-alert {
|
|
197
216
|
padding: 4px 15px;
|
|
198
217
|
}
|
|
@@ -214,7 +233,6 @@
|
|
|
214
233
|
white-space: nowrap;
|
|
215
234
|
text-overflow: ellipsis;
|
|
216
235
|
overflow: hidden;
|
|
217
|
-
|
|
218
236
|
font-size: 14px;
|
|
219
237
|
color: #5a607fe0;
|
|
220
238
|
}
|
|
@@ -230,17 +248,17 @@
|
|
|
230
248
|
.switchBtn {
|
|
231
249
|
width: 100px;
|
|
232
250
|
border-radius: 12px;
|
|
233
|
-
background: #
|
|
251
|
+
background: #fff;
|
|
234
252
|
border: 1px solid #5a607fe0;
|
|
235
253
|
opacity: 0.4;
|
|
236
|
-
box-shadow:
|
|
254
|
+
box-shadow: 0 3px 12px 0 #0000000a;
|
|
237
255
|
font-size: 14px;
|
|
238
256
|
color: #86909c;
|
|
239
257
|
line-height: 24px;
|
|
240
258
|
height: 24px;
|
|
241
259
|
|
|
242
260
|
&.active {
|
|
243
|
-
background: #
|
|
261
|
+
background: #fff;
|
|
244
262
|
border: 1px solid #2d84ff;
|
|
245
263
|
color: #1677ff;
|
|
246
264
|
opacity: 1;
|
|
@@ -261,12 +279,11 @@
|
|
|
261
279
|
border-radius: 4px;
|
|
262
280
|
margin-left: 8px;
|
|
263
281
|
flex-shrink: 0;
|
|
264
|
-
|
|
265
282
|
color: #86909c;
|
|
266
|
-
background: rgba(0, 0, 0,
|
|
283
|
+
background: rgba(0, 0, 0, 4%);
|
|
267
284
|
|
|
268
285
|
&.primary {
|
|
269
286
|
color: #f68b02;
|
|
270
|
-
background: rgba(246, 144, 61,
|
|
287
|
+
background: rgba(246, 144, 61, 10%);
|
|
271
288
|
}
|
|
272
289
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Dropdown } from "antd";
|
|
3
|
-
import { useProducts } from "../../../../../hooks/useProducts";
|
|
4
|
-
import { useLocale,
|
|
3
|
+
import { useAntVConfig, useProducts } from "../../../../../hooks/useProducts";
|
|
4
|
+
import { useLocale, FormattedMessage } from "dumi";
|
|
5
5
|
import styles from "./index.module.less";
|
|
6
6
|
export function ChooseLib(props) {
|
|
7
7
|
var _data$find;
|
|
@@ -15,11 +15,20 @@ export function ChooseLib(props) {
|
|
|
15
15
|
var _useProducts = useProducts(),
|
|
16
16
|
_useProducts$data = _useProducts.data,
|
|
17
17
|
data = _useProducts$data === void 0 ? [] : _useProducts$data;
|
|
18
|
+
var _useAntVConfig = useAntVConfig(),
|
|
19
|
+
_useAntVConfig$data = _useAntVConfig.data,
|
|
20
|
+
_useAntVConfig$data2 = _useAntVConfig$data === void 0 ? {
|
|
21
|
+
library: []
|
|
22
|
+
} : _useAntVConfig$data,
|
|
23
|
+
_useAntVConfig$data2$ = _useAntVConfig$data2.library,
|
|
24
|
+
library = _useAntVConfig$data2$ === void 0 ? [] : _useAntVConfig$data2$;
|
|
18
25
|
var onSelect = function onSelect(key) {
|
|
19
26
|
onChange === null || onChange === void 0 || onChange(key);
|
|
20
27
|
};
|
|
21
28
|
var items = data.filter(function (item) {
|
|
22
|
-
return item.lang === lang &&
|
|
29
|
+
return item.lang === lang && library.map(function (l) {
|
|
30
|
+
return l.toUpperCase();
|
|
31
|
+
}).includes(item.title);
|
|
23
32
|
}).map(function (item) {
|
|
24
33
|
return {
|
|
25
34
|
key: item.title,
|
|
@@ -35,7 +44,6 @@ export function ChooseLib(props) {
|
|
|
35
44
|
}
|
|
36
45
|
};
|
|
37
46
|
});
|
|
38
|
-
var intl = useIntl();
|
|
39
47
|
return /*#__PURE__*/React.createElement(Dropdown, {
|
|
40
48
|
menu: {
|
|
41
49
|
items: items
|
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
align-items: center;
|
|
4
4
|
height: 32px;
|
|
5
5
|
position: relative;
|
|
6
|
-
|
|
7
6
|
padding-left: 8px;
|
|
8
7
|
padding-right: 12px;
|
|
9
|
-
background: rgba(212, 215, 219,
|
|
10
|
-
border: 1px solid rgba(222, 226, 241,
|
|
8
|
+
background: rgba(212, 215, 219, 40%);
|
|
9
|
+
border: 1px solid rgba(222, 226, 241, 70%);
|
|
11
10
|
border-radius: 8px;
|
|
12
11
|
|
|
13
12
|
img {
|
|
@@ -24,6 +23,7 @@
|
|
|
24
23
|
text-overflow: ellipsis;
|
|
25
24
|
white-space: nowrap;
|
|
26
25
|
}
|
|
26
|
+
|
|
27
27
|
.desc {
|
|
28
28
|
margin-left: 16px;
|
|
29
29
|
font-size: 10px;
|
|
@@ -10,23 +10,24 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
10
10
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
11
|
import { DatasourceCard } from "./DatasourceCard";
|
|
12
12
|
import { useEventListener } from 'ahooks';
|
|
13
|
-
import { Tooltip, Upload } from 'antd';
|
|
14
13
|
import classnames from 'classnames';
|
|
15
14
|
import _ from 'lodash';
|
|
16
|
-
import React, { useState } from 'react';
|
|
15
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
17
16
|
import styles from "./index.module.less";
|
|
18
17
|
import { SendButton } from "./SendButton";
|
|
19
|
-
import { AIMode, FileIcons } from "../../constant";
|
|
20
18
|
import { ChooseLib } from "./ChooseLib";
|
|
21
19
|
import { useSiteData, useIntl } from 'dumi';
|
|
22
20
|
import { ic } from "../../../../slots/hooks";
|
|
23
21
|
import { useTypewriter } from "../../../../hooks/useTypewriter";
|
|
24
|
-
import {
|
|
22
|
+
import { authStore, showLoginModal } from "../../../../model/auth";
|
|
23
|
+
import { useSnapshot } from "valtio";
|
|
24
|
+
import { AIChatStore } from "../../../../model/AIChat";
|
|
25
|
+
import { ModeSelectorDropdown } from "../ModeSelector/ModeSelectorDropdown";
|
|
25
26
|
var PLACEHOLDER = {
|
|
26
27
|
implement: 'ai.placeholder.implement',
|
|
27
28
|
solve: 'ai.placeholder.solve'
|
|
28
29
|
};
|
|
29
|
-
|
|
30
|
+
export var PromptTextarea = /*#__PURE__*/React.memo(function PromptTextareaInner(props) {
|
|
30
31
|
var value = props.value,
|
|
31
32
|
size = props.size,
|
|
32
33
|
_onChange = props.onChange,
|
|
@@ -34,14 +35,22 @@ function PromptTextarea(props) {
|
|
|
34
35
|
onConfirm = props.onConfirm,
|
|
35
36
|
onCancel = props.onCancel,
|
|
36
37
|
loading = props.loading,
|
|
37
|
-
mode = props.mode,
|
|
38
|
-
lib = props.lib,
|
|
39
|
-
onLibChange = props.onLibChange,
|
|
40
38
|
_props$showAction = props.showAction,
|
|
41
|
-
showAction = _props$showAction === void 0 ? true : _props$showAction
|
|
39
|
+
showAction = _props$showAction === void 0 ? true : _props$showAction,
|
|
40
|
+
_props$showModeSelect = props.showModeSelector,
|
|
41
|
+
showModeSelector = _props$showModeSelect === void 0 ? false : _props$showModeSelect;
|
|
42
|
+
var snap = useSnapshot(AIChatStore);
|
|
43
|
+
var authSnap = useSnapshot(authStore);
|
|
42
44
|
var _useIntl = useIntl(),
|
|
43
45
|
formatMessage = _useIntl.formatMessage;
|
|
44
|
-
|
|
46
|
+
var textareaRef = useRef(null);
|
|
47
|
+
var _useSiteData = useSiteData(),
|
|
48
|
+
themeConfig = _useSiteData.themeConfig;
|
|
49
|
+
useEffect(function () {
|
|
50
|
+
if (!themeConfig.isAntVSite && !snap.lib) {
|
|
51
|
+
AIChatStore.lib = themeConfig.title;
|
|
52
|
+
}
|
|
53
|
+
}, [themeConfig.isAntVSite, themeConfig.title]);
|
|
45
54
|
// 将fileMeta状态移到组件内部管理
|
|
46
55
|
var _useState = useState(null),
|
|
47
56
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -54,8 +63,6 @@ function PromptTextarea(props) {
|
|
|
54
63
|
focus = _useState4[0],
|
|
55
64
|
setFocus = _useState4[1];
|
|
56
65
|
var isCompact = size === 'compact';
|
|
57
|
-
var _useSiteData = useSiteData(),
|
|
58
|
-
themeConfig = _useSiteData.themeConfig;
|
|
59
66
|
var typedPlaceholder = useTypewriter({
|
|
60
67
|
texts: [formatMessage({
|
|
61
68
|
id: 'ai.placeholder.whatis'
|
|
@@ -92,11 +99,18 @@ function PromptTextarea(props) {
|
|
|
92
99
|
}
|
|
93
100
|
var datasourceNode = renderDatasourceCard();
|
|
94
101
|
var promptTextValid = Boolean(value);
|
|
95
|
-
var
|
|
102
|
+
var pureSend = function pureSend() {
|
|
96
103
|
if (promptTextValid) {
|
|
97
104
|
onConfirm === null || onConfirm === void 0 || onConfirm();
|
|
98
105
|
}
|
|
99
106
|
};
|
|
107
|
+
var send = function send() {
|
|
108
|
+
if (!authSnap.isAuthenticated) {
|
|
109
|
+
showLoginModal(pureSend);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
pureSend();
|
|
113
|
+
};
|
|
100
114
|
useEventListener('keydown', function (event) {
|
|
101
115
|
if (event.key === 'Enter') {
|
|
102
116
|
// 不区分 textarea 是否聚焦
|
|
@@ -105,6 +119,8 @@ function PromptTextarea(props) {
|
|
|
105
119
|
send(); // 触发自定义事件
|
|
106
120
|
}
|
|
107
121
|
}
|
|
122
|
+
}, {
|
|
123
|
+
target: textareaRef
|
|
108
124
|
});
|
|
109
125
|
return /*#__PURE__*/React.createElement("div", {
|
|
110
126
|
className: classnames(styles.container, _defineProperty(_defineProperty(_defineProperty({}, styles.active, focus), styles.compact, isCompact), styles.withDatasource, Boolean(datasourceNode))),
|
|
@@ -120,10 +136,11 @@ function PromptTextarea(props) {
|
|
|
120
136
|
},
|
|
121
137
|
id: "prompt-textarea",
|
|
122
138
|
className: classnames(styles.promptTextarea),
|
|
139
|
+
ref: textareaRef,
|
|
123
140
|
placeholder:
|
|
124
141
|
// (!isCompact && !themeConfig.isAntVSite && ic(themeConfig.metas.description)) ||
|
|
125
142
|
!isCompact && !themeConfig.isAntVSite ? typedPlaceholder : formatMessage({
|
|
126
|
-
id: _.get(PLACEHOLDER, mode, 'ai.placeholder.implement')
|
|
143
|
+
id: _.get(PLACEHOLDER, snap.mode, 'ai.placeholder.implement')
|
|
127
144
|
}),
|
|
128
145
|
value: value,
|
|
129
146
|
onChange: function onChange(evt) {
|
|
@@ -134,26 +151,12 @@ function PromptTextarea(props) {
|
|
|
134
151
|
}, /*#__PURE__*/React.createElement("div", {
|
|
135
152
|
className: styles.dataActions
|
|
136
153
|
}, showAction && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ChooseLib, {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
tooltipText: formatMessage({
|
|
144
|
-
id: 'ai.upload.tooltip'
|
|
145
|
-
})
|
|
146
|
-
}), /*#__PURE__*/React.createElement(Tooltip, {
|
|
147
|
-
title: isCompact ? formatMessage({
|
|
148
|
-
id: 'ai.upload.image'
|
|
149
|
-
}) : undefined
|
|
150
|
-
}, /*#__PURE__*/React.createElement(Upload, null, /*#__PURE__*/React.createElement("button", {
|
|
151
|
-
type: "button"
|
|
152
|
-
}, /*#__PURE__*/React.createElement("img", {
|
|
153
|
-
src: FileIcons.IMAGE
|
|
154
|
-
}), " ", !isCompact && formatMessage({
|
|
155
|
-
id: 'ai.upload.image'
|
|
156
|
-
}))))))), /*#__PURE__*/React.createElement("div", {
|
|
154
|
+
size: size,
|
|
155
|
+
value: snap.lib,
|
|
156
|
+
onChange: function onChange(s) {
|
|
157
|
+
return AIChatStore.lib = s;
|
|
158
|
+
}
|
|
159
|
+
})), showModeSelector && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ModeSelectorDropdown, null))), /*#__PURE__*/React.createElement("div", {
|
|
157
160
|
className: styles.actions
|
|
158
161
|
}, loading ? /*#__PURE__*/React.createElement("img", {
|
|
159
162
|
className: styles.actionBtn,
|
|
@@ -166,5 +169,4 @@ function PromptTextarea(props) {
|
|
|
166
169
|
id: 'ai.msgbox.send.tip'
|
|
167
170
|
}) : undefined
|
|
168
171
|
}))));
|
|
169
|
-
}
|
|
170
|
-
export { PromptTextarea };
|
|
172
|
+
});
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
padding: 16px;
|
|
8
8
|
gap: 16px;
|
|
9
9
|
transition: all 0.2s;
|
|
10
|
-
border: 1px solid rgba(134, 144, 156,
|
|
10
|
+
border: 1px solid rgba(134, 144, 156, 20%);
|
|
11
11
|
border-radius: 16px;
|
|
12
|
-
background: #
|
|
13
|
-
box-shadow: 8px 8px 20px
|
|
12
|
+
background: #fff9;
|
|
13
|
+
box-shadow: 8px 8px 20px 0 #0000000a, inset 1px -1px 0 0 #ffffffe3;
|
|
14
14
|
z-index: 10;
|
|
15
15
|
display: flex;
|
|
16
16
|
flex-direction: column;
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
|
|
53
53
|
&.btn-error {
|
|
54
54
|
color: #ff4d4f;
|
|
55
|
-
box-shadow: inset 1px -1px 0 0 rgba(255, 255, 255,
|
|
56
|
-
0 0 12px 0 rgba(250, 16, 16,
|
|
55
|
+
box-shadow: inset 1px -1px 0 0 rgba(255, 255, 255, 89%),
|
|
56
|
+
0 0 12px 0 rgba(250, 16, 16, 23%);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
.btn-icon,
|
|
@@ -75,9 +75,9 @@
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
&.active {
|
|
78
|
-
background: #
|
|
78
|
+
background: #fff9;
|
|
79
79
|
border: 1px solid #1677ff;
|
|
80
|
-
box-shadow:
|
|
80
|
+
box-shadow: 0 8px 20px 0 #1677ff29, inset 1px -1px 0 0 #ffffffe3;
|
|
81
81
|
|
|
82
82
|
.promptTextarea::placeholder {
|
|
83
83
|
color: transparent;
|
|
@@ -123,6 +123,6 @@
|
|
|
123
123
|
background: transparent;
|
|
124
124
|
|
|
125
125
|
&::placeholder {
|
|
126
|
-
color: rgba(122, 132, 153,
|
|
126
|
+
color: rgba(122, 132, 153, 85%);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
@@ -1,25 +1,28 @@
|
|
|
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); }
|
|
1
2
|
import { Popover } from 'antd';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import styles from "./card.module.less";
|
|
4
5
|
import { BarChartOutlined, QuestionCircleOutlined } from "@ant-design/icons";
|
|
5
6
|
import { AIMode, AIModeMeta, COLORS } from "../../constant";
|
|
6
|
-
import { FormattedMessage } from 'dumi';
|
|
7
|
+
import { FormattedMessage, useLocale } from 'dumi';
|
|
7
8
|
export var Card = function Card(_ref) {
|
|
8
9
|
var _AIModeMeta$tag;
|
|
9
10
|
var item = _ref.item,
|
|
10
|
-
index = _ref.index
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
index = _ref.index,
|
|
12
|
+
onClick = _ref.onClick;
|
|
13
|
+
var _item$query = item.query,
|
|
14
|
+
query = _item$query === void 0 ? {} : _item$query,
|
|
15
|
+
_item$description = item.description,
|
|
16
|
+
description = _item$description === void 0 ? {} : _item$description,
|
|
13
17
|
_item$imageUrls = item.imageUrls,
|
|
14
18
|
imageUrls = _item$imageUrls === void 0 ? [] : _item$imageUrls,
|
|
15
|
-
link = item.link,
|
|
16
19
|
tag = item.tag;
|
|
17
20
|
var style = COLORS[index];
|
|
21
|
+
var locale = useLocale();
|
|
22
|
+
var lang = locale.id === 'zh' ? 'zh' : 'en';
|
|
18
23
|
var handleClick = function handleClick(e) {
|
|
19
24
|
e.stopPropagation();
|
|
20
|
-
|
|
21
|
-
urlObj.hash = "";
|
|
22
|
-
window.open(urlObj.toString(), '_blank');
|
|
25
|
+
onClick === null || onClick === void 0 || onClick();
|
|
23
26
|
};
|
|
24
27
|
var popoverContent = /*#__PURE__*/React.createElement("div", {
|
|
25
28
|
className: styles.popoverContent
|
|
@@ -31,7 +34,7 @@ export var Card = function Card(_ref) {
|
|
|
31
34
|
id: "ai.recommend.card.caseName"
|
|
32
35
|
})), /*#__PURE__*/React.createElement("div", {
|
|
33
36
|
className: styles.popoverValue
|
|
34
|
-
}, query)), /*#__PURE__*/React.createElement("div", {
|
|
37
|
+
}, _typeof(query) === 'object' ? query[lang] : query)), /*#__PURE__*/React.createElement("div", {
|
|
35
38
|
className: styles.popoverItem
|
|
36
39
|
}, /*#__PURE__*/React.createElement("div", {
|
|
37
40
|
className: styles.popoverLabel
|
|
@@ -39,7 +42,7 @@ export var Card = function Card(_ref) {
|
|
|
39
42
|
id: "ai.recommend.card.description"
|
|
40
43
|
})), /*#__PURE__*/React.createElement("div", {
|
|
41
44
|
className: styles.popoverValue
|
|
42
|
-
}, description)));
|
|
45
|
+
}, _typeof(description) === 'object' ? description[lang] : description)));
|
|
43
46
|
return /*#__PURE__*/React.createElement(Popover, {
|
|
44
47
|
content: popoverContent,
|
|
45
48
|
placement: "top",
|
|
@@ -63,7 +66,7 @@ export var Card = function Card(_ref) {
|
|
|
63
66
|
id: ((_AIModeMeta$tag = AIModeMeta[tag]) === null || _AIModeMeta$tag === void 0 ? void 0 : _AIModeMeta$tag.name) || tag
|
|
64
67
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
65
68
|
className: styles.title
|
|
66
|
-
}, query), /*#__PURE__*/React.createElement("div", {
|
|
69
|
+
}, _typeof(query) === 'object' ? query[lang] : query), /*#__PURE__*/React.createElement("div", {
|
|
67
70
|
className: styles.imageContainer
|
|
68
71
|
}, imageUrls.slice(0, 2).map(function (item, idx) {
|
|
69
72
|
return /*#__PURE__*/React.createElement("img", {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
overflow: hidden;
|
|
9
9
|
position: relative;
|
|
10
10
|
aspect-ratio: 292 / 208;
|
|
11
|
-
background: rgba(22, 119, 255,
|
|
11
|
+
background: rgba(22, 119, 255, 6%);
|
|
12
12
|
|
|
13
13
|
.typeTag {
|
|
14
14
|
display: flex;
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
.popoverContent {
|
|
103
|
-
max-width:
|
|
103
|
+
max-width: 800px;
|
|
104
104
|
|
|
105
105
|
.popoverItem {
|
|
106
106
|
display: flex;
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
color: #1d2129e6;
|
|
113
113
|
line-height: 22px;
|
|
114
114
|
font-weight: 500;
|
|
115
|
-
min-width:
|
|
115
|
+
min-width: 80px;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
.popoverValue {
|