@antv/dumi-theme-antv 0.8.0-beta.0 → 0.8.0-beta.10
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 +5 -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 +66 -34
- 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 +18 -4
- 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/hooks/useStreamingText.js +38 -18
- package/dist/hooks/useTypewriter.js +69 -0
- package/dist/layouts/DocLayout.js +2 -1
- package/dist/layouts/GlobalLayout/index.js +10 -4
- package/dist/locales/en.json +121 -1
- package/dist/locales/zh.json +121 -1
- package/dist/model/AIChat.js +79 -11
- package/dist/model/auth.js +133 -0
- package/dist/pages/AIPlayground/components/ConversationsMenu/index.js +31 -10
- package/dist/pages/AIPlayground/components/ConversationsMenu/index.module.less +2 -0
- package/dist/pages/AIPlayground/components/MarkdownComponent/MarkdownCodeBlock.js +47 -20
- package/dist/pages/AIPlayground/components/MarkdownComponent/MarkdownCodeBlock.module.less +13 -0
- package/dist/pages/AIPlayground/components/MarkdownComponent/index.js +6 -3
- package/dist/pages/AIPlayground/components/MsgBox/index.js +250 -106
- 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 +18 -10
- package/dist/pages/AIPlayground/components/SessionLayout/index.module.less +3 -1
- package/dist/pages/AIPlayground/components/TaskBox/generateCode.js +10 -5
- package/dist/pages/AIPlayground/components/TaskBox/index.js +79 -54
- 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 +20 -8
- package/dist/slots/CodeEditor/Toolbar.module.less +1 -0
- package/dist/slots/CodeEditor/index.js +30 -10
- package/dist/slots/CodeEditor/index.module.less +3 -0
- package/dist/slots/CodePreview/index.module.less +0 -3
- package/dist/slots/CodeRunner/index.js +6 -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 -7
- package/dist/slots/Header/Search/SearchResult.module.less +1 -0
- package/dist/slots/Header/index.js +56 -11
- 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/code.js +35 -0
- package/dist/utils/env.js +37 -0
- package/dist/utils/request.js +42 -0
- package/package.json +7 -2
|
@@ -10,37 +10,46 @@ 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, { 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";
|
|
21
|
+
import { useTypewriter } from "../../../../hooks/useTypewriter";
|
|
22
|
+
import { authStore, showLoginModal } from "../../../../model/auth";
|
|
23
|
+
import { useSnapshot } from "valtio";
|
|
23
24
|
var PLACEHOLDER = {
|
|
24
|
-
implement: '
|
|
25
|
-
solve: '
|
|
25
|
+
implement: 'ai.placeholder.implement',
|
|
26
|
+
solve: 'ai.placeholder.solve'
|
|
26
27
|
};
|
|
27
|
-
|
|
28
|
+
export var PromptTextarea = /*#__PURE__*/React.memo(function PromptTextareaInner(props) {
|
|
28
29
|
var value = props.value,
|
|
29
30
|
size = props.size,
|
|
30
31
|
_onChange = props.onChange,
|
|
32
|
+
onDataSummaryChange = props.onDataSummaryChange,
|
|
31
33
|
onConfirm = props.onConfirm,
|
|
32
34
|
onCancel = props.onCancel,
|
|
33
35
|
loading = props.loading,
|
|
34
|
-
fileMeta = props.fileMeta,
|
|
35
36
|
mode = props.mode,
|
|
36
37
|
lib = props.lib,
|
|
37
38
|
onLibChange = props.onLibChange,
|
|
38
39
|
_props$showAction = props.showAction,
|
|
39
40
|
showAction = _props$showAction === void 0 ? true : _props$showAction;
|
|
40
|
-
var
|
|
41
|
+
var authSnap = useSnapshot(authStore);
|
|
42
|
+
var _useIntl = useIntl(),
|
|
43
|
+
formatMessage = _useIntl.formatMessage;
|
|
44
|
+
var textareaRef = useRef(null);
|
|
45
|
+
|
|
46
|
+
// 将fileMeta状态移到组件内部管理
|
|
47
|
+
var _useState = useState(null),
|
|
41
48
|
_useState2 = _slicedToArray(_useState, 2),
|
|
42
|
-
|
|
43
|
-
|
|
49
|
+
fileMeta = _useState2[0],
|
|
50
|
+
setFileMeta = _useState2[1];
|
|
51
|
+
|
|
52
|
+
// ... 其他状态和hooks保持不变
|
|
44
53
|
var _useState3 = useState(false),
|
|
45
54
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
46
55
|
focus = _useState4[0],
|
|
@@ -48,12 +57,35 @@ function PromptTextarea(props) {
|
|
|
48
57
|
var isCompact = size === 'compact';
|
|
49
58
|
var _useSiteData = useSiteData(),
|
|
50
59
|
themeConfig = _useSiteData.themeConfig;
|
|
60
|
+
var typedPlaceholder = useTypewriter({
|
|
61
|
+
texts: [formatMessage({
|
|
62
|
+
id: 'ai.placeholder.whatis'
|
|
63
|
+
}, {
|
|
64
|
+
title: themeConfig.title
|
|
65
|
+
}), ic(themeConfig.metas.description)]
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// 处理DataUploader的回调
|
|
69
|
+
var handleDataAnalyzed = function handleDataAnalyzed(analyzedData) {
|
|
70
|
+
setFileMeta(analyzedData.fileMeta);
|
|
71
|
+
if (onDataSummaryChange) {
|
|
72
|
+
onDataSummaryChange(analyzedData.dataSummary);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
51
75
|
function renderDatasourceCard() {
|
|
52
76
|
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) {
|
|
77
|
+
// 当点击DatasourceCard的关闭按钮时,应该清空状态
|
|
78
|
+
var handleClose = function handleClose() {
|
|
79
|
+
setFileMeta(null);
|
|
80
|
+
if (onDataSummaryChange) {
|
|
81
|
+
onDataSummaryChange('');
|
|
82
|
+
}
|
|
83
|
+
};
|
|
53
84
|
return /*#__PURE__*/React.createElement(DatasourceCard, {
|
|
54
85
|
type: fileMeta.type,
|
|
55
86
|
title: fileMeta.fileName,
|
|
56
|
-
desc: fileMeta.fileSize
|
|
87
|
+
desc: fileMeta.fileSize,
|
|
88
|
+
onDelete: handleClose
|
|
57
89
|
});
|
|
58
90
|
} else {
|
|
59
91
|
return null;
|
|
@@ -61,14 +93,18 @@ function PromptTextarea(props) {
|
|
|
61
93
|
}
|
|
62
94
|
var datasourceNode = renderDatasourceCard();
|
|
63
95
|
var promptTextValid = Boolean(value);
|
|
64
|
-
var
|
|
65
|
-
if (
|
|
66
|
-
message.warning('请输入指令');
|
|
67
|
-
} else {
|
|
68
|
-
setShowError(false);
|
|
96
|
+
var pureSend = function pureSend() {
|
|
97
|
+
if (promptTextValid) {
|
|
69
98
|
onConfirm === null || onConfirm === void 0 || onConfirm();
|
|
70
99
|
}
|
|
71
100
|
};
|
|
101
|
+
var send = function send() {
|
|
102
|
+
if (!authSnap.isAuthenticated) {
|
|
103
|
+
showLoginModal(pureSend);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
pureSend();
|
|
107
|
+
};
|
|
72
108
|
useEventListener('keydown', function (event) {
|
|
73
109
|
if (event.key === 'Enter') {
|
|
74
110
|
// 不区分 textarea 是否聚焦
|
|
@@ -77,6 +113,8 @@ function PromptTextarea(props) {
|
|
|
77
113
|
send(); // 触发自定义事件
|
|
78
114
|
}
|
|
79
115
|
}
|
|
116
|
+
}, {
|
|
117
|
+
target: textareaRef
|
|
80
118
|
});
|
|
81
119
|
return /*#__PURE__*/React.createElement("div", {
|
|
82
120
|
className: classnames(styles.container, _defineProperty(_defineProperty(_defineProperty({}, styles.active, focus), styles.compact, isCompact), styles.withDatasource, Boolean(datasourceNode))),
|
|
@@ -92,7 +130,12 @@ function PromptTextarea(props) {
|
|
|
92
130
|
},
|
|
93
131
|
id: "prompt-textarea",
|
|
94
132
|
className: classnames(styles.promptTextarea),
|
|
95
|
-
|
|
133
|
+
ref: textareaRef,
|
|
134
|
+
placeholder:
|
|
135
|
+
// (!isCompact && !themeConfig.isAntVSite && ic(themeConfig.metas.description)) ||
|
|
136
|
+
!isCompact && !themeConfig.isAntVSite ? typedPlaceholder : formatMessage({
|
|
137
|
+
id: _.get(PLACEHOLDER, mode, 'ai.placeholder.implement')
|
|
138
|
+
}),
|
|
96
139
|
value: value,
|
|
97
140
|
onChange: function onChange(evt) {
|
|
98
141
|
_onChange(evt.target.value);
|
|
@@ -105,19 +148,7 @@ function PromptTextarea(props) {
|
|
|
105
148
|
value: lib,
|
|
106
149
|
onChange: onLibChange,
|
|
107
150
|
size: size
|
|
108
|
-
}),
|
|
109
|
-
title: isCompact && '上传数据'
|
|
110
|
-
}, /*#__PURE__*/React.createElement(Upload, null, /*#__PURE__*/React.createElement("button", {
|
|
111
|
-
type: "button"
|
|
112
|
-
}, /*#__PURE__*/React.createElement("img", {
|
|
113
|
-
src: FileIcons.FILE
|
|
114
|
-
}), " ", !isCompact && '上传数据'))), /*#__PURE__*/React.createElement(Tooltip, {
|
|
115
|
-
title: isCompact && '上传图片'
|
|
116
|
-
}, /*#__PURE__*/React.createElement(Upload, null, /*#__PURE__*/React.createElement("button", {
|
|
117
|
-
type: "button"
|
|
118
|
-
}, /*#__PURE__*/React.createElement("img", {
|
|
119
|
-
src: FileIcons.IMAGE
|
|
120
|
-
}), " ", !isCompact && '上传图片')))))), /*#__PURE__*/React.createElement("div", {
|
|
151
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
121
152
|
className: styles.actions
|
|
122
153
|
}, loading ? /*#__PURE__*/React.createElement("img", {
|
|
123
154
|
className: styles.actionBtn,
|
|
@@ -126,7 +157,8 @@ function PromptTextarea(props) {
|
|
|
126
157
|
}) : /*#__PURE__*/React.createElement(SendButton, {
|
|
127
158
|
onClick: send,
|
|
128
159
|
disabled: !promptTextValid,
|
|
129
|
-
tip: !promptTextValid ?
|
|
160
|
+
tip: !promptTextValid ? formatMessage({
|
|
161
|
+
id: 'ai.msgbox.send.tip'
|
|
162
|
+
}) : undefined
|
|
130
163
|
}))));
|
|
131
|
-
}
|
|
132
|
-
export { PromptTextarea };
|
|
164
|
+
});
|
|
@@ -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
|
|
@@ -12,14 +12,18 @@ import { Spin } from 'antd';
|
|
|
12
12
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
13
13
|
import { Card } from "./Card";
|
|
14
14
|
import styles from "./index.module.less";
|
|
15
|
-
import {
|
|
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],
|
|
@@ -29,20 +33,40 @@ export var RecommendCase = function RecommendCase(props) {
|
|
|
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.recommend)) {
|
|
40
|
+
_context.next = 9;
|
|
41
|
+
break;
|
|
40
42
|
}
|
|
41
|
-
|
|
43
|
+
_context.next = 6;
|
|
44
|
+
return fetch(themeConfig.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(
|
|
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,9 +13,10 @@ import { ModeSelector } from "./ModeSelector";
|
|
|
13
13
|
import { useLocalStorageState } from 'ahooks';
|
|
14
14
|
import { AIMode } from "../constant";
|
|
15
15
|
import classnames from 'classnames';
|
|
16
|
-
import { useSiteData } from 'dumi';
|
|
16
|
+
import { useSiteData, useLocale } from 'dumi';
|
|
17
17
|
import { createNewSession } from "../../../model/AIChat";
|
|
18
18
|
export function HomeDialog(props) {
|
|
19
|
+
var locale = useLocale();
|
|
19
20
|
var _useSiteData = useSiteData(),
|
|
20
21
|
themeConfig = _useSiteData.themeConfig;
|
|
21
22
|
var _useState = useState(!themeConfig.isAntVSite ? themeConfig.title : undefined),
|
|
@@ -32,6 +33,10 @@ export function HomeDialog(props) {
|
|
|
32
33
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
33
34
|
promptText = _useState4[0],
|
|
34
35
|
setPromptText = _useState4[1];
|
|
36
|
+
var _useState5 = useState(''),
|
|
37
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
38
|
+
fileSummary = _useState6[0],
|
|
39
|
+
setFileSummary = _useState6[1];
|
|
35
40
|
return /*#__PURE__*/React.createElement("div", {
|
|
36
41
|
className: classnames(styles.content, props.className),
|
|
37
42
|
style: props.style
|
|
@@ -55,11 +60,20 @@ export function HomeDialog(props) {
|
|
|
55
60
|
createNewSession({
|
|
56
61
|
promptText: promptText,
|
|
57
62
|
mode: mode,
|
|
58
|
-
lib: lib
|
|
63
|
+
lib: lib,
|
|
64
|
+
jump: true,
|
|
65
|
+
context: fileSummary,
|
|
66
|
+
lang: locale.id
|
|
59
67
|
});
|
|
60
68
|
},
|
|
61
|
-
style: props.promptTextareaStyle
|
|
69
|
+
style: props.promptTextareaStyle,
|
|
70
|
+
onDataSummaryChange: setFileSummary
|
|
62
71
|
}), /*#__PURE__*/React.createElement(RecommendCase, {
|
|
63
|
-
className: props.recommendCaseClassName
|
|
72
|
+
className: props.recommendCaseClassName,
|
|
73
|
+
onClick: function onClick(val) {
|
|
74
|
+
if (val !== null && val !== void 0 && val.query) {
|
|
75
|
+
setPromptText(val.query);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
64
78
|
}));
|
|
65
79
|
}
|
|
@@ -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
|
};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { NC_SCENE } from "../utils";
|
|
2
|
+
import React, { forwardRef, useEffect, useImperativeHandle, useRef } from 'react'; // 图形验证码资源文件
|
|
3
|
+
|
|
4
|
+
import { Form, Input } from 'antd';
|
|
5
|
+
import cls from 'classnames';
|
|
6
|
+
import { useIntl } from 'dumi';
|
|
7
|
+
import "./index.less";
|
|
8
|
+
|
|
9
|
+
// 添加 window.noCaptcha 的类型声明
|
|
10
|
+
|
|
11
|
+
// 图形验证码资源文件
|
|
12
|
+
var NC_CSS_SOURCE = 'https://g.alicdn.com/sd/ncpc/nc.css?t=1514534550478';
|
|
13
|
+
var NC_SCRIPT_SOURCE = 'https://g.alicdn.com/sd/ncpc/nc.js?t=1514534550478';
|
|
14
|
+
var NC_NAME = 'NoCaptcha';
|
|
15
|
+
var Captcha = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
16
|
+
var _ref$ncName = _ref.ncName,
|
|
17
|
+
ncName = _ref$ncName === void 0 ? NC_NAME : _ref$ncName,
|
|
18
|
+
_ref$scene = _ref.scene,
|
|
19
|
+
scene = _ref$scene === void 0 ? NC_SCENE.login : _ref$scene,
|
|
20
|
+
form = _ref.form,
|
|
21
|
+
_ref$onCallback = _ref.onCallback,
|
|
22
|
+
onCallback = _ref$onCallback === void 0 ? function () {} : _ref$onCallback,
|
|
23
|
+
className = _ref.className;
|
|
24
|
+
var _useIntl = useIntl(),
|
|
25
|
+
formatMessage = _useIntl.formatMessage,
|
|
26
|
+
locale = _useIntl.locale;
|
|
27
|
+
var ncInstance = useRef(null);
|
|
28
|
+
function reset() {
|
|
29
|
+
var _ncInstance$current;
|
|
30
|
+
form.setFieldsValue({
|
|
31
|
+
csessionid: '',
|
|
32
|
+
sig: '',
|
|
33
|
+
token: '',
|
|
34
|
+
scene: '',
|
|
35
|
+
captcha: null
|
|
36
|
+
});
|
|
37
|
+
(_ncInstance$current = ncInstance.current) === null || _ncInstance$current === void 0 || _ncInstance$current.reset(1);
|
|
38
|
+
}
|
|
39
|
+
function getValues() {
|
|
40
|
+
return form.getFieldsValue(['csessionid', 'sig', 'token', 'scene', 'captcha']);
|
|
41
|
+
}
|
|
42
|
+
useImperativeHandle(ref, function () {
|
|
43
|
+
return {
|
|
44
|
+
resetCaptcha: function resetCaptcha() {
|
|
45
|
+
reset();
|
|
46
|
+
},
|
|
47
|
+
getCaptchaValues: function getCaptchaValues() {
|
|
48
|
+
return getValues();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
function loadCaptcha() {
|
|
53
|
+
var _document$getElementB, _ncInstance$current2;
|
|
54
|
+
if (!ncInstance.current) {
|
|
55
|
+
/* eslint no-undef:0 */
|
|
56
|
+
/* eslint new-cap:0 */
|
|
57
|
+
ncInstance.current = new window.noCaptcha();
|
|
58
|
+
window[ncName] = ncInstance.current;
|
|
59
|
+
}
|
|
60
|
+
var nc_appkey = 'FFFF000000000179A3AD';
|
|
61
|
+
var nc_token = [nc_appkey, new Date().getTime(), Math.random()].join(':');
|
|
62
|
+
var nc_scene = scene;
|
|
63
|
+
var nc_customWidth = ((_document$getElementB = document.getElementById("captcha_render_id_".concat(ncName))) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.offsetWidth) || 300;
|
|
64
|
+
var nc_option = {
|
|
65
|
+
renderTo: "#captcha_render_id_".concat(ncName),
|
|
66
|
+
appkey: nc_appkey,
|
|
67
|
+
scene: nc_scene,
|
|
68
|
+
token: nc_token,
|
|
69
|
+
language: locale ? 'en' : 'cn',
|
|
70
|
+
customWidth: nc_customWidth,
|
|
71
|
+
callback: function callback(data) {
|
|
72
|
+
// 校验成功回调
|
|
73
|
+
var setFieldsValue = form.setFieldsValue;
|
|
74
|
+
setFieldsValue({
|
|
75
|
+
csessionid: data.csessionid,
|
|
76
|
+
sig: data.sig,
|
|
77
|
+
token: nc_token,
|
|
78
|
+
scene: nc_scene,
|
|
79
|
+
captcha: 'true'
|
|
80
|
+
});
|
|
81
|
+
onCallback === null || onCallback === void 0 || onCallback();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
(_ncInstance$current2 = ncInstance.current) === null || _ncInstance$current2 === void 0 || _ncInstance$current2.init(nc_option);
|
|
85
|
+
var lang = {
|
|
86
|
+
_startTEXT: formatMessage({
|
|
87
|
+
id: 'login.captcha.drag'
|
|
88
|
+
}),
|
|
89
|
+
_yesTEXT: formatMessage({
|
|
90
|
+
id: 'login.captcha.success'
|
|
91
|
+
}),
|
|
92
|
+
_Loading: formatMessage({
|
|
93
|
+
id: 'login.captcha.loading'
|
|
94
|
+
}),
|
|
95
|
+
_error300: formatMessage({
|
|
96
|
+
id: 'login.captcha.error.wrong'
|
|
97
|
+
}) + ' <a href="javascript:__nc.reset()">' + formatMessage({
|
|
98
|
+
id: 'login.captcha.error.refresh'
|
|
99
|
+
}) + '</a>',
|
|
100
|
+
_errorNetwork: formatMessage({
|
|
101
|
+
id: 'login.captcha.error.network'
|
|
102
|
+
}) + ' <a href="javascript:__nc.reset()">' + formatMessage({
|
|
103
|
+
id: 'login.captcha.error.refresh'
|
|
104
|
+
}) + '</a>'
|
|
105
|
+
};
|
|
106
|
+
if (locale) {
|
|
107
|
+
var _ncInstance$current3;
|
|
108
|
+
(_ncInstance$current3 = ncInstance.current) === null || _ncInstance$current3 === void 0 || _ncInstance$current3.upLang('en', lang);
|
|
109
|
+
} else {
|
|
110
|
+
var _ncInstance$current4;
|
|
111
|
+
(_ncInstance$current4 = ncInstance.current) === null || _ncInstance$current4 === void 0 || _ncInstance$current4.upLang('cn', lang);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
useEffect(function () {
|
|
115
|
+
var script = document.createElement('script');
|
|
116
|
+
script.src = NC_SCRIPT_SOURCE;
|
|
117
|
+
var link = document.createElement('link');
|
|
118
|
+
script.async = true;
|
|
119
|
+
link.href = NC_CSS_SOURCE;
|
|
120
|
+
link.rel = 'stylesheet';
|
|
121
|
+
link.type = 'text/css';
|
|
122
|
+
|
|
123
|
+
// 如果资源没有加载过,则添加到head中
|
|
124
|
+
document.head.appendChild(link);
|
|
125
|
+
if (!window.noCaptcha) {
|
|
126
|
+
document.head.appendChild(script);
|
|
127
|
+
script.onload = function () {
|
|
128
|
+
loadCaptcha();
|
|
129
|
+
};
|
|
130
|
+
} else {
|
|
131
|
+
loadCaptcha();
|
|
132
|
+
}
|
|
133
|
+
return function () {
|
|
134
|
+
try {
|
|
135
|
+
script.remove();
|
|
136
|
+
link.remove();
|
|
137
|
+
if (script.parentNode === document.body) {
|
|
138
|
+
document.body.removeChild(script);
|
|
139
|
+
}
|
|
140
|
+
if (link.parentNode === document.body) {
|
|
141
|
+
document.body.removeChild(link);
|
|
142
|
+
}
|
|
143
|
+
} catch (e) {
|
|
144
|
+
// ignore error
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
}, []);
|
|
148
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
149
|
+
className: cls('captcha', className)
|
|
150
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
151
|
+
id: "captcha_render_id_".concat(ncName)
|
|
152
|
+
}), /*#__PURE__*/React.createElement(Form.Item, {
|
|
153
|
+
name: "csessionid",
|
|
154
|
+
noStyle: true
|
|
155
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
156
|
+
type: "hidden"
|
|
157
|
+
})), /*#__PURE__*/React.createElement(Form.Item, {
|
|
158
|
+
name: "sig",
|
|
159
|
+
noStyle: true
|
|
160
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
161
|
+
type: "hidden"
|
|
162
|
+
})), /*#__PURE__*/React.createElement(Form.Item, {
|
|
163
|
+
name: "token",
|
|
164
|
+
noStyle: true
|
|
165
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
166
|
+
type: "hidden"
|
|
167
|
+
})), /*#__PURE__*/React.createElement(Form.Item, {
|
|
168
|
+
name: "scene",
|
|
169
|
+
noStyle: true
|
|
170
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
171
|
+
type: "hidden"
|
|
172
|
+
})), /*#__PURE__*/React.createElement(Form.Item, {
|
|
173
|
+
name: "captcha",
|
|
174
|
+
rules: [{
|
|
175
|
+
required: true,
|
|
176
|
+
message: formatMessage({
|
|
177
|
+
id: 'login.captcha.required'
|
|
178
|
+
})
|
|
179
|
+
}],
|
|
180
|
+
className: "captcha-tip"
|
|
181
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
182
|
+
type: "hidden"
|
|
183
|
+
})));
|
|
184
|
+
});
|
|
185
|
+
export default Captcha;
|