@antv/dumi-theme-antv 0.8.0-beta.12 → 0.8.0-beta.13
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.
- package/dist/components/AI/HomeDialog/ModeSelector/ModeSelectorDropdown.js +42 -0
- package/dist/components/AI/HomeDialog/PromptTextarea/ChooseLib/index.js +7 -2
- package/dist/components/AI/HomeDialog/PromptTextarea/index.js +6 -4
- package/dist/components/AI/HomeDialog/RecommendCase/Card.js +11 -6
- package/dist/components/AI/HomeDialog/RecommendCase/card.module.less +2 -2
- package/dist/components/AI/HomeDialog/RecommendCase/index.js +31 -21
- package/dist/components/AI/HomeDialog/RecommendCase/recommend.json +41 -17
- package/dist/components/AI/HomeDialog/index.js +8 -15
- package/dist/components/AI/constant.js +4 -2
- package/dist/hooks/useProducts.js +19 -1
- package/dist/locales/en.json +2 -0
- package/dist/locales/zh.json +2 -0
- package/dist/model/AIChat.js +3 -1
- package/dist/model/auth.js +11 -4
- package/dist/pages/AIPlayground/components/ConversationsMenu/index.js +2 -2
- package/dist/pages/AIPlayground/components/MsgBox/index.js +12 -5
- package/dist/pages/AIPlayground/components/TaskBox/index.js +1 -1
- package/dist/slots/Detail/index.js +2 -1
- package/dist/utils/env.js +43 -17
- 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 &&
|
|
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
|
-
|
|
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:
|
|
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:
|
|
115
|
+
min-width: 80px;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
.popoverValue {
|
|
@@ -16,7 +16,10 @@ 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),
|
|
@@ -24,49 +27,53 @@ export var RecommendCase = function RecommendCase(props) {
|
|
|
24
27
|
setLoading = _useState2[1];
|
|
25
28
|
var _useSiteData = useSiteData(),
|
|
26
29
|
themeConfig = _useSiteData.themeConfig;
|
|
27
|
-
var _useState3 = useState(
|
|
30
|
+
var _useState3 = useState(RecommendJson),
|
|
28
31
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
29
32
|
list = _useState4[0],
|
|
30
33
|
setList = _useState4[1];
|
|
34
|
+
var _useLibrary = useLibrary(),
|
|
35
|
+
_useLibrary$data = _useLibrary.data,
|
|
36
|
+
library = _useLibrary$data === void 0 ? [] : _useLibrary$data;
|
|
31
37
|
var fetchList = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
32
|
-
var _themeConfig$ai, data;
|
|
38
|
+
var _themeConfig$ai, data, url;
|
|
33
39
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
34
40
|
while (1) switch (_context.prev = _context.next) {
|
|
35
41
|
case 0:
|
|
36
42
|
_context.prev = 0;
|
|
37
43
|
setLoading(true);
|
|
38
44
|
data = [];
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
url = themeConfig.isAntVSite ? "".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");
|
|
46
|
+
if (!url) {
|
|
47
|
+
_context.next = 10;
|
|
41
48
|
break;
|
|
42
49
|
}
|
|
43
|
-
_context.next =
|
|
44
|
-
return fetch(
|
|
50
|
+
_context.next = 7;
|
|
51
|
+
return fetch(url).then(function (res) {
|
|
45
52
|
return res.json();
|
|
46
53
|
});
|
|
47
|
-
case
|
|
54
|
+
case 7:
|
|
48
55
|
data = _context.sent;
|
|
49
|
-
_context.next =
|
|
56
|
+
_context.next = 11;
|
|
50
57
|
break;
|
|
51
|
-
case 9:
|
|
52
|
-
data = RecommendJson;
|
|
53
58
|
case 10:
|
|
59
|
+
data = RecommendJson;
|
|
60
|
+
case 11:
|
|
54
61
|
setList(sampleSize(data, 4));
|
|
55
|
-
_context.next =
|
|
62
|
+
_context.next = 17;
|
|
56
63
|
break;
|
|
57
|
-
case
|
|
58
|
-
_context.prev =
|
|
64
|
+
case 14:
|
|
65
|
+
_context.prev = 14;
|
|
59
66
|
_context.t0 = _context["catch"](0);
|
|
60
67
|
console.log(_context.t0);
|
|
61
|
-
case
|
|
62
|
-
_context.prev =
|
|
68
|
+
case 17:
|
|
69
|
+
_context.prev = 17;
|
|
63
70
|
setLoading(false);
|
|
64
|
-
return _context.finish(
|
|
65
|
-
case
|
|
71
|
+
return _context.finish(17);
|
|
72
|
+
case 20:
|
|
66
73
|
case "end":
|
|
67
74
|
return _context.stop();
|
|
68
75
|
}
|
|
69
|
-
}, _callee, null, [[0,
|
|
76
|
+
}, _callee, null, [[0, 14, 17, 20]]);
|
|
70
77
|
})), [list]);
|
|
71
78
|
useEffect(function () {
|
|
72
79
|
fetchList();
|
|
@@ -82,14 +89,14 @@ export var RecommendCase = function RecommendCase(props) {
|
|
|
82
89
|
className: styles.quickStart
|
|
83
90
|
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
84
91
|
id: "ai.recommend.title"
|
|
85
|
-
})), /*#__PURE__*/React.createElement("span", {
|
|
92
|
+
})), (list === null || list === void 0 ? void 0 : list.length) > 4 ? /*#__PURE__*/React.createElement("span", {
|
|
86
93
|
className: styles.refresh,
|
|
87
94
|
onClick: function onClick() {
|
|
88
95
|
return fetchList();
|
|
89
96
|
}
|
|
90
97
|
}, /*#__PURE__*/React.createElement(ReloadOutlined, null), /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
91
98
|
id: "ai.recommend.refresh"
|
|
92
|
-
}))), /*#__PURE__*/React.createElement(Spin, {
|
|
99
|
+
})) : /*#__PURE__*/React.createElement(React.Fragment, null)), /*#__PURE__*/React.createElement(Spin, {
|
|
93
100
|
spinning: loading,
|
|
94
101
|
wrapperClassName: classnames(styles.listContainer, props.className)
|
|
95
102
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -102,6 +109,9 @@ export var RecommendCase = function RecommendCase(props) {
|
|
|
102
109
|
onClick: function onClick() {
|
|
103
110
|
var _props$onClick;
|
|
104
111
|
(_props$onClick = props.onClick) === null || _props$onClick === void 0 || _props$onClick.call(props, item);
|
|
112
|
+
if (item.tag) {
|
|
113
|
+
AIChatStore.mode = item.tag;
|
|
114
|
+
}
|
|
105
115
|
}
|
|
106
116
|
});
|
|
107
117
|
}))));
|
|
@@ -2,41 +2,65 @@
|
|
|
2
2
|
{
|
|
3
3
|
"caseId": "1",
|
|
4
4
|
"tag": "implement",
|
|
5
|
-
"query":
|
|
6
|
-
|
|
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*
|
|
9
|
-
"https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*
|
|
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
|
-
|
|
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*
|
|
19
|
-
"https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*
|
|
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": "
|
|
25
|
-
"query":
|
|
26
|
-
|
|
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*
|
|
29
|
-
"https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*
|
|
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
|
-
|
|
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*
|
|
39
|
-
"https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*
|
|
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
|
|
21
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
}
|
package/dist/locales/en.json
CHANGED
|
@@ -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",
|
package/dist/locales/zh.json
CHANGED
|
@@ -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": "上传图片",
|
package/dist/model/AIChat.js
CHANGED
|
@@ -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 创建 ---
|
package/dist/model/auth.js
CHANGED
|
@@ -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
|
|
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
|
|
97
|
+
case 12:
|
|
91
98
|
case "end":
|
|
92
99
|
return _context2.stop();
|
|
93
100
|
}
|
|
94
|
-
}, _callee2, null, [[0, 5, 8,
|
|
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
|
}, {
|
|
@@ -159,7 +159,7 @@ export var ConversationsMenu = function ConversationsMenu() {
|
|
|
159
159
|
}
|
|
160
160
|
}, /*#__PURE__*/React.createElement(Input, {
|
|
161
161
|
showCount: true,
|
|
162
|
-
maxLength:
|
|
162
|
+
maxLength: 100,
|
|
163
163
|
onChange: function onChange(e) {
|
|
164
164
|
return setState({
|
|
165
165
|
rename: e.target.value
|
|
@@ -9,7 +9,7 @@ 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';
|
|
@@ -21,6 +21,7 @@ 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:
|
|
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:
|
|
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) {
|
|
@@ -316,7 +323,6 @@ function MsgBox(props) {
|
|
|
316
323
|
id: 'ai.msgbox.start.new.chat'
|
|
317
324
|
}))))), /*#__PURE__*/React.createElement(PromptTextarea, {
|
|
318
325
|
size: "compact",
|
|
319
|
-
mode: "implement",
|
|
320
326
|
value: promptText,
|
|
321
327
|
onChange: setPromptText,
|
|
322
328
|
loading: status === 'streaming' || status === 'submitted',
|
|
@@ -326,7 +332,8 @@ function MsgBox(props) {
|
|
|
326
332
|
marginBottom: 0
|
|
327
333
|
},
|
|
328
334
|
onConfirm: handleSubmit,
|
|
329
|
-
onDataSummaryChange: setFileSummary
|
|
335
|
+
onDataSummaryChange: setFileSummary,
|
|
336
|
+
showModeSelector: true
|
|
330
337
|
})));
|
|
331
338
|
}
|
|
332
339
|
export default MsgBox;
|
|
@@ -48,7 +48,7 @@ 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
|
+
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) || snap.lib !== 'F2') {
|
|
52
52
|
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
53
53
|
FallbackComponent: ErrorFallback
|
|
54
54
|
}, /*#__PURE__*/React.createElement(sdk.VisionPreview, {
|
|
@@ -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(
|
|
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();
|
package/dist/utils/env.js
CHANGED
|
@@ -11,38 +11,64 @@ export var safeWindow = function safeWindow(fn) {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
* 在浏览器中,它会根据域名判断;在服务端,它会返回一个固定的生产环境地址。
|
|
16
|
-
* @returns {string} API 的 baseURL
|
|
14
|
+
* 环境类型枚举
|
|
17
15
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 获取当前环境类型
|
|
19
|
+
* @returns {EnvType} 当前环境类型
|
|
20
|
+
*/
|
|
21
|
+
export var getEnv = function getEnv() {
|
|
22
|
+
// 服务端环境默认返回生产环境
|
|
20
23
|
if (typeof window === 'undefined') {
|
|
21
|
-
|
|
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 '
|
|
30
|
+
return 'prod';
|
|
34
31
|
}
|
|
35
32
|
|
|
36
33
|
// 预发环境
|
|
37
34
|
if (hostname.endsWith('-pre.alipay.com')) {
|
|
38
|
-
return '
|
|
35
|
+
return 'pre';
|
|
39
36
|
}
|
|
40
37
|
|
|
41
38
|
// 本地环境
|
|
42
39
|
if (hostname.endsWith('.alipay.net')) {
|
|
43
|
-
return '
|
|
40
|
+
return 'dev';
|
|
44
41
|
}
|
|
45
42
|
|
|
46
|
-
//
|
|
47
|
-
return '
|
|
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
|
};
|