@antv/dumi-theme-antv 0.8.0-beta.1 → 0.8.0-beta.11
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/index.js +4 -1
- package/dist/components/AI/HomeDialog/ModeSelector/index.module.less +39 -22
- package/dist/components/AI/HomeDialog/PromptTextarea/ChooseLib/index.js +4 -2
- 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/Uploader/DataUploader.js +225 -0
- package/dist/components/AI/HomeDialog/PromptTextarea/index.js +74 -43
- package/dist/components/AI/HomeDialog/PromptTextarea/index.module.less +9 -8
- package/dist/components/AI/HomeDialog/RecommendCase/Card.js +13 -8
- package/dist/components/AI/HomeDialog/RecommendCase/card.module.less +1 -1
- package/dist/components/AI/HomeDialog/RecommendCase/index.js +46 -14
- package/dist/components/AI/HomeDialog/RecommendCase/index.module.less +3 -2
- package/dist/components/AI/HomeDialog/index.js +19 -17
- package/dist/components/AI/constant.js +2 -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/layouts/DocLayout.js +2 -1
- package/dist/layouts/GlobalLayout/index.js +10 -4
- package/dist/locales/en.json +125 -1
- package/dist/locales/zh.json +125 -1
- package/dist/model/AIChat.js +72 -8
- package/dist/model/auth.js +133 -0
- package/dist/pages/AIPlayground/components/ConversationsMenu/index.js +36 -12
- package/dist/pages/AIPlayground/components/ConversationsMenu/index.module.less +2 -0
- package/dist/pages/AIPlayground/components/MarkdownComponent/MarkdownCodeBlock.js +25 -11
- package/dist/pages/AIPlayground/components/MarkdownComponent/MarkdownCodeBlock.module.less +1 -2
- package/dist/pages/AIPlayground/components/MarkdownComponent/index.js +5 -2
- package/dist/pages/AIPlayground/components/MsgBox/index.js +202 -146
- 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 +2 -2
- package/dist/pages/AIPlayground/components/SessionLayout/index.module.less +4 -2
- package/dist/pages/AIPlayground/components/TaskBox/generateCode.js +7 -1
- package/dist/pages/AIPlayground/components/TaskBox/index.js +78 -55
- package/dist/pages/AIPlayground/components/TaskBox/index.module.less +1 -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/plugin/index.js +2 -2
- package/dist/slots/Banner/Notification.module.less +8 -8
- package/dist/slots/Banner/index.module.less +10 -9
- package/dist/slots/CodeEditor/Toolbar.js +15 -9
- package/dist/slots/CodeEditor/index.js +35 -12
- package/dist/slots/CodeEditor/index.module.less +3 -1
- package/dist/slots/CodePreview/index.module.less +0 -3
- package/dist/slots/CodeRunner/index.js +5 -2
- package/dist/slots/ContentTable/index.module.less +2 -1
- package/dist/slots/Detail/News.module.less +9 -9
- 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 +23 -8
- package/dist/slots/Header/Search/SearchResult.module.less +1 -0
- package/dist/slots/Header/index.js +72 -12
- 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/utils/env.js +37 -0
- package/dist/utils/index.js +7 -0
- package/dist/utils/request.js +42 -0
- package/package.json +7 -3
|
@@ -10,55 +10,86 @@ 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 { message, 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
|
-
import { useSiteData } from 'dumi';
|
|
19
|
+
import { useSiteData, useIntl } from 'dumi';
|
|
22
20
|
import { ic } from "../../../../slots/hooks";
|
|
23
21
|
import { useTypewriter } from "../../../../hooks/useTypewriter";
|
|
22
|
+
import { authStore, showLoginModal } from "../../../../model/auth";
|
|
23
|
+
import { useSnapshot } from "valtio";
|
|
24
|
+
import { AIChatStore } from "../../../../model/AIChat";
|
|
24
25
|
var PLACEHOLDER = {
|
|
25
|
-
implement: '
|
|
26
|
-
solve: '
|
|
26
|
+
implement: 'ai.placeholder.implement',
|
|
27
|
+
solve: 'ai.placeholder.solve'
|
|
27
28
|
};
|
|
28
|
-
var
|
|
29
|
-
function PromptTextarea(props) {
|
|
29
|
+
export var PromptTextarea = /*#__PURE__*/React.memo(function PromptTextareaInner(props) {
|
|
30
30
|
var value = props.value,
|
|
31
31
|
size = props.size,
|
|
32
32
|
_onChange = props.onChange,
|
|
33
|
+
onDataSummaryChange = props.onDataSummaryChange,
|
|
33
34
|
onConfirm = props.onConfirm,
|
|
34
35
|
onCancel = props.onCancel,
|
|
35
36
|
loading = props.loading,
|
|
36
|
-
fileMeta = props.fileMeta,
|
|
37
37
|
mode = props.mode,
|
|
38
|
-
lib = props.lib,
|
|
39
|
-
onLibChange = props.onLibChange,
|
|
40
38
|
_props$showAction = props.showAction,
|
|
41
39
|
showAction = _props$showAction === void 0 ? true : _props$showAction;
|
|
42
|
-
var
|
|
40
|
+
var snap = useSnapshot(AIChatStore);
|
|
41
|
+
var authSnap = useSnapshot(authStore);
|
|
42
|
+
var _useIntl = useIntl(),
|
|
43
|
+
formatMessage = _useIntl.formatMessage;
|
|
44
|
+
var textareaRef = useRef(null);
|
|
45
|
+
var _useSiteData = useSiteData(),
|
|
46
|
+
themeConfig = _useSiteData.themeConfig;
|
|
47
|
+
useEffect(function () {
|
|
48
|
+
if (!themeConfig.isAntVSite && !snap.lib) {
|
|
49
|
+
AIChatStore.lib = themeConfig.title;
|
|
50
|
+
}
|
|
51
|
+
}, [themeConfig.isAntVSite, themeConfig.title]);
|
|
52
|
+
// 将fileMeta状态移到组件内部管理
|
|
53
|
+
var _useState = useState(null),
|
|
43
54
|
_useState2 = _slicedToArray(_useState, 2),
|
|
44
|
-
|
|
45
|
-
|
|
55
|
+
fileMeta = _useState2[0],
|
|
56
|
+
setFileMeta = _useState2[1];
|
|
57
|
+
|
|
58
|
+
// ... 其他状态和hooks保持不变
|
|
46
59
|
var _useState3 = useState(false),
|
|
47
60
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
48
61
|
focus = _useState4[0],
|
|
49
62
|
setFocus = _useState4[1];
|
|
50
63
|
var isCompact = size === 'compact';
|
|
51
|
-
var _useSiteData = useSiteData(),
|
|
52
|
-
themeConfig = _useSiteData.themeConfig;
|
|
53
64
|
var typedPlaceholder = useTypewriter({
|
|
54
|
-
texts: [
|
|
65
|
+
texts: [formatMessage({
|
|
66
|
+
id: 'ai.placeholder.whatis'
|
|
67
|
+
}, {
|
|
68
|
+
title: themeConfig.title
|
|
69
|
+
}), ic(themeConfig.metas.description)]
|
|
55
70
|
});
|
|
71
|
+
|
|
72
|
+
// 处理DataUploader的回调
|
|
73
|
+
var handleDataAnalyzed = function handleDataAnalyzed(analyzedData) {
|
|
74
|
+
setFileMeta(analyzedData.fileMeta);
|
|
75
|
+
if (onDataSummaryChange) {
|
|
76
|
+
onDataSummaryChange(analyzedData.dataSummary);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
56
79
|
function renderDatasourceCard() {
|
|
57
80
|
if (((fileMeta === null || fileMeta === void 0 ? void 0 : fileMeta.type) === 'FILE' || (fileMeta === null || fileMeta === void 0 ? void 0 : fileMeta.type) === 'IMAGE') && fileMeta !== null && fileMeta !== void 0 && fileMeta.fileName) {
|
|
81
|
+
// 当点击DatasourceCard的关闭按钮时,应该清空状态
|
|
82
|
+
var handleClose = function handleClose() {
|
|
83
|
+
setFileMeta(null);
|
|
84
|
+
if (onDataSummaryChange) {
|
|
85
|
+
onDataSummaryChange('');
|
|
86
|
+
}
|
|
87
|
+
};
|
|
58
88
|
return /*#__PURE__*/React.createElement(DatasourceCard, {
|
|
59
89
|
type: fileMeta.type,
|
|
60
90
|
title: fileMeta.fileName,
|
|
61
|
-
desc: fileMeta.fileSize
|
|
91
|
+
desc: fileMeta.fileSize,
|
|
92
|
+
onDelete: handleClose
|
|
62
93
|
});
|
|
63
94
|
} else {
|
|
64
95
|
return null;
|
|
@@ -66,14 +97,18 @@ function PromptTextarea(props) {
|
|
|
66
97
|
}
|
|
67
98
|
var datasourceNode = renderDatasourceCard();
|
|
68
99
|
var promptTextValid = Boolean(value);
|
|
69
|
-
var
|
|
70
|
-
if (
|
|
71
|
-
message.warning('请输入指令');
|
|
72
|
-
} else {
|
|
73
|
-
setShowError(false);
|
|
100
|
+
var pureSend = function pureSend() {
|
|
101
|
+
if (promptTextValid) {
|
|
74
102
|
onConfirm === null || onConfirm === void 0 || onConfirm();
|
|
75
103
|
}
|
|
76
104
|
};
|
|
105
|
+
var send = function send() {
|
|
106
|
+
if (!authSnap.isAuthenticated) {
|
|
107
|
+
showLoginModal(pureSend);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
pureSend();
|
|
111
|
+
};
|
|
77
112
|
useEventListener('keydown', function (event) {
|
|
78
113
|
if (event.key === 'Enter') {
|
|
79
114
|
// 不区分 textarea 是否聚焦
|
|
@@ -82,6 +117,8 @@ function PromptTextarea(props) {
|
|
|
82
117
|
send(); // 触发自定义事件
|
|
83
118
|
}
|
|
84
119
|
}
|
|
120
|
+
}, {
|
|
121
|
+
target: textareaRef
|
|
85
122
|
});
|
|
86
123
|
return /*#__PURE__*/React.createElement("div", {
|
|
87
124
|
className: classnames(styles.container, _defineProperty(_defineProperty(_defineProperty({}, styles.active, focus), styles.compact, isCompact), styles.withDatasource, Boolean(datasourceNode))),
|
|
@@ -97,9 +134,12 @@ function PromptTextarea(props) {
|
|
|
97
134
|
},
|
|
98
135
|
id: "prompt-textarea",
|
|
99
136
|
className: classnames(styles.promptTextarea),
|
|
137
|
+
ref: textareaRef,
|
|
100
138
|
placeholder:
|
|
101
139
|
// (!isCompact && !themeConfig.isAntVSite && ic(themeConfig.metas.description)) ||
|
|
102
|
-
!isCompact && !themeConfig.isAntVSite ? typedPlaceholder :
|
|
140
|
+
!isCompact && !themeConfig.isAntVSite ? typedPlaceholder : formatMessage({
|
|
141
|
+
id: _.get(PLACEHOLDER, mode, 'ai.placeholder.implement')
|
|
142
|
+
}),
|
|
103
143
|
value: value,
|
|
104
144
|
onChange: function onChange(evt) {
|
|
105
145
|
_onChange(evt.target.value);
|
|
@@ -109,22 +149,12 @@ function PromptTextarea(props) {
|
|
|
109
149
|
}, /*#__PURE__*/React.createElement("div", {
|
|
110
150
|
className: styles.dataActions
|
|
111
151
|
}, showAction && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ChooseLib, {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}, /*#__PURE__*/React.createElement(
|
|
118
|
-
type: "button"
|
|
119
|
-
}, /*#__PURE__*/React.createElement("img", {
|
|
120
|
-
src: FileIcons.FILE
|
|
121
|
-
}), " ", !isCompact && '上传数据'))), /*#__PURE__*/React.createElement(Tooltip, {
|
|
122
|
-
title: isCompact && '上传图片'
|
|
123
|
-
}, /*#__PURE__*/React.createElement(Upload, null, /*#__PURE__*/React.createElement("button", {
|
|
124
|
-
type: "button"
|
|
125
|
-
}, /*#__PURE__*/React.createElement("img", {
|
|
126
|
-
src: FileIcons.IMAGE
|
|
127
|
-
}), " ", !isCompact && '上传图片')))))), /*#__PURE__*/React.createElement("div", {
|
|
152
|
+
size: size,
|
|
153
|
+
value: snap.lib,
|
|
154
|
+
onChange: function onChange(s) {
|
|
155
|
+
return AIChatStore.lib = s;
|
|
156
|
+
}
|
|
157
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
128
158
|
className: styles.actions
|
|
129
159
|
}, loading ? /*#__PURE__*/React.createElement("img", {
|
|
130
160
|
className: styles.actionBtn,
|
|
@@ -133,7 +163,8 @@ function PromptTextarea(props) {
|
|
|
133
163
|
}) : /*#__PURE__*/React.createElement(SendButton, {
|
|
134
164
|
onClick: send,
|
|
135
165
|
disabled: !promptTextValid,
|
|
136
|
-
tip: !promptTextValid ?
|
|
166
|
+
tip: !promptTextValid ? formatMessage({
|
|
167
|
+
id: 'ai.msgbox.send.tip'
|
|
168
|
+
}) : undefined
|
|
137
169
|
}))));
|
|
138
|
-
}
|
|
139
|
-
export { PromptTextarea };
|
|
170
|
+
});
|
|
@@ -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;
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
|
|
38
38
|
:global {
|
|
39
39
|
button {
|
|
40
|
+
cursor: pointer;
|
|
40
41
|
display: inline-flex;
|
|
41
42
|
align-items: center;
|
|
42
43
|
height: 32px;
|
|
@@ -51,8 +52,8 @@
|
|
|
51
52
|
|
|
52
53
|
&.btn-error {
|
|
53
54
|
color: #ff4d4f;
|
|
54
|
-
box-shadow: inset 1px -1px 0 0 rgba(255, 255, 255,
|
|
55
|
-
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%);
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
.btn-icon,
|
|
@@ -74,9 +75,9 @@
|
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
&.active {
|
|
77
|
-
background: #
|
|
78
|
+
background: #fff9;
|
|
78
79
|
border: 1px solid #1677ff;
|
|
79
|
-
box-shadow:
|
|
80
|
+
box-shadow: 0 8px 20px 0 #1677ff29, inset 1px -1px 0 0 #ffffffe3;
|
|
80
81
|
|
|
81
82
|
.promptTextarea::placeholder {
|
|
82
83
|
color: transparent;
|
|
@@ -122,6 +123,6 @@
|
|
|
122
123
|
background: transparent;
|
|
123
124
|
|
|
124
125
|
&::placeholder {
|
|
125
|
-
color: rgba(122, 132, 153,
|
|
126
|
+
color: rgba(122, 132, 153, 85%);
|
|
126
127
|
}
|
|
127
128
|
}
|
|
@@ -3,22 +3,21 @@ import React from 'react';
|
|
|
3
3
|
import styles from "./card.module.less";
|
|
4
4
|
import { BarChartOutlined, QuestionCircleOutlined } from "@ant-design/icons";
|
|
5
5
|
import { AIMode, AIModeMeta, COLORS } from "../../constant";
|
|
6
|
+
import { FormattedMessage } from 'dumi';
|
|
6
7
|
export var Card = function Card(_ref) {
|
|
7
8
|
var _AIModeMeta$tag;
|
|
8
9
|
var item = _ref.item,
|
|
9
|
-
index = _ref.index
|
|
10
|
+
index = _ref.index,
|
|
11
|
+
onClick = _ref.onClick;
|
|
10
12
|
var query = item.query,
|
|
11
13
|
description = item.description,
|
|
12
14
|
_item$imageUrls = item.imageUrls,
|
|
13
15
|
imageUrls = _item$imageUrls === void 0 ? [] : _item$imageUrls,
|
|
14
|
-
link = item.link,
|
|
15
16
|
tag = item.tag;
|
|
16
17
|
var style = COLORS[index];
|
|
17
18
|
var handleClick = function handleClick(e) {
|
|
18
19
|
e.stopPropagation();
|
|
19
|
-
|
|
20
|
-
urlObj.hash = "";
|
|
21
|
-
window.open(urlObj.toString(), '_blank');
|
|
20
|
+
onClick === null || onClick === void 0 || onClick();
|
|
22
21
|
};
|
|
23
22
|
var popoverContent = /*#__PURE__*/React.createElement("div", {
|
|
24
23
|
className: styles.popoverContent
|
|
@@ -26,13 +25,17 @@ export var Card = function Card(_ref) {
|
|
|
26
25
|
className: styles.popoverItem
|
|
27
26
|
}, /*#__PURE__*/React.createElement("div", {
|
|
28
27
|
className: styles.popoverLabel
|
|
29
|
-
},
|
|
28
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
29
|
+
id: "ai.recommend.card.caseName"
|
|
30
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
30
31
|
className: styles.popoverValue
|
|
31
32
|
}, query)), /*#__PURE__*/React.createElement("div", {
|
|
32
33
|
className: styles.popoverItem
|
|
33
34
|
}, /*#__PURE__*/React.createElement("div", {
|
|
34
35
|
className: styles.popoverLabel
|
|
35
|
-
},
|
|
36
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
37
|
+
id: "ai.recommend.card.description"
|
|
38
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
36
39
|
className: styles.popoverValue
|
|
37
40
|
}, description)));
|
|
38
41
|
return /*#__PURE__*/React.createElement(Popover, {
|
|
@@ -54,7 +57,9 @@ export var Card = function Card(_ref) {
|
|
|
54
57
|
className: styles.typeIcon
|
|
55
58
|
}), /*#__PURE__*/React.createElement("span", {
|
|
56
59
|
className: styles.typeText
|
|
57
|
-
},
|
|
60
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
61
|
+
id: ((_AIModeMeta$tag = AIModeMeta[tag]) === null || _AIModeMeta$tag === void 0 ? void 0 : _AIModeMeta$tag.name) || tag
|
|
62
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
58
63
|
className: styles.title
|
|
59
64
|
}, query), /*#__PURE__*/React.createElement("div", {
|
|
60
65
|
className: styles.imageContainer
|
|
@@ -15,34 +15,58 @@ import styles from "./index.module.less";
|
|
|
15
15
|
import { ReloadOutlined } from "@ant-design/icons";
|
|
16
16
|
import RecommendJson from "./recommend.json";
|
|
17
17
|
import classnames from "classnames";
|
|
18
|
+
import { FormattedMessage, useSiteData } from 'dumi';
|
|
19
|
+
import { sampleSize } from "lodash-es";
|
|
18
20
|
export var RecommendCase = function RecommendCase(props) {
|
|
19
21
|
var _useState = useState(false),
|
|
20
22
|
_useState2 = _slicedToArray(_useState, 2),
|
|
21
23
|
loading = _useState2[0],
|
|
22
24
|
setLoading = _useState2[1];
|
|
25
|
+
var _useSiteData = useSiteData(),
|
|
26
|
+
themeConfig = _useSiteData.themeConfig;
|
|
23
27
|
var _useState3 = useState([]),
|
|
24
28
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
25
29
|
list = _useState4[0],
|
|
26
30
|
setList = _useState4[1];
|
|
27
31
|
var fetchList = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
28
|
-
var data;
|
|
32
|
+
var _themeConfig$ai, data;
|
|
29
33
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
30
34
|
while (1) switch (_context.prev = _context.next) {
|
|
31
35
|
case 0:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
} finally {
|
|
39
|
-
setLoading(false);
|
|
36
|
+
_context.prev = 0;
|
|
37
|
+
setLoading(true);
|
|
38
|
+
data = [];
|
|
39
|
+
if (!(themeConfig !== null && themeConfig !== void 0 && (_themeConfig$ai = themeConfig.ai) !== null && _themeConfig$ai !== void 0 && _themeConfig$ai.recommend)) {
|
|
40
|
+
_context.next = 9;
|
|
41
|
+
break;
|
|
40
42
|
}
|
|
41
|
-
|
|
43
|
+
_context.next = 6;
|
|
44
|
+
return fetch(themeConfig.ai.recommend).then(function (res) {
|
|
45
|
+
return res.json();
|
|
46
|
+
});
|
|
47
|
+
case 6:
|
|
48
|
+
data = _context.sent;
|
|
49
|
+
_context.next = 10;
|
|
50
|
+
break;
|
|
51
|
+
case 9:
|
|
52
|
+
data = RecommendJson;
|
|
53
|
+
case 10:
|
|
54
|
+
setList(sampleSize(data, 4));
|
|
55
|
+
_context.next = 16;
|
|
56
|
+
break;
|
|
57
|
+
case 13:
|
|
58
|
+
_context.prev = 13;
|
|
59
|
+
_context.t0 = _context["catch"](0);
|
|
60
|
+
console.log(_context.t0);
|
|
61
|
+
case 16:
|
|
62
|
+
_context.prev = 16;
|
|
63
|
+
setLoading(false);
|
|
64
|
+
return _context.finish(16);
|
|
65
|
+
case 19:
|
|
42
66
|
case "end":
|
|
43
67
|
return _context.stop();
|
|
44
68
|
}
|
|
45
|
-
}, _callee);
|
|
69
|
+
}, _callee, null, [[0, 13, 16, 19]]);
|
|
46
70
|
})), [list]);
|
|
47
71
|
useEffect(function () {
|
|
48
72
|
fetchList();
|
|
@@ -56,12 +80,16 @@ export var RecommendCase = function RecommendCase(props) {
|
|
|
56
80
|
className: styles.title
|
|
57
81
|
}, /*#__PURE__*/React.createElement("span", {
|
|
58
82
|
className: styles.quickStart
|
|
59
|
-
},
|
|
83
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
84
|
+
id: "ai.recommend.title"
|
|
85
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
60
86
|
className: styles.refresh,
|
|
61
87
|
onClick: function onClick() {
|
|
62
88
|
return fetchList();
|
|
63
89
|
}
|
|
64
|
-
}, /*#__PURE__*/React.createElement(ReloadOutlined, null),
|
|
90
|
+
}, /*#__PURE__*/React.createElement(ReloadOutlined, null), /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
91
|
+
id: "ai.recommend.refresh"
|
|
92
|
+
}))), /*#__PURE__*/React.createElement(Spin, {
|
|
65
93
|
spinning: loading,
|
|
66
94
|
wrapperClassName: classnames(styles.listContainer, props.className)
|
|
67
95
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -70,7 +98,11 @@ export var RecommendCase = function RecommendCase(props) {
|
|
|
70
98
|
return /*#__PURE__*/React.createElement(Card, {
|
|
71
99
|
key: item.caseId,
|
|
72
100
|
item: item,
|
|
73
|
-
index: index
|
|
101
|
+
index: index,
|
|
102
|
+
onClick: function onClick() {
|
|
103
|
+
var _props$onClick;
|
|
104
|
+
(_props$onClick = props.onClick) === null || _props$onClick === void 0 || _props$onClick.call(props, item);
|
|
105
|
+
}
|
|
74
106
|
});
|
|
75
107
|
}))));
|
|
76
108
|
};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
margin-top: 32px;
|
|
3
3
|
margin-left: auto;
|
|
4
4
|
margin-right: auto;
|
|
5
|
+
z-index: 10;
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
.title {
|
|
@@ -27,15 +28,15 @@
|
|
|
27
28
|
display: flex;
|
|
28
29
|
gap: 2px;
|
|
29
30
|
align-items: center;
|
|
30
|
-
|
|
31
31
|
font-size: 12px;
|
|
32
|
-
color: rgba(78, 89, 105,
|
|
32
|
+
color: rgba(78, 89, 105, 60%);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
.listContainer {
|
|
37
37
|
width: 100%;
|
|
38
38
|
}
|
|
39
|
+
|
|
39
40
|
.list {
|
|
40
41
|
display: grid;
|
|
41
42
|
grid-template-columns: repeat(4, 1fr);
|
|
@@ -13,25 +13,24 @@ import { ModeSelector } from "./ModeSelector";
|
|
|
13
13
|
import { useLocalStorageState } from 'ahooks';
|
|
14
14
|
import { AIMode } from "../constant";
|
|
15
15
|
import classnames from 'classnames';
|
|
16
|
-
import {
|
|
16
|
+
import { useLocale } from 'dumi';
|
|
17
17
|
import { createNewSession } from "../../../model/AIChat";
|
|
18
18
|
export function HomeDialog(props) {
|
|
19
|
-
var
|
|
20
|
-
themeConfig = _useSiteData.themeConfig;
|
|
21
|
-
var _useState = useState(!themeConfig.isAntVSite ? themeConfig.title : undefined),
|
|
22
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
23
|
-
lib = _useState2[0],
|
|
24
|
-
setLib = _useState2[1];
|
|
19
|
+
var locale = useLocale();
|
|
25
20
|
var _useLocalStorageState = useLocalStorageState('use-local-storage-ai-mode-type', {
|
|
26
21
|
defaultValue: AIMode.implement
|
|
27
22
|
}),
|
|
28
23
|
_useLocalStorageState2 = _slicedToArray(_useLocalStorageState, 2),
|
|
29
24
|
mode = _useLocalStorageState2[0],
|
|
30
25
|
setMode = _useLocalStorageState2[1];
|
|
26
|
+
var _useState = useState(''),
|
|
27
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
28
|
+
promptText = _useState2[0],
|
|
29
|
+
setPromptText = _useState2[1];
|
|
31
30
|
var _useState3 = useState(''),
|
|
32
31
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
fileSummary = _useState4[0],
|
|
33
|
+
setFileSummary = _useState4[1];
|
|
35
34
|
return /*#__PURE__*/React.createElement("div", {
|
|
36
35
|
className: classnames(styles.content, props.className),
|
|
37
36
|
style: props.style
|
|
@@ -44,10 +43,6 @@ export function HomeDialog(props) {
|
|
|
44
43
|
}), /*#__PURE__*/React.createElement(PromptTextarea, {
|
|
45
44
|
mode: mode,
|
|
46
45
|
value: promptText,
|
|
47
|
-
lib: lib,
|
|
48
|
-
onLibChange: function onLibChange(v) {
|
|
49
|
-
setLib(v);
|
|
50
|
-
},
|
|
51
46
|
onChange: function onChange(val) {
|
|
52
47
|
setPromptText(val);
|
|
53
48
|
},
|
|
@@ -55,12 +50,19 @@ export function HomeDialog(props) {
|
|
|
55
50
|
createNewSession({
|
|
56
51
|
promptText: promptText,
|
|
57
52
|
mode: mode,
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
jump: true,
|
|
54
|
+
context: fileSummary,
|
|
55
|
+
lang: locale.id
|
|
60
56
|
});
|
|
61
57
|
},
|
|
62
|
-
style: props.promptTextareaStyle
|
|
58
|
+
style: props.promptTextareaStyle,
|
|
59
|
+
onDataSummaryChange: setFileSummary
|
|
63
60
|
}), /*#__PURE__*/React.createElement(RecommendCase, {
|
|
64
|
-
className: props.recommendCaseClassName
|
|
61
|
+
className: props.recommendCaseClassName,
|
|
62
|
+
onClick: function onClick(val) {
|
|
63
|
+
if (val !== null && val !== void 0 && val.query) {
|
|
64
|
+
setPromptText(val.query);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
65
67
|
}));
|
|
66
68
|
}
|
|
@@ -6,11 +6,11 @@ export var AIMode = {
|
|
|
6
6
|
};
|
|
7
7
|
export var AIModeMeta = {
|
|
8
8
|
implement: {
|
|
9
|
-
name: '
|
|
9
|
+
name: 'ai.mode.implement',
|
|
10
10
|
icon: /*#__PURE__*/React.createElement(BarChartOutlined, null)
|
|
11
11
|
},
|
|
12
12
|
solve: {
|
|
13
|
-
name: '
|
|
13
|
+
name: 'ai.mode.solve',
|
|
14
14
|
icon: /*#__PURE__*/React.createElement(QuestionCircleOutlined, null)
|
|
15
15
|
}
|
|
16
16
|
};
|