@antv/dumi-theme-antv 0.8.0-beta.12 → 0.8.0-beta.14

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 (27) hide show
  1. package/dist/components/AI/HomeDialog/ModeSelector/ModeSelectorDropdown.js +42 -0
  2. package/dist/components/AI/HomeDialog/PromptTextarea/ChooseLib/index.js +7 -2
  3. package/dist/components/AI/HomeDialog/PromptTextarea/index.js +6 -4
  4. package/dist/components/AI/HomeDialog/RecommendCase/Card.js +11 -6
  5. package/dist/components/AI/HomeDialog/RecommendCase/card.module.less +2 -2
  6. package/dist/components/AI/HomeDialog/RecommendCase/index.js +59 -43
  7. package/dist/components/AI/HomeDialog/RecommendCase/recommend.json +41 -17
  8. package/dist/components/AI/HomeDialog/index.js +8 -15
  9. package/dist/components/AI/constant.js +4 -2
  10. package/dist/hooks/useProducts.js +19 -1
  11. package/dist/locales/en.json +6 -1
  12. package/dist/locales/zh.json +6 -1
  13. package/dist/model/AIChat.js +18 -4
  14. package/dist/model/auth.js +11 -4
  15. package/dist/pages/AIPlayground/components/ConversationsMenu/index.js +9 -3
  16. package/dist/pages/AIPlayground/components/MsgBox/index.js +41 -10
  17. package/dist/pages/AIPlayground/components/SessionLayout/index.js +2 -1
  18. package/dist/pages/AIPlayground/components/SessionLayout/index.module.less +2 -1
  19. package/dist/pages/AIPlayground/components/TaskBox/generateCode.js +7 -1
  20. package/dist/pages/AIPlayground/components/TaskBox/index.js +3 -2
  21. package/dist/pages/AIPlayground/index.js +4 -1
  22. package/dist/pages/AIPlayground/index.module.less +5 -0
  23. package/dist/slots/Detail/index.js +2 -1
  24. package/dist/slots/Header/Search/SearchResult.js +2 -1
  25. package/dist/slots/Header/index.js +3 -21
  26. package/dist/utils/env.js +43 -17
  27. package/package.json +1 -1
@@ -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,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Dropdown } from "antd";
3
- import { useProducts } from "../../../../../hooks/useProducts";
3
+ import { useLibrary, useProducts } from "../../../../../hooks/useProducts";
4
4
  import { useLocale, FormattedMessage } from "dumi";
5
5
  import styles from "./index.module.less";
6
6
  export function ChooseLib(props) {
@@ -15,11 +15,16 @@ 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 _useLibrary = useLibrary(),
19
+ _useLibrary$data = _useLibrary.data,
20
+ library = _useLibrary$data === void 0 ? [] : _useLibrary$data;
18
21
  var onSelect = function onSelect(key) {
19
22
  onChange === null || onChange === void 0 || onChange(key);
20
23
  };
21
24
  var items = data.filter(function (item) {
22
- return item.lang === lang && ["G2", "F2", "S2", "G6", "X6", "AVA"].includes(item.title);
25
+ return item.lang === lang && library.map(function (l) {
26
+ return l.toUpperCase();
27
+ }).includes(item.title);
23
28
  }).map(function (item) {
24
29
  return {
25
30
  key: item.title,
@@ -22,6 +22,7 @@ import { useTypewriter } from "../../../../hooks/useTypewriter";
22
22
  import { authStore, showLoginModal } from "../../../../model/auth";
23
23
  import { useSnapshot } from "valtio";
24
24
  import { AIChatStore } from "../../../../model/AIChat";
25
+ import { ModeSelectorDropdown } from "../ModeSelector/ModeSelectorDropdown";
25
26
  var PLACEHOLDER = {
26
27
  implement: 'ai.placeholder.implement',
27
28
  solve: 'ai.placeholder.solve'
@@ -34,9 +35,10 @@ export var PromptTextarea = /*#__PURE__*/React.memo(function PromptTextareaInner
34
35
  onConfirm = props.onConfirm,
35
36
  onCancel = props.onCancel,
36
37
  loading = props.loading,
37
- mode = props.mode,
38
38
  _props$showAction = props.showAction,
39
- 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;
40
42
  var snap = useSnapshot(AIChatStore);
41
43
  var authSnap = useSnapshot(authStore);
42
44
  var _useIntl = useIntl(),
@@ -138,7 +140,7 @@ export var PromptTextarea = /*#__PURE__*/React.memo(function PromptTextareaInner
138
140
  placeholder:
139
141
  // (!isCompact && !themeConfig.isAntVSite && ic(themeConfig.metas.description)) ||
140
142
  !isCompact && !themeConfig.isAntVSite ? typedPlaceholder : formatMessage({
141
- id: _.get(PLACEHOLDER, mode, 'ai.placeholder.implement')
143
+ id: _.get(PLACEHOLDER, snap.mode, 'ai.placeholder.implement')
142
144
  }),
143
145
  value: value,
144
146
  onChange: function onChange(evt) {
@@ -154,7 +156,7 @@ export var PromptTextarea = /*#__PURE__*/React.memo(function PromptTextareaInner
154
156
  onChange: function onChange(s) {
155
157
  return AIChatStore.lib = s;
156
158
  }
157
- }))), /*#__PURE__*/React.createElement("div", {
159
+ })), showModeSelector && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ModeSelectorDropdown, null))), /*#__PURE__*/React.createElement("div", {
158
160
  className: styles.actions
159
161
  }, loading ? /*#__PURE__*/React.createElement("img", {
160
162
  className: styles.actionBtn,
@@ -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 { useLibrary } 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,46 +31,56 @@ 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 _themeConfig$ai, 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$ai = themeConfig.ai) !== null && _themeConfig$ai !== void 0 && _themeConfig$ai.recommend)) {
40
- _context.next = 9;
34
+ var _useLibrary = useLibrary(),
35
+ _useLibrary$data = _useLibrary.data,
36
+ library = _useLibrary$data === void 0 ? [] : _useLibrary$data;
37
+ var fetchList = /*#__PURE__*/function () {
38
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
39
+ var _themeConfig$ai, data, url;
40
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
41
+ while (1) switch (_context.prev = _context.next) {
42
+ case 0:
43
+ _context.prev = 0;
44
+ setLoading(true);
45
+ data = [];
46
+ 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");
47
+ if (!url) {
48
+ _context.next = 10;
49
+ break;
50
+ }
51
+ _context.next = 7;
52
+ return fetch(url).then(function (res) {
53
+ return res.json();
54
+ });
55
+ case 7:
56
+ data = _context.sent;
57
+ _context.next = 11;
41
58
  break;
42
- }
43
- _context.next = 6;
44
- return fetch(themeConfig.ai.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]);
59
+ case 10:
60
+ data = RecommendJson;
61
+ case 11:
62
+ setList(sampleSize(data, 4));
63
+ _context.next = 18;
64
+ break;
65
+ case 14:
66
+ _context.prev = 14;
67
+ _context.t0 = _context["catch"](0);
68
+ setList(RecommendJson);
69
+ console.log(_context.t0);
70
+ case 18:
71
+ _context.prev = 18;
72
+ setLoading(false);
73
+ return _context.finish(18);
74
+ case 21:
75
+ case "end":
76
+ return _context.stop();
77
+ }
78
+ }, _callee, null, [[0, 14, 18, 21]]);
79
+ }));
80
+ return function fetchList() {
81
+ return _ref.apply(this, arguments);
82
+ };
83
+ }();
71
84
  useEffect(function () {
72
85
  fetchList();
73
86
  }, []);
@@ -82,14 +95,14 @@ export var RecommendCase = function RecommendCase(props) {
82
95
  className: styles.quickStart
83
96
  }, /*#__PURE__*/React.createElement(FormattedMessage, {
84
97
  id: "ai.recommend.title"
85
- })), /*#__PURE__*/React.createElement("span", {
98
+ })), (list === null || list === void 0 ? void 0 : list.length) > 4 ? /*#__PURE__*/React.createElement("span", {
86
99
  className: styles.refresh,
87
100
  onClick: function onClick() {
88
101
  return fetchList();
89
102
  }
90
103
  }, /*#__PURE__*/React.createElement(ReloadOutlined, null), /*#__PURE__*/React.createElement(FormattedMessage, {
91
104
  id: "ai.recommend.refresh"
92
- }))), /*#__PURE__*/React.createElement(Spin, {
105
+ })) : /*#__PURE__*/React.createElement(React.Fragment, null)), /*#__PURE__*/React.createElement(Spin, {
93
106
  spinning: loading,
94
107
  wrapperClassName: classnames(styles.listContainer, props.className)
95
108
  }, /*#__PURE__*/React.createElement("div", {
@@ -102,6 +115,9 @@ export var RecommendCase = function RecommendCase(props) {
102
115
  onClick: function onClick() {
103
116
  var _props$onClick;
104
117
  (_props$onClick = props.onClick) === null || _props$onClick === void 0 || _props$onClick.call(props, item);
118
+ if (item.tag) {
119
+ AIChatStore.mode = item.tag;
120
+ }
105
121
  }
106
122
  });
107
123
  }))));
@@ -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,19 +10,14 @@ 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
14
  import { useLocale } from 'dumi';
17
- import { createNewSession } from "../../../model/AIChat";
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 _useLocalStorageState = useLocalStorageState('use-local-storage-ai-mode-type', {
21
- defaultValue: AIMode.implement
22
- }),
23
- _useLocalStorageState2 = _slicedToArray(_useLocalStorageState, 2),
24
- mode = _useLocalStorageState2[0],
25
- setMode = _useLocalStorageState2[1];
19
+ var lang = locale.id === 'zh' ? 'zh' : 'en';
20
+ var snap = useSnapshot(AIChatStore);
26
21
  var _useState = useState(''),
27
22
  _useState2 = _slicedToArray(_useState, 2),
28
23
  promptText = _useState2[0],
@@ -36,12 +31,10 @@ export function HomeDialog(props) {
36
31
  style: props.style
37
32
  }, /*#__PURE__*/React.createElement(AntVBanner, null), /*#__PURE__*/React.createElement(ModeSelector, {
38
33
  onChange: function onChange(v) {
39
- setMode(v);
40
- // todo 埋点
34
+ AIChatStore.mode = v;
41
35
  },
42
- value: mode
36
+ value: snap.mode
43
37
  }), /*#__PURE__*/React.createElement(PromptTextarea, {
44
- mode: mode,
45
38
  value: promptText,
46
39
  onChange: function onChange(val) {
47
40
  setPromptText(val);
@@ -49,7 +42,7 @@ export function HomeDialog(props) {
49
42
  onConfirm: function onConfirm() {
50
43
  createNewSession({
51
44
  promptText: promptText,
52
- mode: mode,
45
+ mode: snap.mode,
53
46
  jump: true,
54
47
  context: fileSummary,
55
48
  lang: locale.id
@@ -61,7 +54,7 @@ export function HomeDialog(props) {
61
54
  className: props.recommendCaseClassName,
62
55
  onClick: function onClick(val) {
63
56
  if (val !== null && val !== void 0 && val.query) {
64
- setPromptText(val.query);
57
+ setPromptText(val.query[lang]);
65
58
  }
66
59
  }
67
60
  }));
@@ -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
 
@@ -1,7 +1,8 @@
1
1
  import { useQuery } from '@tanstack/react-query';
2
+ import { getBaseSiteDataUrl } from "../utils/env";
2
3
  export function getProducts() {
3
4
  // 如需要修改产品信息,请到 https://yuyan.antfin-inc.com/antv/site-data/sprints 修改区块内容
4
- return fetch('https://assets.antv.antgroup.com/antv/products.json' // 生产环境
5
+ return fetch("".concat(getBaseSiteDataUrl(), "/antv/products.json") // 生产环境
5
6
  // 'https://site-data-pre.alipay.com/antv/products.json', // 预发测试
6
7
  ).then(function (res) {
7
8
  return res.json();
@@ -15,4 +16,21 @@ export function useProducts() {
15
16
  queryFn: getProducts,
16
17
  staleTime: 24 * 60 * 60 * 1000 // 一天内数据不会被认为是 "stale",不会触发后台刷新
17
18
  });
19
+ }
20
+ export function getLibrary() {
21
+ // 如需要修改产品信息,请到 https://yuyan.antfin-inc.com/antv/site-data/sprints 修改区块内容
22
+ return fetch("".concat(getBaseSiteDataUrl(), "/antv/library.json") // 生产环境
23
+ // 'https://site-data-pre.alipay.com/antv/products.json', // 预发测试
24
+ ).then(function (res) {
25
+ return res.json();
26
+ });
27
+ }
28
+
29
+ // 封装了 queryKey 和 fetcher 的自定义 Hook
30
+ export function useLibrary() {
31
+ return useQuery({
32
+ queryKey: ['antv-library'],
33
+ queryFn: getLibrary,
34
+ staleTime: 24 * 60 * 60 * 1000 // 一天内数据不会被认为是 "stale",不会触发后台刷新
35
+ });
18
36
  }
@@ -182,7 +182,9 @@
182
182
  "ai.placeholder.implement": "What would you like to visualize today?",
183
183
  "ai.placeholder.solve": "What visualization problem would you like to solve today?",
184
184
  "ai.mode.implement": "Develop",
185
+ "ai.mode.implement.short": "Develop",
185
186
  "ai.mode.solve": "Q&A",
187
+ "ai.mode.solve.short": "Q&A",
186
188
  "ai.upload.tooltip": "Only supports csv,json,tsv,txt files. For performance and cost reasons, only the first few lines will be used as samples",
187
189
  "ai.upload.data": "Upload Data",
188
190
  "ai.upload.image": "Upload Image",
@@ -205,6 +207,7 @@
205
207
  "ai.msgbox.start.new.chat": "Start New Chat",
206
208
  "ai.msgbox.send.tip": "Please enter content before sending",
207
209
  "ai.msgbox.error.response": "Sorry, I couldn't successfully process your request, please try again later",
210
+ "ai.msgbox.continue.from.here": "Continue from here",
208
211
  "ai.recommend.title": "Featured Cases",
209
212
  "ai.recommend.refresh": "Refresh",
210
213
  "ai.recommend.card.caseName": "Case Name",
@@ -227,12 +230,14 @@
227
230
  "ai.conversations.pin": "Pin",
228
231
  "ai.conversations.delete": "Delete",
229
232
  "ai.conversations.edit.title": "Edit Conversation Name",
233
+ "ai.conversations.ok": "OK",
234
+ "ai.conversations.cancel": "Cancel",
235
+ "ai.msgbox.delete": "Delete",
230
236
  "ai.chooseLib.placeholder": "Choose Technology Stack",
231
237
  "ai.search.try": "Try",
232
238
  "ai.search.visualization": "Q&A",
233
239
  "ai.assistant.editor.intro": "I am AntV AI Assistant. You can ask me questions at any time to:\n1. Interpret the code configuration of the current chart.\n2. Generate new code based on the current case through natural language dialogue to customize the chart.",
234
240
  "ai.placeholder.whatis": "What is {title}?",
235
- "header.ai.code": "AI Code Generation",
236
241
  "header.user.history": "History",
237
242
  "header.user.logout": "Logout",
238
243
  "header.user.deleteAccount": "Delete Account",
@@ -181,7 +181,9 @@
181
181
  "ai.placeholder.implement": "今天,你想可视化什么?",
182
182
  "ai.placeholder.solve": "今天,你想解决什么可视化问题?",
183
183
  "ai.mode.implement": "可视化研发",
184
+ "ai.mode.implement.short": "研发",
184
185
  "ai.mode.solve": "可视化答疑",
186
+ "ai.mode.solve.short": "答疑",
185
187
  "ai.upload.tooltip": "仅支持csv,json,tsv,txt文件,为了性能和成本,只会使用文件的前几行作为样本",
186
188
  "ai.upload.data": "上传数据",
187
189
  "ai.upload.image": "上传图片",
@@ -220,18 +222,21 @@
220
222
  "ai.toolbar.clear.conversation": "清空对话",
221
223
  "ai.conversations.expand": "展开",
222
224
  "ai.conversations.collapse": "收起",
225
+ "ai.msgbox.continue.from.here": "从这里继续",
223
226
  "ai.conversations.new": "开始新对话",
224
227
  "ai.conversations.history": "历史对话",
225
228
  "ai.conversations.rename": "重命名",
226
229
  "ai.conversations.pin": "置顶",
227
230
  "ai.conversations.delete": "删除",
228
231
  "ai.conversations.edit.title": "编辑对话名称",
232
+ "ai.conversations.ok": "确定",
233
+ "ai.conversations.cancel": "取消",
234
+ "ai.msgbox.delete": "删除",
229
235
  "ai.chooseLib.placeholder": "选择技术栈",
230
236
  "ai.search.try": "试试",
231
237
  "ai.search.visualization": "可视化答疑",
232
238
  "ai.assistant.editor.intro": "我是AntV AI助手。您可以随时向我提问,让我为您:\n\n1、解读当前图表的代码配置。\n2、通过自然语言对话,基于当前案例生成新代码以定制图表。",
233
239
  "ai.placeholder.whatis": "{title}是什么?",
234
- "header.ai.code": "AI生码",
235
240
  "header.user.history": "历史会话",
236
241
  "header.user.logout": "退出登录",
237
242
  "header.user.deleteAccount": "注销账号",
@@ -14,6 +14,7 @@ import localforage from 'localforage';
14
14
  import FingerprintJS from '@fingerprintjs/fingerprintjs';
15
15
  import { history } from "dumi";
16
16
  import { message } from "antd";
17
+ import { AIMode } from "../components/AI/constant";
17
18
 
18
19
  // --- 配置 ---
19
20
  // 定义需要持久化的 state key
@@ -28,7 +29,8 @@ var initialState = {
28
29
  activeSessionId: null,
29
30
  tempMessage: null,
30
31
  codeBlock: null,
31
- lib: null
32
+ lib: null,
33
+ mode: AIMode.implement
32
34
  };
33
35
 
34
36
  // --- valtio Store 创建 ---
@@ -203,9 +205,11 @@ subscribeKey(AIChatStore, 'activeSessionId', function () {
203
205
  });
204
206
  export var createPureNewSession = function createPureNewSession(title) {
205
207
  var newConversationName = 'New Conversation';
206
- if (AIChatStore.sessions.some(function (s) {
208
+ var existNewSession = AIChatStore.sessions.find(function (s) {
207
209
  return s.title === newConversationName && s.messages.length === 0;
208
- })) {
210
+ });
211
+ if (existNewSession) {
212
+ AIChatStore.activeSessionId = existNewSession.id;
209
213
  return;
210
214
  }
211
215
  var newSessionId = crypto.randomUUID();
@@ -285,4 +289,14 @@ export var clearAllChatData = /*#__PURE__*/function () {
285
289
  return function clearAllChatData() {
286
290
  return _ref2.apply(this, arguments);
287
291
  };
288
- }();
292
+ }();
293
+ export function deleteMessage(msgId) {
294
+ derivedState.activeSession.messages = derivedState.activeSession.messages.filter(function (m) {
295
+ return m.id !== msgId;
296
+ });
297
+ }
298
+ export function branchMessage(index) {
299
+ var messages = derivedState.activeSession.messages.slice(0, index + 1);
300
+ createPureNewSession(messages[0].content);
301
+ AIChatStore.sessions[0].messages = messages;
302
+ }
@@ -4,6 +4,8 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
4
4
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
5
  import { proxy } from 'valtio';
6
6
  import request from "../utils/request";
7
+ import { history } from 'dumi';
8
+ import { message } from "antd";
7
9
 
8
10
  /**
9
11
  * 检查当前 URL 是否包含 'skipLogin=1' 参数
@@ -41,7 +43,7 @@ export var hideLoginModal = function hideLoginModal() {
41
43
  };
42
44
  export var loginOrRegister = /*#__PURE__*/function () {
43
45
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
44
- var _authStore$loginCallb;
46
+ var _authStore$loginCallb, _error$response, errorMessage;
45
47
  return _regeneratorRuntime().wrap(function _callee$(_context) {
46
48
  while (1) switch (_context.prev = _context.next) {
47
49
  case 0:
@@ -57,8 +59,12 @@ export var loginOrRegister = /*#__PURE__*/function () {
57
59
  _context.prev = 9;
58
60
  _context.t0 = _context["catch"](0);
59
61
  console.error('Login failed in store:', _context.t0);
62
+ errorMessage = _context.t0 === null || _context.t0 === void 0 || (_error$response = _context.t0.response) === null || _error$response === void 0 || (_error$response = _error$response.data) === null || _error$response === void 0 ? void 0 : _error$response.message;
63
+ if (errorMessage) {
64
+ message.error(errorMessage);
65
+ }
60
66
  return _context.abrupt("return", false);
61
- case 13:
67
+ case 15:
62
68
  case "end":
63
69
  return _context.stop();
64
70
  }
@@ -86,12 +92,13 @@ export var logout = /*#__PURE__*/function () {
86
92
  case 8:
87
93
  _context2.prev = 8;
88
94
  authStore.isAuthenticated = false;
95
+ history.push('/');
89
96
  return _context2.finish(8);
90
- case 11:
97
+ case 12:
91
98
  case "end":
92
99
  return _context2.stop();
93
100
  }
94
- }, _callee2, null, [[0, 5, 8, 11]]);
101
+ }, _callee2, null, [[0, 5, 8, 12]]);
95
102
  }));
96
103
  return function logout() {
97
104
  return _ref2.apply(this, arguments);
@@ -85,7 +85,7 @@ export var ConversationsMenu = function ConversationsMenu() {
85
85
  setState({
86
86
  open: true,
87
87
  session: session,
88
- rename: session.title
88
+ rename: session.title.slice(0, 100)
89
89
  });
90
90
  }
91
91
  }, {
@@ -156,10 +156,16 @@ export var ConversationsMenu = function ConversationsMenu() {
156
156
  },
157
157
  okButtonProps: {
158
158
  disabled: !state.rename
159
- }
159
+ },
160
+ okText: formatMessage({
161
+ id: 'ai.conversations.ok'
162
+ }),
163
+ cancelText: formatMessage({
164
+ id: 'ai.conversations.cancel'
165
+ })
160
166
  }, /*#__PURE__*/React.createElement(Input, {
161
167
  showCount: true,
162
- maxLength: 20,
168
+ maxLength: 100,
163
169
  onChange: function onChange(e) {
164
170
  return setState({
165
171
  rename: e.target.value
@@ -4,23 +4,24 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
4
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
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
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import { CheckOutlined, CopyOutlined, PlusSquareOutlined, SyncOutlined } from '@ant-design/icons';
7
+ import { BranchesOutlined, CheckOutlined, CopyOutlined, DeleteOutlined, PlusSquareOutlined, SyncOutlined } from '@ant-design/icons';
8
8
  import { Bubble } from '@ant-design/x';
9
9
  import { Button, Flex, Space, Tooltip } from 'antd';
10
10
  import { useChat } from '@ai-sdk/react';
11
11
  import { TextStreamChatTransport } from 'ai';
12
- import { useIntl } from 'dumi';
12
+ import { useIntl, useSiteData } from 'dumi';
13
13
  import { findLast } from 'lodash-es';
14
14
  import React, { useEffect, useState, useMemo, useRef } from 'react';
15
15
  import { useCopyToClipboard } from 'react-use';
16
16
  import { useSnapshot } from 'valtio';
17
17
  import { PromptTextarea } from "../../../../components/AI/HomeDialog/PromptTextarea";
18
- import { AIChatStore, clearEmptySession, createPureNewSession, derivedState } from "../../../../model/AIChat";
18
+ import { AIChatStore, branchMessage, clearEmptySession, createPureNewSession, deleteMessage, derivedState } from "../../../../model/AIChat";
19
19
  import { getCodeFromMarkdown, isPreviewable } from "../../../../utils/code";
20
20
  import { MarkdownComponent } from "../MarkdownComponent";
21
21
  import styles from "./index.module.less";
22
22
  import { useAutoScroll } from "./useAutoScroll";
23
23
  import { getBaseURL } from "../../../../utils/env";
24
+ import { AIMode } from "../../../../components/AI/constant";
24
25
  var avatar = {
25
26
  icon: /*#__PURE__*/React.createElement("img", {
26
27
  draggable: false,
@@ -92,6 +93,8 @@ function MsgBox(props) {
92
93
  // 使用 ref 存储动态值,避免重新创建 transport
93
94
  var anonymousUserIdRef = useRef(snap.anonymousUserId);
94
95
  var activeSessionIdRef = useRef((_derivedSnap$activeSe2 = derivedSnap.activeSession) === null || _derivedSnap$activeSe2 === void 0 ? void 0 : _derivedSnap$activeSe2.id);
96
+ var _useSiteData = useSiteData(),
97
+ themeConfig = _useSiteData.themeConfig;
95
98
  useEffect(function () {
96
99
  var _derivedSnap$activeSe3;
97
100
  anonymousUserIdRef.current = snap.anonymousUserId;
@@ -119,7 +122,7 @@ function MsgBox(props) {
119
122
  mountId: 'container',
120
123
  antvContext: (latestUserMessage === null || latestUserMessage === void 0 ? void 0 : latestUserMessage.context) || props.context,
121
124
  library: AIChatStore.lib,
122
- mode: latestUserMessage === null || latestUserMessage === void 0 ? void 0 : latestUserMessage.mode
125
+ mode: AIChatStore.mode
123
126
  };
124
127
  }
125
128
  }),
@@ -187,7 +190,7 @@ function MsgBox(props) {
187
190
  body: {
188
191
  context: fileSummary,
189
192
  lib: snap.lib,
190
- mode: 'implement'
193
+ mode: snap.mode
191
194
  }
192
195
  });
193
196
  setPromptText('');
@@ -237,6 +240,10 @@ function MsgBox(props) {
237
240
  chatScrollIntoView();
238
241
  if (simple) {
239
242
  createPureNewSession(title);
243
+ AIChatStore.mode = AIMode.implement;
244
+ if (!themeConfig.isAntVSite && themeConfig.title) {
245
+ AIChatStore.lib = themeConfig.title;
246
+ }
240
247
  }
241
248
  return function () {
242
249
  if (simple) {
@@ -267,9 +274,9 @@ function MsgBox(props) {
267
274
  showRunButton: !props.simple
268
275
  }),
269
276
  avatar: msg.role === 'assistant' ? avatar : null,
270
- footer: msg.role === 'assistant' && index > 0 && index === messages.length - 1 && status === 'ready' ? /*#__PURE__*/React.createElement(Space, {
277
+ footer: status === 'ready' && /*#__PURE__*/React.createElement(Space, {
271
278
  size: "small"
272
- }, /*#__PURE__*/React.createElement(Tooltip, {
279
+ }, msg.role === 'assistant' && index === messages.length - 1 && /*#__PURE__*/React.createElement(Tooltip, {
273
280
  title: formatMessage({
274
281
  id: 'ai.msgbox.retry'
275
282
  })
@@ -294,7 +301,31 @@ function MsgBox(props) {
294
301
  return copyToClipboard(textContent);
295
302
  },
296
303
  icon: copyState.value === textContent ? /*#__PURE__*/React.createElement(CheckOutlined, null) : /*#__PURE__*/React.createElement(CopyOutlined, null)
297
- }))) : null,
304
+ })), /*#__PURE__*/React.createElement(Tooltip, {
305
+ title: formatMessage({
306
+ id: 'ai.msgbox.continue.from.here'
307
+ })
308
+ }, /*#__PURE__*/React.createElement(Button, {
309
+ color: "default",
310
+ variant: "text",
311
+ size: "small",
312
+ onClick: function onClick() {
313
+ return branchMessage(index);
314
+ },
315
+ icon: /*#__PURE__*/React.createElement(BranchesOutlined, null)
316
+ })), msg.role === 'assistant' && /*#__PURE__*/React.createElement(Tooltip, {
317
+ title: formatMessage({
318
+ id: 'ai.msgbox.delete'
319
+ })
320
+ }, /*#__PURE__*/React.createElement(Button, {
321
+ color: "default",
322
+ variant: "text",
323
+ size: "small",
324
+ onClick: function onClick() {
325
+ return deleteMessage(msg.id);
326
+ },
327
+ icon: /*#__PURE__*/React.createElement(DeleteOutlined, null)
328
+ }))),
298
329
  placement: msg.role === 'user' ? 'end' : 'start'
299
330
  });
300
331
  }), (status === 'streaming' || status === 'submitted') && ((_messages = messages[messages.length - 1]) === null || _messages === void 0 ? void 0 : _messages.role) === 'user' && /*#__PURE__*/React.createElement(Bubble, {
@@ -316,7 +347,6 @@ function MsgBox(props) {
316
347
  id: 'ai.msgbox.start.new.chat'
317
348
  }))))), /*#__PURE__*/React.createElement(PromptTextarea, {
318
349
  size: "compact",
319
- mode: "implement",
320
350
  value: promptText,
321
351
  onChange: setPromptText,
322
352
  loading: status === 'streaming' || status === 'submitted',
@@ -326,7 +356,8 @@ function MsgBox(props) {
326
356
  marginBottom: 0
327
357
  },
328
358
  onConfirm: handleSubmit,
329
- onDataSummaryChange: setFileSummary
359
+ onDataSummaryChange: setFileSummary,
360
+ showModeSelector: true
330
361
  })));
331
362
  }
332
363
  export default MsgBox;
@@ -38,7 +38,8 @@ function SessionLayout(props) {
38
38
  primary: "second",
39
39
  style: {
40
40
  position: 'unset'
41
- }
41
+ },
42
+ minSize: 100
42
43
  }, /*#__PURE__*/React.createElement("div", {
43
44
  className: classnames(styles.msgBox)
44
45
  }, children[0]), /*#__PURE__*/React.createElement("div", {
@@ -2,8 +2,9 @@
2
2
  display: flex;
3
3
  gap: 12px;
4
4
  background: #f6f7fb;
5
- height: calc(100vh - 64px);
6
5
  padding: 0;
6
+ flex-grow: 1;
7
+ overflow-y: auto;
7
8
  }
8
9
 
9
10
  .msgBox, .taskBox{
@@ -79,11 +79,17 @@ export function wrap2VisionSnap() {
79
79
  var codeBlock = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
80
80
  var dependencies = generateDependencies(codeBlock);
81
81
  var rootElementType = dependencies['@antv/f2'] ? 'canvas' : 'div';
82
+ var dependenciesJSON = {
83
+ "name": "AntV-adapted-project",
84
+ "version": "1.0.0",
85
+ "main": "/src/index.jsx",
86
+ "dependencies": dependencies
87
+ };
82
88
  return {
83
89
  modules: {
84
90
  '/package.json': {
85
91
  fpath: '/package.json',
86
- code: "{\n \"name\": \"AntV-adapted-project\",\n \"version\": \"1.0.0\",\n \"main\": \"/src/index.jsx\",\n \"dependencies\": ".concat(JSON.stringify(dependencies, null, 2), "\n}")
92
+ code: JSON.stringify(dependenciesJSON, null, 2)
87
93
  },
88
94
  '/src/index.jsx': {
89
95
  fpath: '/src/index.jsx',
@@ -48,7 +48,8 @@ function TaskBox() {
48
48
  if (loading) {
49
49
  return /*#__PURE__*/React.createElement(Loading, null);
50
50
  }
51
- if (themeConfig.isAntVSite || ((_themeConfig$ai = themeConfig.ai) === null || _themeConfig$ai === void 0 ? void 0 : _themeConfig$ai.codeRunner) === "VisionSnap" || !((_themeConfig$ai2 = themeConfig.ai) !== null && _themeConfig$ai2 !== void 0 && _themeConfig$ai2.codeRunner)) {
51
+ var wrappedVisionSnapCode = wrap2VisionSnap(snap.codeBlock);
52
+ if (themeConfig.isAntVSite || ((_themeConfig$ai = themeConfig.ai) === null || _themeConfig$ai === void 0 ? void 0 : _themeConfig$ai.codeRunner) === "VisionSnap" || !((_themeConfig$ai2 = themeConfig.ai) !== null && _themeConfig$ai2 !== void 0 && _themeConfig$ai2.codeRunner) || !wrappedVisionSnapCode.modules["/package.json"].code.includes("@antv/f2")) {
52
53
  return /*#__PURE__*/React.createElement(ErrorBoundary, {
53
54
  FallbackComponent: ErrorFallback
54
55
  }, /*#__PURE__*/React.createElement(sdk.VisionPreview, {
@@ -61,7 +62,7 @@ function TaskBox() {
61
62
  displayMode: "code-and-preview",
62
63
  initialView: "preview",
63
64
  theme: "light",
64
- code: wrap2VisionSnap(snap.codeBlock),
65
+ code: wrappedVisionSnapCode,
65
66
  requestProxy: requestProxy,
66
67
  isStreaming: false,
67
68
  proxyOptions: {
@@ -3,7 +3,10 @@ import { SessionLayout } from "./components/SessionLayout";
3
3
  import MsgBox from "./components/MsgBox";
4
4
  import TaskBox from "./components/TaskBox";
5
5
  import Header from "dumi/theme/slots/Header";
6
+ import styles from "./index.module.less";
6
7
  function AIPlayground() {
7
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Header, null), /*#__PURE__*/React.createElement(SessionLayout, null, /*#__PURE__*/React.createElement(MsgBox, null), /*#__PURE__*/React.createElement(TaskBox, null)));
8
+ return /*#__PURE__*/React.createElement("div", {
9
+ className: styles.aiPlayground
10
+ }, /*#__PURE__*/React.createElement(Header, null), /*#__PURE__*/React.createElement(SessionLayout, null, /*#__PURE__*/React.createElement(MsgBox, null), /*#__PURE__*/React.createElement(TaskBox, null)));
8
11
  }
9
12
  export default AIPlayground;
@@ -0,0 +1,5 @@
1
+ .aiPlayground {
2
+ display: flex;
3
+ flex-direction: column;
4
+ height: 100vh;
5
+ }
@@ -23,6 +23,7 @@ import { News } from "./News";
23
23
  import { ic } from "../hooks";
24
24
  import styles from "./index.module.less";
25
25
  import { HomeDialog } from "../../components/AI/HomeDialog";
26
+ import { getBaseSiteDataUrl } from "../../utils/env";
26
27
  /**
27
28
  * Index.技术栈的描述区域!
28
29
  * 各自配置
@@ -48,7 +49,7 @@ export var Detail = function Detail(_ref) {
48
49
  setRemoteNews = _useState2[1];
49
50
  var lang = useLocale().id;
50
51
  useEffect(function () {
51
- fetch('https://assets.antv.antgroup.com/antv/banner-messages.json' // 生产环境
52
+ fetch("".concat(getBaseSiteDataUrl(), "/antv/banner-messages.json") // 生产环境
52
53
  // 'https://site-data-pre.alipay.com/antv/banner-messages.json', // 预发测试
53
54
  ).then(function (res) {
54
55
  return res.json();
@@ -2,7 +2,7 @@ import { useIntl, useSiteData } from 'dumi';
2
2
  import React from 'react';
3
3
  import styles from "./SearchResult.module.less";
4
4
  import classnames from "classnames";
5
- import { createNewSession } from "../../../model/AIChat";
5
+ import { AIChatStore, createNewSession } from "../../../model/AIChat";
6
6
  import { authStore, showLoginModal } from "../../../model/auth";
7
7
  import { useSnapshot } from "valtio";
8
8
  var getHighlightInfo = function getHighlightInfo(textSegments) {
@@ -25,6 +25,7 @@ export var SearchResult = function SearchResult(_ref) {
25
25
  var intl = useIntl();
26
26
  var authSnap = useSnapshot(authStore);
27
27
  function pureSearch() {
28
+ AIChatStore.mode = 'solve';
28
29
  createNewSession({
29
30
  promptText: keywords,
30
31
  mode: 'solve',
@@ -18,7 +18,7 @@ import { Alert, Button, Dropdown, Menu, Modal, Popover } from 'antd';
18
18
  import cx from 'classnames';
19
19
  import { FormattedMessage, Link, useLocale, useSiteData, useIntl, history } from 'dumi';
20
20
  import { get, map, size } from 'lodash-es';
21
- import React, { useEffect, useMemo, useState } from 'react';
21
+ import React, { useEffect, useState } from 'react';
22
22
  import { useMedia } from 'react-use';
23
23
  import { getPurePathname } from "../../utils/location";
24
24
  import { ic, icWithLocale } from "../hooks";
@@ -57,9 +57,6 @@ var HeaderComponent = function HeaderComponent(_ref) {
57
57
  showAntVProductsCard = _ref$showAntVProducts === void 0 ? true : _ref$showAntVProducts,
58
58
  _ref$showLanguageSwit = _ref.showLanguageSwitcher,
59
59
  showLanguageSwitcher = _ref$showLanguageSwit === void 0 ? true : _ref$showLanguageSwit,
60
- _ref$showWeavefox = _ref.showWeavefox,
61
- showWeavefox = _ref$showWeavefox === void 0 ? {} : _ref$showWeavefox,
62
- isInternalUser = _ref.isInternalUser,
63
60
  logo = _ref.logo,
64
61
  onLanguageChange = _ref.onLanguageChange,
65
62
  _ref$showWxQrcode = _ref.showWxQrcode,
@@ -154,8 +151,7 @@ var HeaderComponent = function HeaderComponent(_ref) {
154
151
  }),
155
152
  link: ''
156
153
  }, logo),
157
- img = _img$link$logo.img,
158
- link = _img$link$logo.link;
154
+ img = _img$link$logo.img;
159
155
  var _useLocation = useLocation(),
160
156
  pathname = _useLocation.pathname;
161
157
  useEffect(function () {
@@ -190,27 +186,13 @@ var HeaderComponent = function HeaderComponent(_ref) {
190
186
  var handleSwitchLanguage = function handleSwitchLanguage() {
191
187
  onLanguageChange === null || onLanguageChange === void 0 || onLanguageChange(lang);
192
188
  };
193
- var weavefox = useMemo(function () {
194
- var configKey = isInternalUser ? 'internal' : 'public';
195
- var configValue = showWeavefox[configKey];
196
- if (!configValue) return /*#__PURE__*/React.createElement(React.Fragment, null);
197
- var defaultLink = isInternalUser ? 'https://weavefox.antgroup-inc.cn/agent/@huiyu.zjt/AntV' : 'https://weavefox.alipay.com/agent/@ufox-b8tydq-0758/202505AP7vfl00422922';
198
- var href = typeof configValue === 'string' ? configValue : defaultLink;
199
- return /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("a", {
200
- href: href,
201
- target: "_blank",
202
- rel: "noreferrer"
203
- }, /*#__PURE__*/React.createElement(FormattedMessage, {
204
- id: "header.ai.code"
205
- })));
206
- }, [isInternalUser, showWeavefox]);
207
189
  var menu = /*#__PURE__*/React.createElement("ul", {
208
190
  className: cx(styles.menu, _defineProperty(_defineProperty({}, styles.popup, !isWide), styles.popupHidden, !popupMenuVisible))
209
191
  }, /** 最左侧的菜单,一般是 教程、API、示例,或者其他自定义,有配置文件中的 `navs` 决定 */
210
192
  size(navs) ? /*#__PURE__*/React.createElement(Navs, {
211
193
  navs: navs,
212
194
  path: pathname
213
- }) : null, weavefox, /** 生态产品 */
195
+ }) : null, /** 生态产品 */
214
196
  size(ecosystems) ? /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement(Dropdown, {
215
197
  className: styles.ecoSystems,
216
198
  overlay: /*#__PURE__*/React.createElement(Menu, null, map(ecosystems, function (_ref2) {
package/dist/utils/env.js CHANGED
@@ -11,38 +11,64 @@ export var safeWindow = function safeWindow(fn) {
11
11
  };
12
12
 
13
13
  /**
14
- * 根据当前环境动态获取 API 的 baseURL。
15
- * 在浏览器中,它会根据域名判断;在服务端,它会返回一个固定的生产环境地址。
16
- * @returns {string} API 的 baseURL
14
+ * 环境类型枚举
17
15
  */
18
- export var getBaseURL = function getBaseURL() {
19
- // 关键:检查是否在浏览器环境
16
+
17
+ /**
18
+ * 获取当前环境类型
19
+ * @returns {EnvType} 当前环境类型
20
+ */
21
+ export var getEnv = function getEnv() {
22
+ // 服务端环境默认返回生产环境
20
23
  if (typeof window === 'undefined') {
21
- // === 服务端环境 (SSR/Pre-render) ===
22
- // 在服务端渲染时,我们无法知道用户最终会通过哪个域名访问。
23
- // 通常,我们默认返回生产环境的 API 地址。
24
- // 这样预渲染出的页面如果需要请求数据,会直接请求线上API。
25
- return 'https://www.weavefox.cn';
24
+ return 'prod';
26
25
  }
27
-
28
- // === 浏览器环境 ===
29
26
  var hostname = window.location.hostname;
30
27
 
31
28
  // 生产环境
32
29
  if (hostname.endsWith('antv.antgroup.com')) {
33
- return 'https://www.weavefox.cn';
30
+ return 'prod';
34
31
  }
35
32
 
36
33
  // 预发环境
37
34
  if (hostname.endsWith('-pre.alipay.com')) {
38
- return 'https://prepub.weavefox.cn';
35
+ return 'pre';
39
36
  }
40
37
 
41
38
  // 本地环境
42
39
  if (hostname.endsWith('.alipay.net')) {
43
- return 'https://weavefox.alipay.net:8443';
40
+ return 'dev';
44
41
  }
45
42
 
46
- // 默认返回生产环境地址,适用于其他未知域名(如 localhost)
47
- return 'https://www.weavefox.cn';
43
+ // 默认返回生产环境
44
+ return 'prod';
45
+ };
46
+
47
+ /**
48
+ * 根据当前环境动态获取 API 的 baseURL。
49
+ * 在浏览器中,它会根据域名判断;在服务端,它会返回一个固定的生产环境地址。
50
+ * @returns {string} API 的 baseURL
51
+ */
52
+ export var getBaseURL = function getBaseURL() {
53
+ var env = getEnv();
54
+ switch (env) {
55
+ case 'dev':
56
+ return 'https://weavefox.alipay.net:8443';
57
+ case 'pre':
58
+ return 'https://prepub.weavefox.cn';
59
+ case 'prod':
60
+ default:
61
+ return 'https://www.weavefox.cn';
62
+ }
63
+ };
64
+ export var getBaseSiteDataUrl = function getBaseSiteDataUrl() {
65
+ var env = getEnv();
66
+ switch (env) {
67
+ case 'dev':
68
+ case 'pre':
69
+ return 'https://site-data-pre.alipay.com';
70
+ case 'prod':
71
+ default:
72
+ return 'https://assets.antv.antgroup.com';
73
+ }
48
74
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/dumi-theme-antv",
3
- "version": "0.8.0-beta.12",
3
+ "version": "0.8.0-beta.14",
4
4
  "description": "AntV website theme based on dumi2.",
5
5
  "keywords": [
6
6
  "dumi",