@antv/dumi-theme-antv 0.8.0-beta.1 → 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.
Files changed (80) hide show
  1. package/dist/builtins/Playground/index.module.less +0 -1
  2. package/dist/components/AI/HomeDialog/AntVBanner/index.module.less +2 -2
  3. package/dist/components/AI/HomeDialog/ModeSelector/index.js +4 -1
  4. package/dist/components/AI/HomeDialog/ModeSelector/index.module.less +39 -22
  5. package/dist/components/AI/HomeDialog/PromptTextarea/ChooseLib/index.js +5 -2
  6. package/dist/components/AI/HomeDialog/PromptTextarea/ChooseLib/index.module.less +0 -1
  7. package/dist/components/AI/HomeDialog/PromptTextarea/DatasourceCard/index.module.less +3 -3
  8. package/dist/components/AI/HomeDialog/PromptTextarea/Uploader/DataUploader.js +225 -0
  9. package/dist/components/AI/HomeDialog/PromptTextarea/index.js +61 -36
  10. package/dist/components/AI/HomeDialog/PromptTextarea/index.module.less +9 -8
  11. package/dist/components/AI/HomeDialog/RecommendCase/Card.js +13 -8
  12. package/dist/components/AI/HomeDialog/RecommendCase/card.module.less +1 -1
  13. package/dist/components/AI/HomeDialog/RecommendCase/index.js +45 -13
  14. package/dist/components/AI/HomeDialog/RecommendCase/index.module.less +3 -2
  15. package/dist/components/AI/HomeDialog/index.js +17 -4
  16. package/dist/components/AI/constant.js +2 -2
  17. package/dist/components/Login/Captcha/index.js +185 -0
  18. package/dist/components/Login/Captcha/index.less +91 -0
  19. package/dist/components/Login/CheckCode/index.js +244 -0
  20. package/dist/components/Login/CheckCode/index.less +137 -0
  21. package/dist/components/Login/CountDownButton/index.js +109 -0
  22. package/dist/components/Login/CountDownButton/index.less +8 -0
  23. package/dist/components/Login/LoginForm.js +239 -0
  24. package/dist/components/Login/LoginForm.less +409 -0
  25. package/dist/components/Login/index.js +24 -0
  26. package/dist/components/Login/openAuthWindow.js +54 -0
  27. package/dist/components/Login/types.js +5 -0
  28. package/dist/components/Login/utils.js +47 -0
  29. package/dist/layouts/DocLayout.js +2 -1
  30. package/dist/layouts/GlobalLayout/index.js +10 -4
  31. package/dist/locales/en.json +121 -1
  32. package/dist/locales/zh.json +121 -1
  33. package/dist/model/AIChat.js +65 -7
  34. package/dist/model/auth.js +133 -0
  35. package/dist/pages/AIPlayground/components/ConversationsMenu/index.js +28 -10
  36. package/dist/pages/AIPlayground/components/ConversationsMenu/index.module.less +2 -0
  37. package/dist/pages/AIPlayground/components/MarkdownComponent/MarkdownCodeBlock.js +25 -11
  38. package/dist/pages/AIPlayground/components/MarkdownComponent/MarkdownCodeBlock.module.less +1 -2
  39. package/dist/pages/AIPlayground/components/MarkdownComponent/index.js +5 -2
  40. package/dist/pages/AIPlayground/components/MsgBox/index.js +198 -136
  41. package/dist/pages/AIPlayground/components/MsgBox/index.module.less +3 -2
  42. package/dist/pages/AIPlayground/components/MsgBox/useAutoScroll.js +46 -0
  43. package/dist/pages/AIPlayground/components/SessionLayout/index.js +18 -10
  44. package/dist/pages/AIPlayground/components/SessionLayout/index.module.less +3 -1
  45. package/dist/pages/AIPlayground/components/TaskBox/generateCode.js +7 -1
  46. package/dist/pages/AIPlayground/components/TaskBox/index.js +79 -55
  47. package/dist/pages/AIPlayground/components/TaskBox/index.module.less +1 -0
  48. package/dist/pages/Examples/components/Accouncement/index.module.less +1 -1
  49. package/dist/pages/Examples/index.module.less +11 -11
  50. package/dist/pages/Index/components/Cases/index.module.less +8 -8
  51. package/dist/pages/Index/components/Companies/index.module.less +4 -3
  52. package/dist/pages/Index/components/Features/FeatureCard.module.less +4 -5
  53. package/dist/pages/Index/components/Features/index.module.less +5 -5
  54. package/dist/pages/Index/components/_.less +9 -9
  55. package/dist/plugin/index.js +2 -2
  56. package/dist/slots/Banner/Notification.module.less +8 -8
  57. package/dist/slots/Banner/index.module.less +10 -9
  58. package/dist/slots/CodeEditor/Toolbar.js +15 -9
  59. package/dist/slots/CodeEditor/index.js +19 -10
  60. package/dist/slots/CodeEditor/index.module.less +3 -0
  61. package/dist/slots/CodePreview/index.module.less +0 -3
  62. package/dist/slots/CodeRunner/index.js +5 -2
  63. package/dist/slots/ContentTable/index.module.less +2 -1
  64. package/dist/slots/Detail/News.module.less +9 -9
  65. package/dist/slots/Detail/index.module.less +11 -14
  66. package/dist/slots/ExampleSider/index.module.less +3 -4
  67. package/dist/slots/Footer/index.module.less +2 -2
  68. package/dist/slots/Header/Products/Product.module.less +2 -2
  69. package/dist/slots/Header/Search/SearchResult.js +23 -8
  70. package/dist/slots/Header/Search/SearchResult.module.less +1 -0
  71. package/dist/slots/Header/index.js +56 -11
  72. package/dist/slots/Header/index.module.less +13 -5
  73. package/dist/slots/LiveExample/index.module.less +1 -1
  74. package/dist/slots/Loading/index.module.less +30 -28
  75. package/dist/slots/ManualContent/index.module.less +14 -17
  76. package/dist/slots/_.less +9 -9
  77. package/dist/static/user.svg +3 -0
  78. package/dist/utils/env.js +37 -0
  79. package/dist/utils/request.js +42 -0
  80. package/package.json +7 -2
@@ -10,39 +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";
23
21
  import { useTypewriter } from "../../../../hooks/useTypewriter";
22
+ import { authStore, showLoginModal } from "../../../../model/auth";
23
+ import { useSnapshot } from "valtio";
24
24
  var PLACEHOLDER = {
25
- implement: '今天,你想可视化什么?',
26
- solve: '今天,你想解决什么可视化问题?'
25
+ implement: 'ai.placeholder.implement',
26
+ solve: 'ai.placeholder.solve'
27
27
  };
28
- var uploadFileTooltip = '仅支持csv,json,tsv,txt文件,为了性能和成本,只会使用您数据的前几行作为样本';
29
- function PromptTextarea(props) {
28
+ export var PromptTextarea = /*#__PURE__*/React.memo(function PromptTextareaInner(props) {
30
29
  var value = props.value,
31
30
  size = props.size,
32
31
  _onChange = props.onChange,
32
+ onDataSummaryChange = props.onDataSummaryChange,
33
33
  onConfirm = props.onConfirm,
34
34
  onCancel = props.onCancel,
35
35
  loading = props.loading,
36
- fileMeta = props.fileMeta,
37
36
  mode = props.mode,
38
37
  lib = props.lib,
39
38
  onLibChange = props.onLibChange,
40
39
  _props$showAction = props.showAction,
41
40
  showAction = _props$showAction === void 0 ? true : _props$showAction;
42
- var _useState = useState(false),
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),
43
48
  _useState2 = _slicedToArray(_useState, 2),
44
- showError = _useState2[0],
45
- setShowError = _useState2[1];
49
+ fileMeta = _useState2[0],
50
+ setFileMeta = _useState2[1];
51
+
52
+ // ... 其他状态和hooks保持不变
46
53
  var _useState3 = useState(false),
47
54
  _useState4 = _slicedToArray(_useState3, 2),
48
55
  focus = _useState4[0],
@@ -51,14 +58,34 @@ function PromptTextarea(props) {
51
58
  var _useSiteData = useSiteData(),
52
59
  themeConfig = _useSiteData.themeConfig;
53
60
  var typedPlaceholder = useTypewriter({
54
- texts: ["".concat(themeConfig.title, "\u662F\u4EC0\u4E48\uFF1F"), ic(themeConfig.metas.description)]
61
+ texts: [formatMessage({
62
+ id: 'ai.placeholder.whatis'
63
+ }, {
64
+ title: themeConfig.title
65
+ }), ic(themeConfig.metas.description)]
55
66
  });
67
+
68
+ // 处理DataUploader的回调
69
+ var handleDataAnalyzed = function handleDataAnalyzed(analyzedData) {
70
+ setFileMeta(analyzedData.fileMeta);
71
+ if (onDataSummaryChange) {
72
+ onDataSummaryChange(analyzedData.dataSummary);
73
+ }
74
+ };
56
75
  function renderDatasourceCard() {
57
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
+ };
58
84
  return /*#__PURE__*/React.createElement(DatasourceCard, {
59
85
  type: fileMeta.type,
60
86
  title: fileMeta.fileName,
61
- desc: fileMeta.fileSize
87
+ desc: fileMeta.fileSize,
88
+ onDelete: handleClose
62
89
  });
63
90
  } else {
64
91
  return null;
@@ -66,14 +93,18 @@ function PromptTextarea(props) {
66
93
  }
67
94
  var datasourceNode = renderDatasourceCard();
68
95
  var promptTextValid = Boolean(value);
69
- var send = function send() {
70
- if (!promptTextValid) {
71
- message.warning('请输入指令');
72
- } else {
73
- setShowError(false);
96
+ var pureSend = function pureSend() {
97
+ if (promptTextValid) {
74
98
  onConfirm === null || onConfirm === void 0 || onConfirm();
75
99
  }
76
100
  };
101
+ var send = function send() {
102
+ if (!authSnap.isAuthenticated) {
103
+ showLoginModal(pureSend);
104
+ return;
105
+ }
106
+ pureSend();
107
+ };
77
108
  useEventListener('keydown', function (event) {
78
109
  if (event.key === 'Enter') {
79
110
  // 不区分 textarea 是否聚焦
@@ -82,6 +113,8 @@ function PromptTextarea(props) {
82
113
  send(); // 触发自定义事件
83
114
  }
84
115
  }
116
+ }, {
117
+ target: textareaRef
85
118
  });
86
119
  return /*#__PURE__*/React.createElement("div", {
87
120
  className: classnames(styles.container, _defineProperty(_defineProperty(_defineProperty({}, styles.active, focus), styles.compact, isCompact), styles.withDatasource, Boolean(datasourceNode))),
@@ -97,9 +130,12 @@ function PromptTextarea(props) {
97
130
  },
98
131
  id: "prompt-textarea",
99
132
  className: classnames(styles.promptTextarea),
133
+ ref: textareaRef,
100
134
  placeholder:
101
135
  // (!isCompact && !themeConfig.isAntVSite && ic(themeConfig.metas.description)) ||
102
- !isCompact && !themeConfig.isAntVSite ? typedPlaceholder : _.get(PLACEHOLDER, mode, '今天,你想可视化什么?'),
136
+ !isCompact && !themeConfig.isAntVSite ? typedPlaceholder : formatMessage({
137
+ id: _.get(PLACEHOLDER, mode, 'ai.placeholder.implement')
138
+ }),
103
139
  value: value,
104
140
  onChange: function onChange(evt) {
105
141
  _onChange(evt.target.value);
@@ -112,19 +148,7 @@ function PromptTextarea(props) {
112
148
  value: lib,
113
149
  onChange: onLibChange,
114
150
  size: size
115
- }), mode === AIMode.implement && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Tooltip, {
116
- title: isCompact ? "\u4E0A\u4F20\u6570\u636E\u3002".concat(uploadFileTooltip) : uploadFileTooltip
117
- }, /*#__PURE__*/React.createElement(Upload, null, /*#__PURE__*/React.createElement("button", {
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", {
151
+ }))), /*#__PURE__*/React.createElement("div", {
128
152
  className: styles.actions
129
153
  }, loading ? /*#__PURE__*/React.createElement("img", {
130
154
  className: styles.actionBtn,
@@ -133,7 +157,8 @@ function PromptTextarea(props) {
133
157
  }) : /*#__PURE__*/React.createElement(SendButton, {
134
158
  onClick: send,
135
159
  disabled: !promptTextValid,
136
- tip: !promptTextValid ? "\u8BF7\u8F93\u5165\u5185\u5BB9\u540E\u53D1\u9001\u6307\u4EE4" : undefined
160
+ tip: !promptTextValid ? formatMessage({
161
+ id: 'ai.msgbox.send.tip'
162
+ }) : undefined
137
163
  }))));
138
- }
139
- 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, 0.2);
10
+ border: 1px solid rgba(134, 144, 156, 20%);
11
11
  border-radius: 16px;
12
- background: #ffffff99;
13
- box-shadow: 8px 8px 20px 0px #0000000a, inset 1px -1px 0 0px #ffffffe3;
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, 0.89),
55
- 0 0 12px 0 rgba(250, 16, 16, 0.23);
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: #ffffff99;
78
+ background: #fff9;
78
79
  border: 1px solid #1677ff;
79
- box-shadow: 0px 8px 20px 0px #1677ff29, inset 1px -1px 0 0px #ffffffe3;
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, 0.85);
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
- var urlObj = new URL(location.href);
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
- }, "\u6848\u4F8B\u540D"), /*#__PURE__*/React.createElement("div", {
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
- }, "\u63CF\u8FF0\u4FE1\u606F"), /*#__PURE__*/React.createElement("div", {
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
- }, ((_AIModeMeta$tag = AIModeMeta[tag]) === null || _AIModeMeta$tag === void 0 ? void 0 : _AIModeMeta$tag.name) || tag)), /*#__PURE__*/React.createElement("div", {
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
@@ -8,7 +8,7 @@
8
8
  overflow: hidden;
9
9
  position: relative;
10
10
  aspect-ratio: 292 / 208;
11
- background: rgba(22, 119, 255, 0.06);
11
+ background: rgba(22, 119, 255, 6%);
12
12
 
13
13
  .typeTag {
14
14
  display: flex;
@@ -15,11 +15,15 @@ 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],
@@ -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
- try {
33
- setLoading(true);
34
- data = RecommendJson;
35
- setList(data.slice(0, 4));
36
- } catch (err) {
37
- console.log(err);
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
- case 1:
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
- }, "\u7CBE\u9009\u6848\u4F8B"), /*#__PURE__*/React.createElement("span", {
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), "\u6362\u4E00\u6279")), /*#__PURE__*/React.createElement(Spin, {
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, 0.6);
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
@@ -56,11 +61,19 @@ export function HomeDialog(props) {
56
61
  promptText: promptText,
57
62
  mode: mode,
58
63
  lib: lib,
59
- jump: true
64
+ jump: true,
65
+ context: fileSummary,
66
+ lang: locale.id
60
67
  });
61
68
  },
62
- style: props.promptTextareaStyle
69
+ style: props.promptTextareaStyle,
70
+ onDataSummaryChange: setFileSummary
63
71
  }), /*#__PURE__*/React.createElement(RecommendCase, {
64
- 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
+ }
65
78
  }));
66
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;