@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.
Files changed (88) 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/ModeSelectorDropdown.js +42 -0
  4. package/dist/components/AI/HomeDialog/ModeSelector/index.module.less +39 -22
  5. package/dist/components/AI/HomeDialog/PromptTextarea/ChooseLib/index.js +12 -4
  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/index.js +38 -36
  9. package/dist/components/AI/HomeDialog/PromptTextarea/index.module.less +8 -8
  10. package/dist/components/AI/HomeDialog/RecommendCase/Card.js +14 -11
  11. package/dist/components/AI/HomeDialog/RecommendCase/card.module.less +3 -3
  12. package/dist/components/AI/HomeDialog/RecommendCase/index.js +73 -24
  13. package/dist/components/AI/HomeDialog/RecommendCase/index.module.less +4 -2
  14. package/dist/components/AI/HomeDialog/RecommendCase/recommend.json +41 -17
  15. package/dist/components/AI/HomeDialog/index.js +21 -33
  16. package/dist/components/AI/constant.js +4 -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/hooks/useProducts.js +22 -1
  30. package/dist/layouts/DocLayout.js +2 -1
  31. package/dist/layouts/GlobalLayout/index.js +11 -4
  32. package/dist/locales/en.json +43 -2
  33. package/dist/locales/zh.json +43 -2
  34. package/dist/model/AIChat.js +93 -6
  35. package/dist/model/auth.js +147 -0
  36. package/dist/pages/AIPlayground/components/ConversationsMenu/index.js +15 -7
  37. package/dist/pages/AIPlayground/components/ConversationsMenu/index.module.less +2 -0
  38. package/dist/pages/AIPlayground/components/MarkdownComponent/MarkdownCodeBlock.js +26 -17
  39. package/dist/pages/AIPlayground/components/MarkdownComponent/MarkdownCodeBlock.module.less +1 -2
  40. package/dist/pages/AIPlayground/components/MarkdownComponent/index.js +7 -4
  41. package/dist/pages/AIPlayground/components/MsgBox/index.js +266 -149
  42. package/dist/pages/AIPlayground/components/MsgBox/index.module.less +3 -2
  43. package/dist/pages/AIPlayground/components/MsgBox/useAutoScroll.js +46 -0
  44. package/dist/pages/AIPlayground/components/SessionLayout/index.js +41 -12
  45. package/dist/pages/AIPlayground/components/SessionLayout/index.module.less +4 -4
  46. package/dist/pages/AIPlayground/components/TaskBox/generateCode.js +129 -8
  47. package/dist/pages/AIPlayground/components/TaskBox/index.js +92 -55
  48. package/dist/pages/AIPlayground/components/TaskBox/index.module.less +1 -0
  49. package/dist/pages/AIPlayground/index.js +4 -1
  50. package/dist/pages/AIPlayground/index.module.less +5 -0
  51. package/dist/pages/Examples/components/Accouncement/index.module.less +1 -1
  52. package/dist/pages/Examples/index.module.less +11 -11
  53. package/dist/pages/Index/components/Cases/index.module.less +8 -8
  54. package/dist/pages/Index/components/Companies/index.module.less +4 -3
  55. package/dist/pages/Index/components/Features/FeatureCard.module.less +4 -5
  56. package/dist/pages/Index/components/Features/index.module.less +5 -5
  57. package/dist/pages/Index/components/_.less +9 -9
  58. package/dist/slots/Banner/Notification.module.less +8 -8
  59. package/dist/slots/Banner/index.module.less +10 -9
  60. package/dist/slots/CodeEditor/Toolbar.js +7 -25
  61. package/dist/slots/CodeEditor/index.js +34 -12
  62. package/dist/slots/CodeEditor/index.module.less +3 -1
  63. package/dist/slots/CodeEditor/utils.js +2 -1
  64. package/dist/slots/CodePreview/index.module.less +0 -3
  65. package/dist/slots/CodeRunner/index.js +23 -11
  66. package/dist/slots/ContentTable/index.module.less +2 -1
  67. package/dist/slots/Detail/News.module.less +9 -9
  68. package/dist/slots/Detail/index.js +2 -1
  69. package/dist/slots/Detail/index.module.less +11 -14
  70. package/dist/slots/ExampleSider/index.module.less +3 -4
  71. package/dist/slots/Footer/index.module.less +2 -2
  72. package/dist/slots/Header/Products/Product.module.less +2 -2
  73. package/dist/slots/Header/Search/SearchResult.js +20 -8
  74. package/dist/slots/Header/Search/SearchResult.module.less +1 -0
  75. package/dist/slots/Header/index.js +51 -25
  76. package/dist/slots/Header/index.module.less +13 -5
  77. package/dist/slots/LiveExample/index.module.less +1 -1
  78. package/dist/slots/Loading/index.module.less +30 -28
  79. package/dist/slots/ManualContent/index.module.less +14 -17
  80. package/dist/slots/_.less +9 -9
  81. package/dist/static/user.svg +3 -0
  82. package/dist/typings.d.ts +6 -0
  83. package/dist/utils/analytics.js +16 -0
  84. package/dist/utils/env.js +63 -0
  85. package/dist/utils/index.js +7 -0
  86. package/dist/utils/request.js +42 -0
  87. package/package.json +9 -5
  88. package/dist/static/SearchAiIcon.svg +0 -14
@@ -9,45 +9,87 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
9
9
  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; } }
10
10
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
11
  import { Spin } from 'antd';
12
- import React, { useCallback, useEffect, useState } from 'react';
12
+ import React, { useEffect, useState } from 'react';
13
13
  import { Card } from "./Card";
14
14
  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 } from 'dumi';
18
+ import { FormattedMessage, useSiteData } from 'dumi';
19
+ import { sample, sampleSize } from "lodash-es";
20
+ import { AIChatStore } from "../../../../model/AIChat";
21
+ import { useAntVConfig } from "../../../../hooks/useProducts";
22
+ import { getBaseSiteDataUrl } from "../../../../utils/env";
19
23
  export var RecommendCase = function RecommendCase(props) {
20
24
  var _useState = useState(false),
21
25
  _useState2 = _slicedToArray(_useState, 2),
22
26
  loading = _useState2[0],
23
27
  setLoading = _useState2[1];
28
+ var _useSiteData = useSiteData(),
29
+ themeConfig = _useSiteData.themeConfig;
24
30
  var _useState3 = useState([]),
25
31
  _useState4 = _slicedToArray(_useState3, 2),
26
32
  list = _useState4[0],
27
33
  setList = _useState4[1];
28
- var fetchList = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
29
- var data;
30
- return _regeneratorRuntime().wrap(function _callee$(_context) {
31
- while (1) switch (_context.prev = _context.next) {
32
- case 0:
33
- try {
34
+ var _useAntVConfig = useAntVConfig(),
35
+ _useAntVConfig$data = _useAntVConfig.data,
36
+ _useAntVConfig$data2 = _useAntVConfig$data === void 0 ? {
37
+ library: []
38
+ } : _useAntVConfig$data,
39
+ _useAntVConfig$data2$ = _useAntVConfig$data2.library,
40
+ library = _useAntVConfig$data2$ === void 0 ? [] : _useAntVConfig$data2$;
41
+ var fetchList = /*#__PURE__*/function () {
42
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
43
+ var _themeConfig$ai, data, url;
44
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
45
+ while (1) switch (_context.prev = _context.next) {
46
+ case 0:
47
+ _context.prev = 0;
34
48
  setLoading(true);
49
+ data = [];
50
+ url = themeConfig.isAntVSite && library.length ? "".concat(getBaseSiteDataUrl(), "/").concat(sample(library).toLowerCase(), "/recommend.json") : (themeConfig === null || themeConfig === void 0 || (_themeConfig$ai = themeConfig.ai) === null || _themeConfig$ai === void 0 ? void 0 : _themeConfig$ai.recommend) || "".concat(getBaseSiteDataUrl(), "/").concat(themeConfig.title, "/recommend.json");
51
+ if (!url) {
52
+ _context.next = 10;
53
+ break;
54
+ }
55
+ _context.next = 7;
56
+ return fetch(url).then(function (res) {
57
+ return res.json();
58
+ });
59
+ case 7:
60
+ data = _context.sent;
61
+ _context.next = 11;
62
+ break;
63
+ case 10:
35
64
  data = RecommendJson;
36
- setList(data.slice(0, 4));
37
- } catch (err) {
38
- console.log(err);
39
- } finally {
65
+ case 11:
66
+ setList(sampleSize(data, 4));
67
+ _context.next = 18;
68
+ break;
69
+ case 14:
70
+ _context.prev = 14;
71
+ _context.t0 = _context["catch"](0);
72
+ setList(RecommendJson);
73
+ console.log(_context.t0);
74
+ case 18:
75
+ _context.prev = 18;
40
76
  setLoading(false);
41
- }
42
- case 1:
43
- case "end":
44
- return _context.stop();
45
- }
46
- }, _callee);
47
- })), [list]);
77
+ return _context.finish(18);
78
+ case 21:
79
+ case "end":
80
+ return _context.stop();
81
+ }
82
+ }, _callee, null, [[0, 14, 18, 21]]);
83
+ }));
84
+ return function fetchList() {
85
+ return _ref.apply(this, arguments);
86
+ };
87
+ }();
48
88
  useEffect(function () {
49
- fetchList();
50
- }, []);
89
+ if (library.length) {
90
+ fetchList();
91
+ }
92
+ }, [themeConfig.isAntVSite, library.length]);
51
93
  if (!list.length) {
52
94
  return null;
53
95
  }
@@ -59,14 +101,14 @@ export var RecommendCase = function RecommendCase(props) {
59
101
  className: styles.quickStart
60
102
  }, /*#__PURE__*/React.createElement(FormattedMessage, {
61
103
  id: "ai.recommend.title"
62
- })), /*#__PURE__*/React.createElement("span", {
104
+ })), (list === null || list === void 0 ? void 0 : list.length) > 4 ? /*#__PURE__*/React.createElement("span", {
63
105
  className: styles.refresh,
64
106
  onClick: function onClick() {
65
107
  return fetchList();
66
108
  }
67
109
  }, /*#__PURE__*/React.createElement(ReloadOutlined, null), /*#__PURE__*/React.createElement(FormattedMessage, {
68
110
  id: "ai.recommend.refresh"
69
- }))), /*#__PURE__*/React.createElement(Spin, {
111
+ })) : /*#__PURE__*/React.createElement(React.Fragment, null)), /*#__PURE__*/React.createElement(Spin, {
70
112
  spinning: loading,
71
113
  wrapperClassName: classnames(styles.listContainer, props.className)
72
114
  }, /*#__PURE__*/React.createElement("div", {
@@ -75,7 +117,14 @@ export var RecommendCase = function RecommendCase(props) {
75
117
  return /*#__PURE__*/React.createElement(Card, {
76
118
  key: item.caseId,
77
119
  item: item,
78
- index: index
120
+ index: index,
121
+ onClick: function onClick() {
122
+ var _props$onClick;
123
+ (_props$onClick = props.onClick) === null || _props$onClick === void 0 || _props$onClick.call(props, item);
124
+ if (item.tag) {
125
+ AIChatStore.mode = item.tag;
126
+ }
127
+ }
79
128
  });
80
129
  }))));
81
130
  };
@@ -1,7 +1,9 @@
1
1
  .container {
2
+ position: relative;
2
3
  margin-top: 32px;
3
4
  margin-left: auto;
4
5
  margin-right: auto;
6
+ z-index: 10;
5
7
  }
6
8
 
7
9
  .title {
@@ -27,15 +29,15 @@
27
29
  display: flex;
28
30
  gap: 2px;
29
31
  align-items: center;
30
-
31
32
  font-size: 12px;
32
- color: rgba(78, 89, 105, 0.6);
33
+ color: rgba(78, 89, 105, 60%);
33
34
  }
34
35
  }
35
36
 
36
37
  .listContainer {
37
38
  width: 100%;
38
39
  }
40
+
39
41
  .list {
40
42
  display: grid;
41
43
  grid-template-columns: repeat(4, 1fr);
@@ -2,41 +2,65 @@
2
2
  {
3
3
  "caseId": "1",
4
4
  "tag": "implement",
5
- "query": "一个城市过去五年来的年度降雨量分别是:2016年800毫米,2017年900毫米,2018年700毫米,2019年1000毫米,2020年1100毫米。使用折线图描绘这些数据。",
6
- "description": "自然语言描述需求,生成可视化代码",
5
+ "query": {
6
+ "zh": "你有一份公司多产品线销售数据:data = [ {month: '1月', productA: 12000, productB: 8500, productC: 15200}, {month: '2月', productA: 13500, productB: 9200, productC: 14800}, {month: '3月', productA: 15200, productB: 10800, productC: 16500}, {month: '4月', productA: 14800, productB: 11500, productC: 17200}, {month: '5月', productA: 16500, productB: 12200, productC: 18800}, {month: '6月', productA: 18200, productB: 13800, productC: 19500}, {month: '7月', productA: 19800, productB: 14500, productC: 20200}, {month: '8月', productA: 21500, productB: 15200, productC: 21800}, {month: '9月', productA: 20200, productB: 16800, productC: 22500}, {month: '10月', productA: 22800, productB: 17500, productC: 23200}, {month: '11月', productA: 24500, productB: 18200, productC: 24800}, {month: '12月', productA: 26200, productB: 19800, productC: 25500} ], 请绘制一个多折线图展示三条产品线的销售趋势变化,通过不同线型和颜色清晰区分各产品表现。 同时在最高点进行数据标注。",
7
+ "en": "You have multi-product line sales data for a company: data = [ {month: 'January', productA: 12000, productB: 8500, productC: 15200}, {month: 'February', productA: 13500, productB: 9200, productC: 14800}, {month: 'March', productA: 15200, productB: 10800, productC: 16500}, {month: 'April', productA: 14800, productB: 11500, productC: 17200}, {month: 'May', productA: 16500, productB: 12200, productC: 18800}, {month: 'June', productA: 18200, productB: 13800, productC: 19500}, {month: 'July', productA: 19800, productB: 14500, productC: 20200}, {month: 'August', productA: 21500, productB: 15200, productC: 21800}, {month: 'September', productA: 20200, productB: 16800, productC: 22500}, {month: 'October', productA: 22800, productB: 17500, productC: 23200}, {month: 'November', productA: 24500, productB: 18200, productC: 24800}, {month: 'December', productA: 26200, productB: 19800, productC: 25500} ]. Please draw a multi-line chart to show the sales trend changes of the three product lines, clearly distinguishing each product's performance through different line styles and colors. Also add data annotations at the highest points."
8
+ },
9
+ "description": {
10
+ "zh": "自然语言描述需求,生成可视化代码",
11
+ "en": "Natural language description of requirements, generate visualization code"
12
+ },
7
13
  "imageUrls": [
8
- "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*K5iUTrYme5QAAAAAQpAAAAgAemJ7AQ/original",
9
- "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*K5iUTrYme5QAAAAAQpAAAAgAemJ7AQ/original"
14
+ "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*zUKtR4U75fcAAAAAROAAAAgAemJ7AQ/original",
15
+ "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*zUKtR4U75fcAAAAAROAAAAgAemJ7AQ/original"
10
16
  ]
11
17
  },
12
18
  {
13
19
  "caseId": "2",
14
20
  "tag": "implement",
15
- "query": "使用文件中的数据,生成柱状图",
16
- "description": "多种数据源引入,专业图表生成,有数据就能生成图表。",
21
+ "query": {
22
+ "zh": "一家咖啡店的饮品销售比例为:咖啡 60%,茶 25%,果汁 15%。请用环图可视化这些饮品销售数据,并将色板调整为橙色系。",
23
+ "en": "A coffee shop's beverage sales ratio is: Coffee 60%, Tea 25%, Juice 15%. Please visualize these beverage sales data with a donut chart and adjust the color palette to orange tones."
24
+ },
25
+ "description": {
26
+ "zh": "自然语言描述需求,生成可视化代码",
27
+ "en": "Natural language description of requirements, generate visualization code"
28
+ },
17
29
  "imageUrls": [
18
- "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*K5iUTrYme5QAAAAAQpAAAAgAemJ7AQ/original",
19
- "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*K5iUTrYme5QAAAAAQpAAAAgAemJ7AQ/original"
30
+ "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*oMezTK-Yf2EAAAAAQmAAAAgAemJ7AQ/original",
31
+ "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*oMezTK-Yf2EAAAAAQmAAAAgAemJ7AQ/original"
20
32
  ]
21
33
  },
22
34
  {
23
35
  "caseId": "3",
24
- "tag": "implement",
25
- "query": "基于设计稿生成图表代码,还原视觉细节",
26
- "description": "基于设计稿生成图表代码,还原视觉细节",
36
+ "tag": "solve",
37
+ "query": {
38
+ "zh": "为什么配置了 state 没有生效?",
39
+ "en": "Why is the configured state not taking effect?"
40
+ },
41
+ "description": {
42
+ "zh": "精准定位并提供针对渲染异常、性能瓶颈及数据不匹配等问题的解决方案。",
43
+ "en": "Precisely locate and provide solutions for rendering anomalies, performance bottlenecks, and data mismatches."
44
+ },
27
45
  "imageUrls": [
28
- "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*K5iUTrYme5QAAAAAQpAAAAgAemJ7AQ/original",
29
- "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*K5iUTrYme5QAAAAAQpAAAAgAemJ7AQ/original"
46
+ "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*15mgQ4lA5CUAAAAASzAAAAgAemJ7AQ/original",
47
+ "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*15mgQ4lA5CUAAAAASzAAAAgAemJ7AQ/original"
30
48
  ]
31
49
  },
32
50
  {
33
51
  "caseId": "4",
34
52
  "tag": "solve",
35
- "query": "怎么配置堆叠面积图的描边为不同的颜色",
36
- "description": "精准定位并提供针对渲染异常、性能瓶颈及数据不匹配等问题的解决方案。",
53
+ "query": {
54
+ "zh": "数据标签互相遮挡了怎么办?",
55
+ "en": "What to do when data labels overlap each other?"
56
+ },
57
+ "description": {
58
+ "zh": "精准定位并提供针对渲染异常、性能瓶颈及数据不匹配等问题的解决方案。",
59
+ "en": "Precisely locate and provide solutions for rendering anomalies, performance bottlenecks, and data mismatches."
60
+ },
37
61
  "imageUrls": [
38
- "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*K5iUTrYme5QAAAAAQpAAAAgAemJ7AQ/original",
39
- "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*K5iUTrYme5QAAAAAQpAAAAgAemJ7AQ/original"
62
+ "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*thpQQIB3LG4AAAAASMAAAAgAemJ7AQ/original",
63
+ "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*thpQQIB3LG4AAAAASMAAAAgAemJ7AQ/original"
40
64
  ]
41
65
  }
42
66
  ]
@@ -10,65 +10,53 @@ import { AntVBanner } from "./AntVBanner";
10
10
  import { PromptTextarea } from "./PromptTextarea";
11
11
  import { RecommendCase } from "./RecommendCase";
12
12
  import { ModeSelector } from "./ModeSelector";
13
- import { useLocalStorageState } from 'ahooks';
14
- import { AIMode } from "../constant";
15
13
  import classnames from 'classnames';
16
- import { useSiteData, useLocale } from 'dumi';
17
- import { createNewSession } from "../../../model/AIChat";
14
+ import { useLocale } from 'dumi';
15
+ import { AIChatStore, createNewSession } from "../../../model/AIChat";
16
+ import { useSnapshot } from "valtio";
18
17
  export function HomeDialog(props) {
19
18
  var locale = useLocale();
20
- var _useSiteData = useSiteData(),
21
- themeConfig = _useSiteData.themeConfig;
22
- var _useState = useState(!themeConfig.isAntVSite ? themeConfig.title : undefined),
19
+ var lang = locale.id === 'zh' ? 'zh' : 'en';
20
+ var snap = useSnapshot(AIChatStore);
21
+ var _useState = useState(''),
23
22
  _useState2 = _slicedToArray(_useState, 2),
24
- lib = _useState2[0],
25
- setLib = _useState2[1];
26
- var _useLocalStorageState = useLocalStorageState('use-local-storage-ai-mode-type', {
27
- defaultValue: AIMode.implement
28
- }),
29
- _useLocalStorageState2 = _slicedToArray(_useLocalStorageState, 2),
30
- mode = _useLocalStorageState2[0],
31
- setMode = _useLocalStorageState2[1];
23
+ promptText = _useState2[0],
24
+ setPromptText = _useState2[1];
32
25
  var _useState3 = useState(''),
33
26
  _useState4 = _slicedToArray(_useState3, 2),
34
- promptText = _useState4[0],
35
- setPromptText = _useState4[1];
36
- var _useState5 = useState(''),
37
- _useState6 = _slicedToArray(_useState5, 2),
38
- fileSummary = _useState6[0],
39
- setFileSummary = _useState6[1];
27
+ fileSummary = _useState4[0],
28
+ setFileSummary = _useState4[1];
40
29
  return /*#__PURE__*/React.createElement("div", {
41
30
  className: classnames(styles.content, props.className),
42
31
  style: props.style
43
32
  }, /*#__PURE__*/React.createElement(AntVBanner, null), /*#__PURE__*/React.createElement(ModeSelector, {
44
33
  onChange: function onChange(v) {
45
- setMode(v);
46
- // todo 埋点
34
+ AIChatStore.mode = v;
47
35
  },
48
- value: mode
36
+ value: snap.mode
49
37
  }), /*#__PURE__*/React.createElement(PromptTextarea, {
50
- mode: mode,
51
38
  value: promptText,
52
- lib: lib,
53
- onLibChange: function onLibChange(v) {
54
- setLib(v);
55
- },
56
39
  onChange: function onChange(val) {
57
40
  setPromptText(val);
58
41
  },
59
42
  onConfirm: function onConfirm() {
60
43
  createNewSession({
61
44
  promptText: promptText,
62
- mode: mode,
63
- lib: lib,
45
+ mode: snap.mode,
64
46
  jump: true,
65
47
  context: fileSummary,
66
- lang: locale.id
48
+ lang: locale.id,
49
+ entry_point: 'home'
67
50
  });
68
51
  },
69
52
  style: props.promptTextareaStyle,
70
53
  onDataSummaryChange: setFileSummary
71
54
  }), /*#__PURE__*/React.createElement(RecommendCase, {
72
- className: props.recommendCaseClassName
55
+ className: props.recommendCaseClassName,
56
+ onClick: function onClick(val) {
57
+ if (val !== null && val !== void 0 && val.query) {
58
+ setPromptText(val.query[lang]);
59
+ }
60
+ }
73
61
  }));
74
62
  }
@@ -7,11 +7,13 @@ export var AIMode = {
7
7
  export var AIModeMeta = {
8
8
  implement: {
9
9
  name: 'ai.mode.implement',
10
- icon: /*#__PURE__*/React.createElement(BarChartOutlined, null)
10
+ icon: /*#__PURE__*/React.createElement(BarChartOutlined, null),
11
+ shortName: 'ai.mode.implement.short'
11
12
  },
12
13
  solve: {
13
14
  name: 'ai.mode.solve',
14
- icon: /*#__PURE__*/React.createElement(QuestionCircleOutlined, null)
15
+ icon: /*#__PURE__*/React.createElement(QuestionCircleOutlined, null),
16
+ shortName: 'ai.mode.solve.short'
15
17
  }
16
18
  };
17
19
 
@@ -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;
@@ -0,0 +1,91 @@
1
+ @primary-color: #873bf4;
2
+ @yuque-color-bg-primary-hover-light: #f5f5f5;
3
+ @yuque-color-bg-primary: #ffffff;
4
+ @yuque-grey-5: #bfbfbf;
5
+ @yuque-color-text-body: #595959;
6
+ @white: #ffffff;
7
+ @yuque-color-function-warning: #faad14;
8
+ @yuque-color-function-error: #ff4d4f;
9
+
10
+ .captcha {
11
+ margin-bottom: 16px;
12
+
13
+ .nc-lang-cnt {
14
+ color: #4c4c4c;
15
+ }
16
+
17
+ .nc-container {
18
+ border-radius: 4px;
19
+ overflow: hidden;
20
+
21
+ .nc_wrapper,
22
+ #nc_1_wrapper {
23
+ width: 100%;
24
+
25
+ .nc_scale {
26
+ height: 40px;
27
+ background: @yuque-color-bg-primary-hover-light;
28
+ width: auto;
29
+
30
+ .nc_bg {
31
+ width: 0;
32
+ background-color: @yuque-color-bg-primary;
33
+ border: 1px solid @yuque-grey-5;
34
+ border-right-width: 0;
35
+ border-radius: 4px 0 0 4px;
36
+ }
37
+
38
+ .scale_text {
39
+ color: @yuque-color-text-body;
40
+ font-size: 16px;
41
+ }
42
+
43
+ .scale_text2 {
44
+ color: @white;
45
+ font-size: 16px;
46
+ }
47
+
48
+ span {
49
+ border: none;
50
+ height: 40px;
51
+ line-height: 40px;
52
+ border-radius: 4px;
53
+ font-size: 14px;
54
+
55
+ &.btn_slide {
56
+ border: 1px solid @yuque-grey-5;
57
+ }
58
+
59
+ &.btn_ok {
60
+ border: 1px solid @yuque-grey-5;
61
+ border-radius: 0 4px 4px 0;
62
+ color: #4c4c4c;
63
+ }
64
+ }
65
+ }
66
+ }
67
+
68
+ .errloading {
69
+ width: 100%;
70
+ height: 40px;
71
+ line-height: 22px;
72
+ border-radius: 4px;
73
+ border: 1px solid @yuque-color-function-warning;
74
+
75
+ .nc_iconfont {
76
+ color: @yuque-color-function-error;
77
+ }
78
+
79
+ span {
80
+ color: @yuque-color-function-warning;
81
+ font-size: 14px;
82
+ }
83
+ }
84
+ }
85
+
86
+ .captcha-tip {
87
+ .ant-form-item-control-input {
88
+ min-height: auto;
89
+ }
90
+ }
91
+ }