@antv/dumi-theme-antv 0.6.3 → 0.6.4-beta.1
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/slots/Header/index.js +23 -11
- package/dist/utils/user.js +18 -11
- package/package.json +3 -2
|
@@ -17,7 +17,7 @@ import { CaretDownFilled, CheckOutlined, DownOutlined, GithubOutlined, LinkOutli
|
|
|
17
17
|
import { Alert, Button, Dropdown, Menu, Modal, Popover, Select } from 'antd';
|
|
18
18
|
import cx from 'classnames';
|
|
19
19
|
import { FormattedMessage, useLocale, useSiteData } from 'dumi';
|
|
20
|
-
import { get, map, size } from 'lodash-es';
|
|
20
|
+
import { get, isBoolean, map, size } from 'lodash-es';
|
|
21
21
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
22
22
|
import { useNavigate } from 'react-router-dom';
|
|
23
23
|
import { useMedia } from 'react-use';
|
|
@@ -461,7 +461,7 @@ export var Header = function Header(props) {
|
|
|
461
461
|
docsearchOptions = themeConfig.docsearchOptions,
|
|
462
462
|
announcement = themeConfig.announcement,
|
|
463
463
|
petercat = themeConfig.petercat,
|
|
464
|
-
|
|
464
|
+
isLinksShow = themeConfig.links;
|
|
465
465
|
var searchOptions = {
|
|
466
466
|
docsearchOptions: docsearchOptions
|
|
467
467
|
};
|
|
@@ -496,7 +496,6 @@ export var Header = function Header(props) {
|
|
|
496
496
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
497
497
|
isInternalUser = _useState12[0],
|
|
498
498
|
setIsInternalUser = _useState12[1];
|
|
499
|
-
var isPetercatShow = petercat === null || petercat === void 0 ? void 0 : petercat.show;
|
|
500
499
|
useEffect(function () {
|
|
501
500
|
var checkUserType = /*#__PURE__*/function () {
|
|
502
501
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
@@ -522,20 +521,33 @@ export var Header = function Header(props) {
|
|
|
522
521
|
checkUserType();
|
|
523
522
|
}, []);
|
|
524
523
|
useEffect(function () {
|
|
525
|
-
var
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
script
|
|
529
|
-
|
|
530
|
-
|
|
524
|
+
var scriptId = 'links-widget-script';
|
|
525
|
+
var script = document.getElementById(scriptId);
|
|
526
|
+
if (isInternalUser && isLinksShow) {
|
|
527
|
+
if (!script) {
|
|
528
|
+
script = document.createElement('script');
|
|
529
|
+
script.id = scriptId;
|
|
530
|
+
script.src = 'https://links.alipay.com/widgetInit/67a96a296b6fa80490bdf892';
|
|
531
|
+
script.async = true;
|
|
532
|
+
document.body.appendChild(script);
|
|
533
|
+
}
|
|
534
|
+
} else {
|
|
535
|
+
if (script) {
|
|
536
|
+
document.body.removeChild(script);
|
|
537
|
+
}
|
|
531
538
|
}
|
|
532
539
|
return function () {
|
|
533
540
|
if (script) {
|
|
534
541
|
document.body.removeChild(script);
|
|
535
542
|
}
|
|
536
543
|
};
|
|
537
|
-
}, [isInternalUser]);
|
|
538
|
-
|
|
544
|
+
}, [isInternalUser, isLinksShow]);
|
|
545
|
+
|
|
546
|
+
// 当 petercat.show 为 true 且以下任一条件满足时展示 Petercat Assistant:
|
|
547
|
+
// 1. 外部用户访问
|
|
548
|
+
// 2. 不显示 links 研发小蜜
|
|
549
|
+
var isPetercatShow = (petercat === null || petercat === void 0 ? void 0 : petercat.show) && (isBoolean(isInternalUser) && !isInternalUser || !isLinksShow);
|
|
550
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(HeaderComponent, Object.assign({}, headerProps, props)), isPetercatShow && /*#__PURE__*/React.createElement(Assistant, {
|
|
539
551
|
token: petercat === null || petercat === void 0 ? void 0 : petercat.token,
|
|
540
552
|
apiDomain: "https://api.petercat.ai"
|
|
541
553
|
}));
|
package/dist/utils/user.js
CHANGED
|
@@ -51,6 +51,8 @@ var fetchWithTimeout = /*#__PURE__*/function () {
|
|
|
51
51
|
return _ref.apply(this, arguments);
|
|
52
52
|
};
|
|
53
53
|
}();
|
|
54
|
+
|
|
55
|
+
// 仅限于蚂蚁用户为 true
|
|
54
56
|
var isInternalUser;
|
|
55
57
|
|
|
56
58
|
/**
|
|
@@ -58,7 +60,7 @@ var isInternalUser;
|
|
|
58
60
|
*/
|
|
59
61
|
export var determineUserType = /*#__PURE__*/function () {
|
|
60
62
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
61
|
-
var url, timeout;
|
|
63
|
+
var url, timeout, res;
|
|
62
64
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
63
65
|
while (1) switch (_context2.prev = _context2.next) {
|
|
64
66
|
case 0:
|
|
@@ -68,26 +70,31 @@ export var determineUserType = /*#__PURE__*/function () {
|
|
|
68
70
|
}
|
|
69
71
|
return _context2.abrupt("return", isInternalUser);
|
|
70
72
|
case 2:
|
|
71
|
-
url = 'https://
|
|
72
|
-
timeout = 5000;
|
|
73
|
+
url = 'https://links.alipay.com/cors/room/67a96a296b6fa80490bdf892/tipConfig';
|
|
74
|
+
timeout = 5000;
|
|
73
75
|
_context2.prev = 4;
|
|
74
76
|
_context2.next = 7;
|
|
75
77
|
return fetchWithTimeout(url, {}, timeout);
|
|
76
78
|
case 7:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
res = _context2.sent;
|
|
80
|
+
if ((res === null || res === void 0 ? void 0 : res.buserviceErrorCode) === 'USER_NOT_LOGIN') {
|
|
81
|
+
isInternalUser = false; // 集团用户
|
|
82
|
+
} else {
|
|
83
|
+
isInternalUser = true; // 蚂蚁用户
|
|
84
|
+
}
|
|
85
|
+
_context2.next = 14;
|
|
79
86
|
break;
|
|
80
|
-
case
|
|
81
|
-
_context2.prev =
|
|
87
|
+
case 11:
|
|
88
|
+
_context2.prev = 11;
|
|
82
89
|
_context2.t0 = _context2["catch"](4);
|
|
83
|
-
isInternalUser = false;
|
|
84
|
-
case 13:
|
|
85
|
-
return _context2.abrupt("return", isInternalUser);
|
|
90
|
+
isInternalUser = false; // 外部用户
|
|
86
91
|
case 14:
|
|
92
|
+
return _context2.abrupt("return", isInternalUser);
|
|
93
|
+
case 15:
|
|
87
94
|
case "end":
|
|
88
95
|
return _context2.stop();
|
|
89
96
|
}
|
|
90
|
-
}, _callee2, null, [[4,
|
|
97
|
+
}, _callee2, null, [[4, 11]]);
|
|
91
98
|
}));
|
|
92
99
|
return function determineUserType() {
|
|
93
100
|
return _ref2.apply(this, arguments);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/dumi-theme-antv",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4-beta.1",
|
|
4
4
|
"description": "AntV website theme based on dumi2.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dumi",
|
|
@@ -129,7 +129,8 @@
|
|
|
129
129
|
"react-dom": ">=16.9.0"
|
|
130
130
|
},
|
|
131
131
|
"publishConfig": {
|
|
132
|
-
"access": "public"
|
|
132
|
+
"access": "public",
|
|
133
|
+
"tag": "beta"
|
|
133
134
|
},
|
|
134
135
|
"authors": [
|
|
135
136
|
"dumi",
|