@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.
Files changed (84) 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 +66 -34
  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 +46 -14
  14. package/dist/components/AI/HomeDialog/RecommendCase/index.module.less +3 -2
  15. package/dist/components/AI/HomeDialog/index.js +18 -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/hooks/useStreamingText.js +38 -18
  30. package/dist/hooks/useTypewriter.js +69 -0
  31. package/dist/layouts/DocLayout.js +2 -1
  32. package/dist/layouts/GlobalLayout/index.js +10 -4
  33. package/dist/locales/en.json +121 -1
  34. package/dist/locales/zh.json +121 -1
  35. package/dist/model/AIChat.js +79 -11
  36. package/dist/model/auth.js +133 -0
  37. package/dist/pages/AIPlayground/components/ConversationsMenu/index.js +31 -10
  38. package/dist/pages/AIPlayground/components/ConversationsMenu/index.module.less +2 -0
  39. package/dist/pages/AIPlayground/components/MarkdownComponent/MarkdownCodeBlock.js +47 -20
  40. package/dist/pages/AIPlayground/components/MarkdownComponent/MarkdownCodeBlock.module.less +13 -0
  41. package/dist/pages/AIPlayground/components/MarkdownComponent/index.js +6 -3
  42. package/dist/pages/AIPlayground/components/MsgBox/index.js +250 -106
  43. package/dist/pages/AIPlayground/components/MsgBox/index.module.less +3 -2
  44. package/dist/pages/AIPlayground/components/MsgBox/useAutoScroll.js +46 -0
  45. package/dist/pages/AIPlayground/components/SessionLayout/index.js +18 -10
  46. package/dist/pages/AIPlayground/components/SessionLayout/index.module.less +3 -1
  47. package/dist/pages/AIPlayground/components/TaskBox/generateCode.js +10 -5
  48. package/dist/pages/AIPlayground/components/TaskBox/index.js +79 -54
  49. package/dist/pages/AIPlayground/components/TaskBox/index.module.less +1 -0
  50. package/dist/pages/Examples/components/Accouncement/index.module.less +1 -1
  51. package/dist/pages/Examples/index.module.less +11 -11
  52. package/dist/pages/Index/components/Cases/index.module.less +8 -8
  53. package/dist/pages/Index/components/Companies/index.module.less +4 -3
  54. package/dist/pages/Index/components/Features/FeatureCard.module.less +4 -5
  55. package/dist/pages/Index/components/Features/index.module.less +5 -5
  56. package/dist/pages/Index/components/_.less +9 -9
  57. package/dist/plugin/index.js +2 -2
  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 +20 -8
  61. package/dist/slots/CodeEditor/Toolbar.module.less +1 -0
  62. package/dist/slots/CodeEditor/index.js +30 -10
  63. package/dist/slots/CodeEditor/index.module.less +3 -0
  64. package/dist/slots/CodePreview/index.module.less +0 -3
  65. package/dist/slots/CodeRunner/index.js +6 -2
  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.module.less +11 -14
  69. package/dist/slots/ExampleSider/index.module.less +3 -4
  70. package/dist/slots/Footer/index.module.less +2 -2
  71. package/dist/slots/Header/Products/Product.module.less +2 -2
  72. package/dist/slots/Header/Search/SearchResult.js +23 -7
  73. package/dist/slots/Header/Search/SearchResult.module.less +1 -0
  74. package/dist/slots/Header/index.js +56 -11
  75. package/dist/slots/Header/index.module.less +13 -5
  76. package/dist/slots/LiveExample/index.module.less +1 -1
  77. package/dist/slots/Loading/index.module.less +30 -28
  78. package/dist/slots/ManualContent/index.module.less +14 -17
  79. package/dist/slots/_.less +9 -9
  80. package/dist/static/user.svg +3 -0
  81. package/dist/utils/code.js +35 -0
  82. package/dist/utils/env.js +37 -0
  83. package/dist/utils/request.js +42 -0
  84. package/package.json +7 -2
@@ -83,6 +83,7 @@
83
83
 
84
84
 
85
85
  .ai {
86
+ cursor: pointer;
86
87
  margin-right: 10px;
87
88
  font-size: 12px;
88
89
  }
@@ -15,7 +15,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
15
  import MonacoEditor, { loader } from '@monaco-editor/react';
16
16
  import { Drawer, Switch } from 'antd';
17
17
  import { autoType as d3AutoType, dsvFormat } from 'd3-dsv';
18
- import { useLocale, useSiteData } from 'dumi';
18
+ import { useLocale, useSiteData, useIntl, useLocation } from 'dumi';
19
19
  import { debounce, noop } from 'lodash-es';
20
20
  import { format } from 'prettier';
21
21
  import parserBabel from 'prettier/parser-babel';
@@ -57,10 +57,14 @@ var CodeEditor = function CodeEditor(_ref) {
57
57
  _ref$onError = _ref.onError,
58
58
  onError = _ref$onError === void 0 ? noop : _ref$onError,
59
59
  _ref$onFullscreen = _ref.onFullscreen,
60
- onFullscreen = _ref$onFullscreen === void 0 ? noop : _ref$onFullscreen;
60
+ onFullscreen = _ref$onFullscreen === void 0 ? noop : _ref$onFullscreen,
61
+ _ref$showAI = _ref.showAI,
62
+ showAI = _ref$showAI === void 0 ? true : _ref$showAI;
63
+ var umiLocation = useLocation();
61
64
  var locale = useLocale();
62
65
  var _useSiteData = useSiteData(),
63
66
  themeConfig = _useSiteData.themeConfig;
67
+ var intl = useIntl();
64
68
  var _themeConfig$es = themeConfig.es5,
65
69
  es5 = _themeConfig$es === void 0 ? true : _themeConfig$es,
66
70
  _themeConfig$showSpec = themeConfig.showSpecTab,
@@ -103,8 +107,8 @@ var CodeEditor = function CodeEditor(_ref) {
103
107
  setCurrentEditorTab = _useState12[1];
104
108
  var _useState13 = useState(false),
105
109
  _useState14 = _slicedToArray(_useState13, 2),
106
- showAI = _useState14[0],
107
- setShowAI = _useState14[1];
110
+ showAIDrawer = _useState14[0],
111
+ setShowAIDrawer = _useState14[1];
108
112
  var containerId = "playgroundScriptContainer_".concat(exampleId);
109
113
 
110
114
  // 出发 auto resize
@@ -280,6 +284,7 @@ var CodeEditor = function CodeEditor(_ref) {
280
284
  // 用于更新当前 example 的 spec 和 data
281
285
  useEffect(function () {
282
286
  setCurrentEditorTab(EDITOR_TABS.JAVASCRIPT);
287
+ setShowAIDrawer(false);
283
288
  }, [exampleId]);
284
289
 
285
290
  // hook 用户的数据
@@ -383,7 +388,10 @@ var CodeEditor = function CodeEditor(_ref) {
383
388
  }
384
389
  };
385
390
  var onClickAI = function onClickAI() {
386
- setShowAI(true);
391
+ setShowAIDrawer(true);
392
+ };
393
+ var onReload = function onReload() {
394
+ setCode(source);
387
395
  };
388
396
  return /*#__PURE__*/React.createElement("div", {
389
397
  className: styles.editor
@@ -402,6 +410,8 @@ var CodeEditor = function CodeEditor(_ref) {
402
410
  onEditorTabChange: onTabChange,
403
411
  onToggleFullscreen: onFullscreen,
404
412
  onClickAI: onClickAI,
413
+ showAI: showAI,
414
+ onReload: onReload,
405
415
  slots: {
406
416
  Spec: /*#__PURE__*/React.createElement("span", {
407
417
  style: {
@@ -456,20 +466,30 @@ var CodeEditor = function CodeEditor(_ref) {
456
466
  }), /*#__PURE__*/React.createElement(Drawer, {
457
467
  placement: "right",
458
468
  closable: true,
459
- open: showAI,
469
+ open: showAIDrawer,
460
470
  getContainer: false,
461
471
  onClose: function onClose() {
462
- return setShowAI(false);
472
+ return setShowAIDrawer(false);
463
473
  },
464
- rootClassName: styles.drawer
474
+ rootClassName: styles.drawer,
475
+ width: '80%',
476
+ key: "".concat(umiLocation.hash, "_").concat(umiLocation.key)
465
477
  }, /*#__PURE__*/React.createElement(MsgBox, {
478
+ key: "".concat(umiLocation.hash, "_").concat(umiLocation.key),
466
479
  simple: true,
467
480
  messages: [{
468
481
  id: crypto.randomUUID(),
469
482
  role: 'assistant',
470
- content: "\u6211\u662FAntV AI\u52A9\u624B\u3002\u60A8\u53EF\u4EE5\u968F\u65F6\u5411\u6211\u63D0\u95EE\uFF0C\u8BA9\u6211\u4E3A\u60A8\uFF1A\n \n1\u3001\u89E3\u8BFB\u5F53\u524D\u56FE\u8868\u7684\u4EE3\u7801\u914D\u7F6E\u3002\n \n2\u3001\u901A\u8FC7\u81EA\u7136\u8BED\u8A00\u5BF9\u8BDD\uFF0C\u57FA\u4E8E\u5F53\u524D\u6848\u4F8B\u751F\u6210\u65B0\u4EE3\u7801\u4EE5\u5B9A\u5236\u56FE\u8868\u3002",
483
+ content: intl.formatMessage({
484
+ id: 'ai.assistant.editor.intro'
485
+ }),
471
486
  createdAt: Date.now()
472
- }]
487
+ }],
488
+ context: valueOf(tab),
489
+ onCodegen: function onCodegen(codeBlock) {
490
+ setCode(codeBlock);
491
+ },
492
+ title: title
473
493
  })));
474
494
  }));
475
495
  };
@@ -12,9 +12,11 @@
12
12
 
13
13
  .drawer{
14
14
  margin-top: 36px;
15
+
15
16
  :global {
16
17
  .ant-drawer-content {
17
18
  background: #f8f9fc;
19
+
18
20
  div.ant-drawer-header {
19
21
  padding-bottom: unset;
20
22
  border-bottom: unset;
@@ -24,6 +26,7 @@
24
26
  flex: unset;
25
27
  }
26
28
  }
29
+
27
30
  .ant-drawer-body{
28
31
  display: flex;
29
32
  flex-direction: column;
@@ -2,10 +2,8 @@
2
2
  width: 100%;
3
3
  height: 100%;
4
4
  position: relative;
5
-
6
5
  padding: 24px;
7
6
  overflow: auto;
8
-
9
7
  display: flex;
10
8
  flex-direction: column;
11
9
 
@@ -46,7 +44,6 @@
46
44
  position: absolute;
47
45
  top: 0;
48
46
  left: 0;
49
-
50
47
  background: #fff;
51
48
  }
52
49
  }
@@ -32,7 +32,9 @@ var CodeRunner = function CodeRunner(_ref) {
32
32
  replaceId = _ref.replaceId,
33
33
  isPlayground = _ref.isPlayground,
34
34
  _ref$notFound = _ref.notFound,
35
- notFound = _ref$notFound === void 0 ? /*#__PURE__*/React.createElement(NotFound, null) : _ref$notFound;
35
+ notFound = _ref$notFound === void 0 ? /*#__PURE__*/React.createElement(NotFound, null) : _ref$notFound,
36
+ _ref$showAI = _ref.showAI,
37
+ showAI = _ref$showAI === void 0 ? true : _ref$showAI;
36
38
  var demoInfo = getDemoInfo(exampleTopics, topic, example, demo);
37
39
 
38
40
  // 找不到,啥也别干了,404 页面
@@ -79,7 +81,9 @@ var CodeRunner = function CodeRunner(_ref) {
79
81
  onFullscreen: setFullscreen,
80
82
  onDestroy: noop,
81
83
  onReady: noop,
82
- playground: playground
84
+ playground: playground,
85
+ title: ic(title),
86
+ showAI: showAI
83
87
  }))));
84
88
  };
85
89
  export default CodeRunner;
@@ -1,8 +1,9 @@
1
1
  :global {
2
2
  ul.dumi-default-toc {
3
3
  > li {
4
- margin-left: 0px !important;
4
+ margin-left: 0 !important;
5
5
  }
6
+
6
7
  .active {
7
8
  color: #873bf4 !important;
8
9
  border-left: 3px solid #873bf4 !important;
@@ -1,9 +1,9 @@
1
1
  .news {
2
2
  width: 50%;
3
3
  margin-right: 2%;
4
- background-color: #ffffff;
4
+ background-color: #fff;
5
5
  border: 1px solid #e5e8ef;
6
- box-shadow: 0 8px 28px 0 rgba(0, 0, 0, 0.05);
6
+ box-shadow: 0 8px 28px 0 rgba(0, 0, 0, 5%);
7
7
  border-radius: 16px;
8
8
  height: 100%;
9
9
  font-size: 14px;
@@ -91,13 +91,13 @@
91
91
  @keyframes showAndHide0 {
92
92
  0% {
93
93
  opacity: 1;
94
- top: 0px;
94
+ top: 0;
95
95
  z-index: 1;
96
96
  }
97
97
 
98
98
  33.3% {
99
99
  opacity: 0;
100
- top: 0px;
100
+ top: 0;
101
101
  z-index: 0;
102
102
  }
103
103
 
@@ -109,7 +109,7 @@
109
109
 
110
110
  100% {
111
111
  opacity: 1;
112
- top: 0px;
112
+ top: 0;
113
113
  z-index: 1;
114
114
  }
115
115
  }
@@ -123,13 +123,13 @@
123
123
 
124
124
  33.3% {
125
125
  opacity: 1;
126
- top: 0px;
126
+ top: 0;
127
127
  z-index: 1;
128
128
  }
129
129
 
130
130
  66.6% {
131
131
  opacity: 0;
132
- top: 0px;
132
+ top: 0;
133
133
  z-index: 0;
134
134
  }
135
135
 
@@ -155,13 +155,13 @@
155
155
 
156
156
  66.6% {
157
157
  opacity: 1;
158
- top: 0px;
158
+ top: 0;
159
159
  z-index: 1;
160
160
  }
161
161
 
162
162
  100% {
163
163
  opacity: 0;
164
- top: 0px;
164
+ top: 0;
165
165
  z-index: 0;
166
166
  }
167
167
  }
@@ -3,13 +3,14 @@
3
3
  .wrapper {
4
4
  min-height: 1000px;
5
5
  max-height: 1150px;
6
- background: linear-gradient(225deg, #ffffff, #f0f5ff);
6
+ background: linear-gradient(225deg, #fff, #f0f5ff);
7
7
  height: calc(94vh);
8
8
  position: relative;
9
9
  overflow: hidden;
10
10
 
11
11
  .content {
12
12
  .container1440();
13
+
13
14
  height: 100%;
14
15
  position: relative;
15
16
  }
@@ -28,7 +29,7 @@
28
29
 
29
30
  .title {
30
31
  font-size: 3.4em; //2.875em;
31
- color: rgba(0, 0, 0, 1);
32
+ color: rgba(0, 0, 0, 100%);
32
33
  position: relative;
33
34
  font-family: AlibabaPuHuiTiRHeavy;
34
35
 
@@ -39,8 +40,7 @@
39
40
 
40
41
  .description {
41
42
  margin-top: 0.83%; //12px;
42
- margin-bottom: 0px;
43
- color: rgba(106, 123, 140, 1);
43
+ margin-bottom: 0;
44
44
  font-weight: 200;
45
45
  position: relative;
46
46
  width: 40%;
@@ -52,7 +52,7 @@
52
52
  overflow: hidden;
53
53
  text-overflow: ellipsis;
54
54
  -webkit-line-clamp: 4;
55
- display: -webkit-box;
55
+ display: box;
56
56
  -webkit-box-orient: vertical;
57
57
  }
58
58
 
@@ -64,7 +64,6 @@
64
64
  display: flex;
65
65
  align-items: center;
66
66
  justify-content: center;
67
- cursor: pointer;
68
67
  border-radius: 12px;
69
68
  z-index: 10;
70
69
  position: relative;
@@ -73,13 +72,12 @@
73
72
  height: 54px;
74
73
  min-width: 166px;
75
74
  padding: 0 10px;
76
- box-shadow: 0 8px 28px 0 rgba(0, 0, 0, 0.1);
77
75
  background-color: #691eff;
78
76
  font-size: 18px;
79
77
  cursor: pointer;
80
78
  box-shadow: 0 8px 28px 0 #f2f2f2;
81
79
  margin-right: 20px;
82
- color: #ffffff;
80
+ color: #fff;
83
81
  overflow: hidden;
84
82
 
85
83
  .icon {
@@ -94,8 +92,7 @@
94
92
  }
95
93
 
96
94
  &.primary {
97
- color: #fff;
98
- background-color: #ffffff;
95
+ background-color: #fff;
99
96
  color: #000;
100
97
  border: 1px solid #e8e8e8;
101
98
 
@@ -123,8 +120,8 @@
123
120
  display: flex;
124
121
  height: 54px;
125
122
  cursor: pointer;
126
- box-shadow: 0 8px 28px 0 rgba(0, 0, 0, 0.05);
127
- background-color: #ffffff;
123
+ box-shadow: 0 8px 28px 0 rgba(0, 0, 0, 5%);
124
+ background-color: #fff;
128
125
  border: 1px solid #e8e8e8;
129
126
  justify-content: center;
130
127
  align-items: center;
@@ -146,6 +143,7 @@
146
143
 
147
144
  .gh-btn {
148
145
  padding: 16px;
146
+
149
147
  .gh-ico {
150
148
  display: block;
151
149
  width: 20px;
@@ -172,7 +170,7 @@
172
170
  margin-left: -8px;
173
171
  color: #1d2129;
174
172
  letter-spacing: 0;
175
- font-family: AlibabaSans102-Medium;
173
+ font-family: "AlibabaSans102-Medium";
176
174
  }
177
175
  }
178
176
  }
@@ -195,7 +193,6 @@
195
193
  display: flex;
196
194
  position: absolute;
197
195
  right: 0;
198
- margin-top: -300px;
199
196
  width: 32%;
200
197
  max-width: 598px;
201
198
  height: 324px;
@@ -11,7 +11,7 @@
11
11
  z-index: 1;
12
12
  top: 0;
13
13
  height: 100%;
14
- box-shadow: 0 0 6px 2px rgba(0, 0, 0, 0);
14
+ box-shadow: 0 0 6px 2px rgba(0, 0, 0, 0%);
15
15
  width: 1px;
16
16
  transition: all 0.3s;
17
17
  }
@@ -45,7 +45,7 @@
45
45
  user-select: none;
46
46
  background-color: #fff;
47
47
 
48
- &:after {
48
+ &::after {
49
49
  transition: all 0.3s;
50
50
  background-color: transparent;
51
51
  border: 1px solid transparent;
@@ -60,7 +60,7 @@
60
60
  &:hover {
61
61
  border-color: var(--primary-color);
62
62
 
63
- &:before {
63
+ &::before {
64
64
  transition: all 0.3s;
65
65
  content: '';
66
66
  position: absolute;
@@ -127,7 +127,6 @@
127
127
  display: inline-block;
128
128
  width: 100%;
129
129
  vertical-align: bottom;
130
-
131
130
  overflow: hidden;
132
131
  text-overflow: ellipsis;
133
132
  white-space: nowrap;
@@ -36,7 +36,7 @@
36
36
  display: flex;
37
37
  justify-content: center;
38
38
  font-size: 14px;
39
- border-bottom: 1px solid rgba(255, 255, 255, 0.25);
39
+ border-bottom: 1px solid rgba(255, 255, 255, 25%);
40
40
  margin-bottom: 16px;
41
41
  box-sizing: border-box;
42
42
  padding-bottom: 16px;
@@ -72,7 +72,7 @@
72
72
  :global(.anticon),
73
73
  a {
74
74
  margin-right: 8px;
75
- color: rgba(255, 255, 255, 0.6);
75
+ color: rgba(255, 255, 255, 60%);
76
76
  }
77
77
 
78
78
  &.light {
@@ -57,7 +57,7 @@
57
57
  ul {
58
58
  list-style: none;
59
59
  padding: 0;
60
- margin: 0 0 20px 0;
60
+ margin: 0 0 20px;
61
61
 
62
62
  &:last-child {
63
63
  margin-bottom: 32px;
@@ -87,7 +87,7 @@
87
87
  margin-bottom: 4px;
88
88
  font-size: 14px;
89
89
  line-height: 22px;
90
- color: rgba(0, 0, 0, 0.85);
90
+ color: rgba(0, 0, 0, 85%);
91
91
  transition: all 0.3s;
92
92
 
93
93
  &:hover {
@@ -3,6 +3,8 @@ import React from 'react';
3
3
  import styles from "./SearchResult.module.less";
4
4
  import classnames from "classnames";
5
5
  import { createNewSession } from "../../../model/AIChat";
6
+ import { authStore, showLoginModal } from "../../../model/auth";
7
+ import { useSnapshot } from "valtio";
6
8
  var getHighlightInfo = function getHighlightInfo(textSegments) {
7
9
  return /*#__PURE__*/React.createElement(React.Fragment, null, textSegments.map(function (segment) {
8
10
  return /*#__PURE__*/React.createElement("span", {
@@ -21,6 +23,16 @@ export var SearchResult = function SearchResult(_ref) {
21
23
  var _useSiteData = useSiteData(),
22
24
  themeConfig = _useSiteData.themeConfig;
23
25
  var intl = useIntl();
26
+ var authSnap = useSnapshot(authStore);
27
+ function pureSearch() {
28
+ createNewSession({
29
+ promptText: keywords,
30
+ mode: 'solve',
31
+ lib: !themeConfig.isAntVSite ? themeConfig.title : undefined,
32
+ jump: true,
33
+ lang: intl.locale === 'zh' ? 'zh' : 'en'
34
+ });
35
+ }
24
36
  return /*#__PURE__*/React.createElement("div", {
25
37
  className: styles.searchResult
26
38
  }, /*#__PURE__*/React.createElement("div", {
@@ -35,19 +47,23 @@ export var SearchResult = function SearchResult(_ref) {
35
47
  }), /*#__PURE__*/React.createElement("a", {
36
48
  className: styles.result,
37
49
  onClick: function onClick() {
38
- createNewSession({
39
- promptText: keywords,
40
- mode: "solve",
41
- lib: !themeConfig.isAntVSite ? themeConfig.title : undefined
42
- });
50
+ if (!authSnap.isAuthenticated) {
51
+ showLoginModal(pureSearch);
52
+ return;
53
+ }
54
+ pureSearch();
43
55
  }
44
56
  }, /*#__PURE__*/React.createElement("div", {
45
57
  className: classnames(styles.title, styles.highlighted)
46
58
  }, keywords), /*#__PURE__*/React.createElement("div", {
47
59
  className: styles.description
48
- }, "\u8BD5\u8BD5\xA0", /*#__PURE__*/React.createElement("span", {
60
+ }, intl.formatMessage({
61
+ id: 'ai.search.try'
62
+ }), "\xA0", /*#__PURE__*/React.createElement("span", {
49
63
  className: styles.highlighted
50
- }, "AI"), "\xA0\u53EF\u89C6\u5316\u7B54\u7591"))), results !== null && results !== void 0 && results.length ? results.map(function (r, index) {
64
+ }, "AI"), "\xA0", intl.formatMessage({
65
+ id: 'ai.search.visualization'
66
+ })))), results !== null && results !== void 0 && results.length ? results.map(function (r, index) {
51
67
  return /*#__PURE__*/React.createElement("div", {
52
68
  className: styles.item,
53
69
  key: index
@@ -51,6 +51,7 @@
51
51
  color: rgb(160, 161, 167);
52
52
  max-height: 55px;
53
53
  overflow: hidden;
54
+
54
55
  .segment {
55
56
  padding-left: 1px;
56
57
  padding-right: 1px;
@@ -13,7 +13,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
13
13
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
14
14
  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; } }
15
15
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
- import { CaretDownFilled, DownOutlined, GithubOutlined, LinkOutlined, MenuOutlined, WechatOutlined } from '@ant-design/icons';
16
+ import { CaretDownFilled, DownOutlined, GithubOutlined, LinkOutlined, LogoutOutlined, MenuOutlined, UserDeleteOutlined, WechatOutlined } from '@ant-design/icons';
17
17
  import { Alert, Button, Dropdown, Menu, Modal, Popover } from 'antd';
18
18
  import cx from 'classnames';
19
19
  import { FormattedMessage, Link, useLocale, useSiteData } from 'dumi';
@@ -26,11 +26,15 @@ import { Navs } from "./Navs";
26
26
  import { Products } from "./Products";
27
27
  import { Search } from "./Search";
28
28
  import { findVersion } from "./utils";
29
+ import { ReactComponent as UserIcon } from "../../static/user.svg";
29
30
  import { Assistant } from '@petercatai/assistant';
30
31
  import '@petercatai/assistant/style';
31
32
  import { useLocation } from 'react-router-dom';
32
33
  import { determineUserType } from "../../utils/user";
33
34
  import styles from "./index.module.less";
35
+ import { useSnapshot } from "valtio";
36
+ import { authStore, logout } from "../../model/auth";
37
+ import { clearAllChatData } from "../../model/AIChat";
34
38
  function redirectChinaMirror(chinaMirrorOrigin) {
35
39
  window.location.href = window.location.href.replace(window.location.origin, chinaMirrorOrigin);
36
40
  }
@@ -76,7 +80,7 @@ var HeaderComponent = function HeaderComponent(_ref) {
76
80
  ecosystems = _ref.ecosystems,
77
81
  announcement = _ref.announcement;
78
82
  var isAntVHome = isAntVSite && isHomePage; // 是否为AntV官网首页
79
-
83
+ var authSnap = useSnapshot(authStore);
80
84
  var _useState = useState(false),
81
85
  _useState2 = _slicedToArray(_useState, 2),
82
86
  bannerVisible = _useState2[0],
@@ -195,7 +199,9 @@ var HeaderComponent = function HeaderComponent(_ref) {
195
199
  href: href,
196
200
  target: "_blank",
197
201
  rel: "noreferrer"
198
- }, "AI\u751F\u7801"));
202
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
203
+ id: "header.ai.code"
204
+ })));
199
205
  }, [isInternalUser, showWeavefox]);
200
206
  var menu = /*#__PURE__*/React.createElement("ul", {
201
207
  className: cx(styles.menu, _defineProperty(_defineProperty({}, styles.popup, !isWide), styles.popupHidden, !popupMenuVisible))
@@ -235,7 +241,9 @@ var HeaderComponent = function HeaderComponent(_ref) {
235
241
  style: {
236
242
  marginRight: '8px'
237
243
  }
238
- }, "\uD83C\uDDE8\uD83C\uDDF3"), "AntV \u7CFB\u5217\u7F51\u7AD9\u90E8\u7F72\u5728 gh-pages \u4E0A\uFF0C\u82E5\u8BBF\u95EE\u901F\u5EA6\u4E0D\u4F73\uFF0C\u53EF\u4EE5\u524D\u5F80\u56FD\u5185\u955C\u50CF\u7AD9\u70B9\u3002"), /*#__PURE__*/React.createElement("div", {
244
+ }, "\uD83C\uDDE8\uD83C\uDDF3"), /*#__PURE__*/React.createElement(FormattedMessage, {
245
+ id: "header.china.mirror.title"
246
+ })), /*#__PURE__*/React.createElement("div", {
239
247
  style: {
240
248
  marginTop: 16,
241
249
  textAlign: 'right'
@@ -248,14 +256,18 @@ var HeaderComponent = function HeaderComponent(_ref) {
248
256
  style: {
249
257
  marginRight: 8
250
258
  }
251
- }, "\u6682\u65F6\u5173\u95ED"), /*#__PURE__*/React.createElement(Button, {
259
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
260
+ id: "header.china.mirror.temp.close"
261
+ })), /*#__PURE__*/React.createElement(Button, {
252
262
  type: "primary",
253
263
  size: "small",
254
264
  onClick: function onClick() {
255
265
  localStorage.setItem('china-mirror-no-more-hint', Date.now().toString());
256
266
  updateChinaMirrorHintVisible(false);
257
267
  }
258
- }, "\u4E0D\u518D\u63D0\u9192"))),
268
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
269
+ id: "header.china.mirror.no.more"
270
+ })))),
259
271
  open: chinaMirrorHintVisible,
260
272
  placement: "bottomRight",
261
273
  align: {
@@ -273,8 +285,12 @@ var HeaderComponent = function HeaderComponent(_ref) {
273
285
  }
274
286
  })))) : null, showChinaMirror && !isWide && /*#__PURE__*/React.createElement(Modal, {
275
287
  open: chinaMirrorHintVisible,
276
- cancelText: "\u4E0D\u518D\u63D0\u9192",
277
- okText: "\u7ACB\u5373\u524D\u5F80",
288
+ cancelText: /*#__PURE__*/React.createElement(FormattedMessage, {
289
+ id: "header.china.mirror.no.more"
290
+ }),
291
+ okText: /*#__PURE__*/React.createElement(FormattedMessage, {
292
+ id: "header.china.mirror.temp.close"
293
+ }),
278
294
  onCancel: function onCancel() {
279
295
  updateChinaMirrorHintVisible(false);
280
296
  },
@@ -292,7 +308,9 @@ var HeaderComponent = function HeaderComponent(_ref) {
292
308
  }, /*#__PURE__*/React.createElement("span", {
293
309
  role: "img",
294
310
  "aria-labelledby": "\u4E2D\u56FD"
295
- }, "\uD83C\uDDE8\uD83C\uDDF3"), "AntV \u7CFB\u5217\u7F51\u7AD9\u90E8\u7F72\u5728 gh-pages \u4E0A\uFF0C\u82E5\u8BBF\u95EE\u901F\u5EA6\u4E0D\u4F73\uFF0C\u53EF\u4EE5\u524D\u5F80", /*#__PURE__*/React.createElement("a", {
311
+ }, "\uD83C\uDDE8\uD83C\uDDF3"), /*#__PURE__*/React.createElement(FormattedMessage, {
312
+ id: "header.china.mirror.title"
313
+ }), /*#__PURE__*/React.createElement("a", {
296
314
  href: chinaMirrorUrl,
297
315
  onClick: function onClick(e) {
298
316
  e.preventDefault();
@@ -370,7 +388,9 @@ var HeaderComponent = function HeaderComponent(_ref) {
370
388
  src: "https://gw.alipayobjects.com/zos/antfincdn/ZKlx96dsfs/qrcode_for_gh_f52d8b6aa591_258.jpg",
371
389
  alt: "wx-qrcode"
372
390
  }),
373
- title: "\u5FAE\u4FE1\u626B\u4E00\u626B\u5173\u6CE8",
391
+ title: /*#__PURE__*/React.createElement(FormattedMessage, {
392
+ id: "header.wx.qrcode.title"
393
+ }),
374
394
  styles: {
375
395
  body: {
376
396
  padding: 2
@@ -387,7 +407,32 @@ var HeaderComponent = function HeaderComponent(_ref) {
387
407
  href: githubUrl,
388
408
  target: "_blank",
389
409
  rel: "noreferrer"
390
- }, /*#__PURE__*/React.createElement(GithubOutlined, null))));
410
+ }, /*#__PURE__*/React.createElement(GithubOutlined, null))), authSnap.isAuthenticated && /*#__PURE__*/React.createElement("li", {
411
+ className: cx(styles.navIcon, styles.githubCorner)
412
+ }, /*#__PURE__*/React.createElement(Dropdown, {
413
+ menu: {
414
+ items: [{
415
+ key: 'logout',
416
+ label: /*#__PURE__*/React.createElement("a", {
417
+ onClick: function onClick() {
418
+ return logout();
419
+ }
420
+ }, "\u9000\u51FA\u767B\u5F55"),
421
+ icon: /*#__PURE__*/React.createElement(LogoutOutlined, null)
422
+ }, {
423
+ key: 'deleteAccount',
424
+ label: /*#__PURE__*/React.createElement("a", {
425
+ onClick: function onClick() {
426
+ logout();
427
+ clearAllChatData();
428
+ }
429
+ }, "\u6CE8\u9500\u8D26\u53F7"),
430
+ icon: /*#__PURE__*/React.createElement(UserDeleteOutlined, null)
431
+ }]
432
+ }
433
+ }, /*#__PURE__*/React.createElement("a", null, /*#__PURE__*/React.createElement(UserIcon, {
434
+ className: styles.userIcon
435
+ })))));
391
436
  return /*#__PURE__*/React.createElement("header", {
392
437
  className: cx(styles.header, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, styles.transparent, !!transparent && !productMenuVisible), styles.isHomePage, !!isHomePage && !isAntVHome), styles.lightTheme, !!isAntVHome && !productMenuVisible && isWide), styles.isAntVHome, !!isAntVHome), styles.fixed, popupMenuVisible))
393
438
  }, bannerVisible && announcementTitle && /*#__PURE__*/React.createElement(Alert, {