@antv/dumi-theme-antv 0.8.0-beta.9 → 0.8.2

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 (50) hide show
  1. package/README.md +52 -13
  2. package/dist/components/AI/HomeDialog/AntVBanner/index.module.less +20 -0
  3. package/dist/components/AI/HomeDialog/ModeSelector/ModeSelectorDropdown.js +42 -0
  4. package/dist/components/AI/HomeDialog/PromptTextarea/ChooseLib/index.js +12 -4
  5. package/dist/components/AI/HomeDialog/PromptTextarea/SendButton.js +1 -1
  6. package/dist/components/AI/HomeDialog/PromptTextarea/index.js +31 -14
  7. package/dist/components/AI/HomeDialog/PromptTextarea/index.module.less +17 -0
  8. package/dist/components/AI/HomeDialog/RecommendCase/Card.js +11 -6
  9. package/dist/components/AI/HomeDialog/RecommendCase/card.module.less +2 -2
  10. package/dist/components/AI/HomeDialog/RecommendCase/index.js +67 -45
  11. package/dist/components/AI/HomeDialog/RecommendCase/index.module.less +16 -0
  12. package/dist/components/AI/HomeDialog/RecommendCase/recommend.json +41 -17
  13. package/dist/components/AI/HomeDialog/index.js +22 -40
  14. package/dist/components/AI/HomeDialog/index.module.less +5 -0
  15. package/dist/components/AI/constant.js +4 -2
  16. package/dist/components/Login/LoginForm.js +1 -1
  17. package/dist/components/Login/LoginForm.less +3 -4
  18. package/dist/hooks/useProducts.js +23 -3
  19. package/dist/layouts/GlobalLayout/index.js +1 -0
  20. package/dist/locales/en.json +12 -1
  21. package/dist/locales/zh.json +12 -1
  22. package/dist/model/AIChat.js +36 -5
  23. package/dist/model/auth.js +18 -4
  24. package/dist/pages/AIPlayground/components/ConversationsMenu/index.js +13 -4
  25. package/dist/pages/AIPlayground/components/MarkdownComponent/MarkdownCodeBlock.js +15 -10
  26. package/dist/pages/AIPlayground/components/MarkdownComponent/index.js +2 -2
  27. package/dist/pages/AIPlayground/components/MsgBox/index.js +103 -31
  28. package/dist/pages/AIPlayground/components/SessionLayout/index.js +41 -12
  29. package/dist/pages/AIPlayground/components/SessionLayout/index.module.less +4 -3
  30. package/dist/pages/AIPlayground/components/TaskBox/generateCode.js +128 -13
  31. package/dist/pages/AIPlayground/components/TaskBox/index.js +23 -6
  32. package/dist/pages/AIPlayground/index.js +4 -1
  33. package/dist/pages/AIPlayground/index.module.less +5 -0
  34. package/dist/slots/Banner/Notification.module.less +5 -5
  35. package/dist/slots/Banner/index.module.less +3 -1
  36. package/dist/slots/CodeEditor/Toolbar.js +2 -22
  37. package/dist/slots/CodeEditor/index.js +23 -7
  38. package/dist/slots/CodeEditor/index.module.less +0 -1
  39. package/dist/slots/CodeEditor/utils.js +2 -1
  40. package/dist/slots/CodeRunner/index.js +20 -11
  41. package/dist/slots/Detail/index.js +5 -14
  42. package/dist/slots/Detail/index.module.less +95 -134
  43. package/dist/slots/Header/Search/SearchResult.js +4 -2
  44. package/dist/slots/Header/index.js +22 -25
  45. package/dist/slots/LiveExample/index.js +1 -1
  46. package/dist/typings.d.ts +6 -0
  47. package/dist/utils/analytics.js +16 -0
  48. package/dist/utils/env.js +43 -17
  49. package/dist/utils/index.js +7 -0
  50. package/package.json +12 -20
package/README.md CHANGED
@@ -2,18 +2,24 @@
2
2
 
3
3
  [![NPM version](https://img.shields.io/npm/v/@antv/dumi-theme-antv.svg?style=flat)](https://npmjs.org/package/@antv/dumi-theme-antv) [![NPM downloads](http://img.shields.io/npm/dm/@antv/dumi-theme-antv.svg?style=flat)](https://npmjs.org/package/@antv/dumi-theme-antv)
4
4
 
5
- A theme package for the [dumi](https://next.d.umijs.org) framework.
5
+ A theme package for the [dumi](https://next.d.umijs.org) framework, serving AntV official websites including G2, G6, X6, F2, S2, L7, and more.
6
6
 
7
- ## Usage
7
+ [dumi](https://next.d.umijs.org) 框架的主题包,服务于 AntV 官网,包括 G2、G6、X6、F2、S2、L7 等等。
8
+
9
+ ## Usage / 用法
8
10
 
9
11
  Install this theme into `devDependencies`:
10
12
 
13
+ 安装此主题到 `devDependencies`:
14
+
11
15
  ```bash
12
16
  $ npm i @antv/dumi-theme-antv -D
13
17
  ```
14
18
 
15
19
  Configure it in dumi config file `.dumirc.ts`:
16
20
 
21
+ 在 dumi 配置文件 `.dumirc.ts` 中配置:
22
+
17
23
  ```ts
18
24
  import { defineConfig } from 'dumi';
19
25
 
@@ -26,35 +32,68 @@ export defineConfig({
26
32
 
27
33
  That's all, now you can execute `dumi dev` and enjoy this theme.
28
34
 
29
- ## Options
35
+ 这就行了,现在你可以执行 `dumi dev` 并享受这个主题了。
36
+
37
+ ## Options / 选项
30
38
 
31
39
  TODO
32
40
 
41
+ `themeConfig.docsearchOptions.sort` creates a sorting rule for search results. This can be defined using an array of strings.
42
+
33
43
  `themeConfig.docsearchOptions.sort` 用于配置搜索结果的排序规则。可以通过字符串数组来定义排序逻辑。
34
44
 
45
+ - Each string can be a path segment used to match the link of search results.
46
+ - If a string starts with `!`, it means results NOT containing that path segment should be ranked before those that do.
47
+
35
48
  - 每个字符串可以是一个路径片段,用于匹配搜索结果的链接。
36
49
  - 如果字符串以 `!` 开头,则表示不包含该路径片段的结果应排在包含该路径片段的结果之前。
37
50
 
38
- ## Development
51
+ ## Development / 开发
39
52
 
40
53
  ```bash
41
54
  $ npm install
42
55
  ```
43
56
 
44
- After the dependencies are installed, a symlink from `example/.dumi/theme` to `../../src` will be created automatically, the symlink makes dumi load our theme package as a local theme, so we can start the example directly, HMR is also available:
57
+ If you want to test locally, it is recommended to `npm link` directly to the corresponding AntV official website project for testing, so that HMR (Hot Module Replacement) works. Testing directly using this project (e.g. in `example`) does not support HMR.
45
58
 
46
- ```bash
47
- # switch to example directory
48
- $ cd example
59
+ 如果想本地测试,建议直接通过 `npm link` 到对应的 AntV 官网项目中测试,这样才有热更新 (HMR)。直接使用本项目测试(如 `example` 目录)是没有热更新的。
60
+
61
+ dumi theme development documentation: https://next.d.umijs.org/theme
62
+
63
+ dumi 主题开发文档:https://next.d.umijs.org/theme
64
+
65
+ ## Release / 发布
66
+
67
+ This project uses GitHub Actions for automated releasing and [Trusted Publishing](https://docs.npmjs.com/trusted-publishers).
49
68
 
50
- # downloads the dependencies
51
- npm install
69
+ 本项目使用 GitHub Actions 进行自动化发布,并采用了 [可信发布 (Trusted Publishing)](https://docs.npmjs.com/trusted-publishers)。
52
70
 
53
- # start dev server to preview
54
- npm run dev
71
+ To publish a new version, simply push a git tag:
72
+
73
+ 发布新版本只需推送一个 git tag:
74
+
75
+ ```bash
76
+ # for stable release / 正式发布
77
+ git tag v0.8.0
78
+ git push origin v0.8.0
79
+
80
+ # for pre-release (auto-tagged as beta/alpha/etc on npm based on the suffix)
81
+ # 预发布(根据后缀自动在 npm 标记为 beta/alpha 等)
82
+ git tag v0.8.0-beta.1
83
+ git push origin v0.8.0-beta.1
55
84
  ```
56
85
 
57
- dumi theme development documentation: https://next.d.umijs.org/theme
86
+ The CI will automatically:
87
+ 1. Parse the version from the tag.
88
+ 2. Build the project.
89
+ 3. Publish to npm (with provenance).
90
+ 4. Create a GitHub Release.
91
+
92
+ CI 将会自动:
93
+ 1. 从 tag 中解析版本号。
94
+ 2. 构建项目。
95
+ 3. 发布到 npm(带有 provenance)。
96
+ 4. 创建 GitHub Release。
58
97
 
59
98
  ## LICENSE
60
99
 
@@ -32,4 +32,24 @@
32
32
  margin: 0;
33
33
  font-size: 16px;
34
34
  }
35
+
36
+ @media only screen and (max-width: 767.99px) {
37
+ .sage {
38
+ width: 80px;
39
+ }
40
+
41
+ h1 {
42
+ font-size: 22px;
43
+ line-height: 28px;
44
+ }
45
+
46
+ .desc {
47
+ font-size: 14px;
48
+ line-height: 22px;
49
+ }
50
+
51
+ .slogan {
52
+ font-size: 13px;
53
+ }
54
+ }
35
55
  }
@@ -0,0 +1,42 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ 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; }
5
+ 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; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import { Dropdown, Space } from 'antd';
8
+ import { useIntl } from 'dumi';
9
+ import React from 'react';
10
+ import { useSnapshot } from 'valtio';
11
+ import { AIChatStore } from "../../../../model/AIChat";
12
+ import { AIModeMeta } from "../../constant";
13
+ export function ModeSelectorDropdown() {
14
+ var _useIntl = useIntl(),
15
+ formatMessage = _useIntl.formatMessage;
16
+ var snap = useSnapshot(AIChatStore);
17
+ var items = Object.entries(AIModeMeta).map(function (_ref) {
18
+ var _ref2 = _slicedToArray(_ref, 2),
19
+ key = _ref2[0],
20
+ value = _ref2[1];
21
+ return {
22
+ key: key,
23
+ label: formatMessage({
24
+ id: value.shortName
25
+ }),
26
+ icon: value.icon,
27
+ // @ts-ignore
28
+ onClick: function onClick() {
29
+ return AIChatStore.mode = key;
30
+ }
31
+ };
32
+ });
33
+ return /*#__PURE__*/React.createElement(Dropdown, {
34
+ menu: {
35
+ items: items
36
+ }
37
+ }, /*#__PURE__*/React.createElement("button", {
38
+ type: "button"
39
+ }, /*#__PURE__*/React.createElement("a", null, /*#__PURE__*/React.createElement(Space, null, AIModeMeta[snap.mode].icon, formatMessage({
40
+ id: AIModeMeta[snap.mode].shortName
41
+ })))));
42
+ }
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { Dropdown } from "antd";
3
- import { useProducts } from "../../../../../hooks/useProducts";
4
- import { useLocale, useIntl, FormattedMessage } from "dumi";
3
+ import { useAntVConfig, useProducts } from "../../../../../hooks/useProducts";
4
+ import { useLocale, FormattedMessage } from "dumi";
5
5
  import styles from "./index.module.less";
6
6
  export function ChooseLib(props) {
7
7
  var _data$find;
@@ -15,11 +15,20 @@ export function ChooseLib(props) {
15
15
  var _useProducts = useProducts(),
16
16
  _useProducts$data = _useProducts.data,
17
17
  data = _useProducts$data === void 0 ? [] : _useProducts$data;
18
+ var _useAntVConfig = useAntVConfig(),
19
+ _useAntVConfig$data = _useAntVConfig.data,
20
+ _useAntVConfig$data2 = _useAntVConfig$data === void 0 ? {
21
+ library: []
22
+ } : _useAntVConfig$data,
23
+ _useAntVConfig$data2$ = _useAntVConfig$data2.library,
24
+ library = _useAntVConfig$data2$ === void 0 ? [] : _useAntVConfig$data2$;
18
25
  var onSelect = function onSelect(key) {
19
26
  onChange === null || onChange === void 0 || onChange(key);
20
27
  };
21
28
  var items = data.filter(function (item) {
22
- return item.lang === lang && ["G2", "F2", "S2", "G6", "X6", "AVA"].includes(item.title);
29
+ return item.lang === lang && library.map(function (l) {
30
+ return l.toUpperCase();
31
+ }).includes(item.title);
23
32
  }).map(function (item) {
24
33
  return {
25
34
  key: item.title,
@@ -35,7 +44,6 @@ export function ChooseLib(props) {
35
44
  }
36
45
  };
37
46
  });
38
- var intl = useIntl();
39
47
  return /*#__PURE__*/React.createElement(Dropdown, {
40
48
  menu: {
41
49
  items: items
@@ -11,7 +11,7 @@ function SendButton(props) {
11
11
  disabled = props.disabled,
12
12
  tip = props.tip;
13
13
  return /*#__PURE__*/React.createElement(Tooltip, {
14
- title: disabled ? tip : null
14
+ title: tip
15
15
  }, /*#__PURE__*/React.createElement("img", {
16
16
  className: classnames(styles.actionBtn, _defineProperty({}, styles.disabled, disabled)),
17
17
  onClick: function onClick() {
@@ -12,7 +12,7 @@ import { DatasourceCard } from "./DatasourceCard";
12
12
  import { useEventListener } from 'ahooks';
13
13
  import classnames from 'classnames';
14
14
  import _ from 'lodash';
15
- import React, { useRef, useState } from 'react';
15
+ import React, { useEffect, useRef, useState } from 'react';
16
16
  import styles from "./index.module.less";
17
17
  import { SendButton } from "./SendButton";
18
18
  import { ChooseLib } from "./ChooseLib";
@@ -21,6 +21,8 @@ import { ic } from "../../../../slots/hooks";
21
21
  import { useTypewriter } from "../../../../hooks/useTypewriter";
22
22
  import { authStore, showLoginModal } from "../../../../model/auth";
23
23
  import { useSnapshot } from "valtio";
24
+ import { AIChatStore } from "../../../../model/AIChat";
25
+ import { ModeSelectorDropdown } from "../ModeSelector/ModeSelectorDropdown";
24
26
  var PLACEHOLDER = {
25
27
  implement: 'ai.placeholder.implement',
26
28
  solve: 'ai.placeholder.solve'
@@ -33,16 +35,25 @@ export var PromptTextarea = /*#__PURE__*/React.memo(function PromptTextareaInner
33
35
  onConfirm = props.onConfirm,
34
36
  onCancel = props.onCancel,
35
37
  loading = props.loading,
36
- mode = props.mode,
37
- lib = props.lib,
38
- onLibChange = props.onLibChange,
39
38
  _props$showAction = props.showAction,
40
- showAction = _props$showAction === void 0 ? true : _props$showAction;
39
+ showAction = _props$showAction === void 0 ? true : _props$showAction,
40
+ _props$showModeSelect = props.showModeSelector,
41
+ showModeSelector = _props$showModeSelect === void 0 ? false : _props$showModeSelect,
42
+ _props$skipLoginCheck = props.skipLoginCheck,
43
+ skipLoginCheck = _props$skipLoginCheck === void 0 ? false : _props$skipLoginCheck,
44
+ sendButtonTip = props.sendButtonTip;
45
+ var snap = useSnapshot(AIChatStore);
41
46
  var authSnap = useSnapshot(authStore);
42
47
  var _useIntl = useIntl(),
43
48
  formatMessage = _useIntl.formatMessage;
44
49
  var textareaRef = useRef(null);
45
-
50
+ var _useSiteData = useSiteData(),
51
+ themeConfig = _useSiteData.themeConfig;
52
+ useEffect(function () {
53
+ if (!themeConfig.isAntVSite && !snap.lib) {
54
+ AIChatStore.lib = themeConfig.title;
55
+ }
56
+ }, [themeConfig.isAntVSite, themeConfig.title]);
46
57
  // 将fileMeta状态移到组件内部管理
47
58
  var _useState = useState(null),
48
59
  _useState2 = _slicedToArray(_useState, 2),
@@ -55,8 +66,6 @@ export var PromptTextarea = /*#__PURE__*/React.memo(function PromptTextareaInner
55
66
  focus = _useState4[0],
56
67
  setFocus = _useState4[1];
57
68
  var isCompact = size === 'compact';
58
- var _useSiteData = useSiteData(),
59
- themeConfig = _useSiteData.themeConfig;
60
69
  var typedPlaceholder = useTypewriter({
61
70
  texts: [formatMessage({
62
71
  id: 'ai.placeholder.whatis'
@@ -99,6 +108,12 @@ export var PromptTextarea = /*#__PURE__*/React.memo(function PromptTextareaInner
99
108
  }
100
109
  };
101
110
  var send = function send() {
111
+ // 如果跳过登录检查,直接发送
112
+ if (skipLoginCheck) {
113
+ pureSend();
114
+ return;
115
+ }
116
+ // 否则检查登录状态
102
117
  if (!authSnap.isAuthenticated) {
103
118
  showLoginModal(pureSend);
104
119
  return;
@@ -134,7 +149,7 @@ export var PromptTextarea = /*#__PURE__*/React.memo(function PromptTextareaInner
134
149
  placeholder:
135
150
  // (!isCompact && !themeConfig.isAntVSite && ic(themeConfig.metas.description)) ||
136
151
  !isCompact && !themeConfig.isAntVSite ? typedPlaceholder : formatMessage({
137
- id: _.get(PLACEHOLDER, mode, 'ai.placeholder.implement')
152
+ id: _.get(PLACEHOLDER, snap.mode, 'ai.placeholder.implement')
138
153
  }),
139
154
  value: value,
140
155
  onChange: function onChange(evt) {
@@ -145,10 +160,12 @@ export var PromptTextarea = /*#__PURE__*/React.memo(function PromptTextareaInner
145
160
  }, /*#__PURE__*/React.createElement("div", {
146
161
  className: styles.dataActions
147
162
  }, showAction && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ChooseLib, {
148
- value: lib,
149
- onChange: onLibChange,
150
- size: size
151
- }))), /*#__PURE__*/React.createElement("div", {
163
+ size: size,
164
+ value: snap.lib,
165
+ onChange: function onChange(s) {
166
+ return AIChatStore.lib = s;
167
+ }
168
+ })), showModeSelector && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ModeSelectorDropdown, null))), /*#__PURE__*/React.createElement("div", {
152
169
  className: styles.actions
153
170
  }, loading ? /*#__PURE__*/React.createElement("img", {
154
171
  className: styles.actionBtn,
@@ -159,6 +176,6 @@ export var PromptTextarea = /*#__PURE__*/React.memo(function PromptTextareaInner
159
176
  disabled: !promptTextValid,
160
177
  tip: !promptTextValid ? formatMessage({
161
178
  id: 'ai.msgbox.send.tip'
162
- }) : undefined
179
+ }) : sendButtonTip
163
180
  }))));
164
181
  });
@@ -99,6 +99,23 @@
99
99
  font-size: 14px;
100
100
  }
101
101
  }
102
+
103
+ @media only screen and (max-width: 767.99px) {
104
+ width: 100%;
105
+ height: auto;
106
+ min-height: 120px;
107
+
108
+ &.withDatasource {
109
+ height: auto;
110
+ min-height: 160px;
111
+ }
112
+
113
+ .header {
114
+ > div {
115
+ max-width: 100%;
116
+ }
117
+ }
118
+ }
102
119
  }
103
120
 
104
121
  .datasourceBtn {
@@ -1,20 +1,25 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
1
2
  import { Popover } from 'antd';
2
3
  import React from 'react';
3
4
  import styles from "./card.module.less";
4
5
  import { BarChartOutlined, QuestionCircleOutlined } from "@ant-design/icons";
5
6
  import { AIMode, AIModeMeta, COLORS } from "../../constant";
6
- import { FormattedMessage } from 'dumi';
7
+ import { FormattedMessage, useLocale } from 'dumi';
7
8
  export var Card = function Card(_ref) {
8
9
  var _AIModeMeta$tag;
9
10
  var item = _ref.item,
10
11
  index = _ref.index,
11
12
  onClick = _ref.onClick;
12
- var query = item.query,
13
- description = item.description,
13
+ var _item$query = item.query,
14
+ query = _item$query === void 0 ? {} : _item$query,
15
+ _item$description = item.description,
16
+ description = _item$description === void 0 ? {} : _item$description,
14
17
  _item$imageUrls = item.imageUrls,
15
18
  imageUrls = _item$imageUrls === void 0 ? [] : _item$imageUrls,
16
19
  tag = item.tag;
17
20
  var style = COLORS[index];
21
+ var locale = useLocale();
22
+ var lang = locale.id === 'zh' ? 'zh' : 'en';
18
23
  var handleClick = function handleClick(e) {
19
24
  e.stopPropagation();
20
25
  onClick === null || onClick === void 0 || onClick();
@@ -29,7 +34,7 @@ export var Card = function Card(_ref) {
29
34
  id: "ai.recommend.card.caseName"
30
35
  })), /*#__PURE__*/React.createElement("div", {
31
36
  className: styles.popoverValue
32
- }, query)), /*#__PURE__*/React.createElement("div", {
37
+ }, _typeof(query) === 'object' ? query[lang] : query)), /*#__PURE__*/React.createElement("div", {
33
38
  className: styles.popoverItem
34
39
  }, /*#__PURE__*/React.createElement("div", {
35
40
  className: styles.popoverLabel
@@ -37,7 +42,7 @@ export var Card = function Card(_ref) {
37
42
  id: "ai.recommend.card.description"
38
43
  })), /*#__PURE__*/React.createElement("div", {
39
44
  className: styles.popoverValue
40
- }, description)));
45
+ }, _typeof(description) === 'object' ? description[lang] : description)));
41
46
  return /*#__PURE__*/React.createElement(Popover, {
42
47
  content: popoverContent,
43
48
  placement: "top",
@@ -61,7 +66,7 @@ export var Card = function Card(_ref) {
61
66
  id: ((_AIModeMeta$tag = AIModeMeta[tag]) === null || _AIModeMeta$tag === void 0 ? void 0 : _AIModeMeta$tag.name) || tag
62
67
  }))), /*#__PURE__*/React.createElement("div", {
63
68
  className: styles.title
64
- }, query), /*#__PURE__*/React.createElement("div", {
69
+ }, _typeof(query) === 'object' ? query[lang] : query), /*#__PURE__*/React.createElement("div", {
65
70
  className: styles.imageContainer
66
71
  }, imageUrls.slice(0, 2).map(function (item, idx) {
67
72
  return /*#__PURE__*/React.createElement("img", {
@@ -100,7 +100,7 @@
100
100
  }
101
101
 
102
102
  .popoverContent {
103
- max-width: 372px;
103
+ max-width: 800px;
104
104
 
105
105
  .popoverItem {
106
106
  display: flex;
@@ -112,7 +112,7 @@
112
112
  color: #1d2129e6;
113
113
  line-height: 22px;
114
114
  font-weight: 500;
115
- min-width: 56px;
115
+ min-width: 80px;
116
116
  }
117
117
 
118
118
  .popoverValue {
@@ -9,14 +9,17 @@ 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
18
  import { FormattedMessage, useSiteData } from 'dumi';
19
- import { sampleSize } from "lodash-es";
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";
20
23
  export var RecommendCase = function RecommendCase(props) {
21
24
  var _useState = useState(false),
22
25
  _useState2 = _slicedToArray(_useState, 2),
@@ -28,49 +31,65 @@ export var RecommendCase = function RecommendCase(props) {
28
31
  _useState4 = _slicedToArray(_useState3, 2),
29
32
  list = _useState4[0],
30
33
  setList = _useState4[1];
31
- var fetchList = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
32
- var data;
33
- return _regeneratorRuntime().wrap(function _callee$(_context) {
34
- while (1) switch (_context.prev = _context.next) {
35
- case 0:
36
- _context.prev = 0;
37
- setLoading(true);
38
- data = [];
39
- if (!(themeConfig !== null && themeConfig !== void 0 && themeConfig.recommend)) {
40
- _context.next = 9;
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;
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;
41
62
  break;
42
- }
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:
66
- case "end":
67
- return _context.stop();
68
- }
69
- }, _callee, null, [[0, 13, 16, 19]]);
70
- })), [list]);
63
+ case 10:
64
+ data = RecommendJson;
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;
76
+ setLoading(false);
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
+ }();
71
88
  useEffect(function () {
72
- fetchList();
73
- }, []);
89
+ if (library.length) {
90
+ fetchList();
91
+ }
92
+ }, [themeConfig.isAntVSite, library.length]);
74
93
  if (!list.length) {
75
94
  return null;
76
95
  }
@@ -82,14 +101,14 @@ export var RecommendCase = function RecommendCase(props) {
82
101
  className: styles.quickStart
83
102
  }, /*#__PURE__*/React.createElement(FormattedMessage, {
84
103
  id: "ai.recommend.title"
85
- })), /*#__PURE__*/React.createElement("span", {
104
+ })), (list === null || list === void 0 ? void 0 : list.length) > 4 ? /*#__PURE__*/React.createElement("span", {
86
105
  className: styles.refresh,
87
106
  onClick: function onClick() {
88
107
  return fetchList();
89
108
  }
90
109
  }, /*#__PURE__*/React.createElement(ReloadOutlined, null), /*#__PURE__*/React.createElement(FormattedMessage, {
91
110
  id: "ai.recommend.refresh"
92
- }))), /*#__PURE__*/React.createElement(Spin, {
111
+ })) : /*#__PURE__*/React.createElement(React.Fragment, null)), /*#__PURE__*/React.createElement(Spin, {
93
112
  spinning: loading,
94
113
  wrapperClassName: classnames(styles.listContainer, props.className)
95
114
  }, /*#__PURE__*/React.createElement("div", {
@@ -102,6 +121,9 @@ export var RecommendCase = function RecommendCase(props) {
102
121
  onClick: function onClick() {
103
122
  var _props$onClick;
104
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
+ }
105
127
  }
106
128
  });
107
129
  }))));
@@ -1,4 +1,5 @@
1
1
  .container {
2
+ position: relative;
2
3
  margin-top: 32px;
3
4
  margin-left: auto;
4
5
  margin-right: auto;
@@ -42,3 +43,18 @@
42
43
  grid-template-columns: repeat(4, 1fr);
43
44
  gap: 16px;
44
45
  }
46
+
47
+ @media only screen and (max-width: 767.99px) {
48
+ .title {
49
+ width: 100%;
50
+
51
+ .quickStart {
52
+ font-size: 16px;
53
+ }
54
+ }
55
+
56
+ .list {
57
+ grid-template-columns: repeat(2, 1fr);
58
+ gap: 12px;
59
+ }
60
+ }