@antv/dumi-theme-antv 0.6.4-beta.0 → 0.6.4-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/slots/Header/index.js +21 -14
- package/dist/utils/user.js +6 -1
- package/package.json +1 -1
|
@@ -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,28 @@ export var Header = function Header(props) {
|
|
|
522
521
|
checkUserType();
|
|
523
522
|
}, []);
|
|
524
523
|
useEffect(function () {
|
|
525
|
-
var
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
script
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
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 {
|
|
533
535
|
if (script) {
|
|
534
536
|
document.body.removeChild(script);
|
|
535
537
|
}
|
|
536
|
-
}
|
|
537
|
-
}, [isInternalUser]);
|
|
538
|
-
|
|
538
|
+
}
|
|
539
|
+
}, [isInternalUser, isLinksShow]);
|
|
540
|
+
|
|
541
|
+
// 当 petercat.show 为 true 且以下任一条件满足时展示 Petercat Assistant:
|
|
542
|
+
// 1. 外部用户访问
|
|
543
|
+
// 2. 不显示 links 研发小蜜
|
|
544
|
+
var isPetercatShow = (petercat === null || petercat === void 0 ? void 0 : petercat.show) && (isBoolean(isInternalUser) && !isInternalUser || !isLinksShow);
|
|
545
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(HeaderComponent, Object.assign({}, headerProps, props)), isPetercatShow && /*#__PURE__*/React.createElement(Assistant, {
|
|
539
546
|
token: petercat === null || petercat === void 0 ? void 0 : petercat.token,
|
|
540
547
|
apiDomain: "https://api.petercat.ai"
|
|
541
548
|
}));
|
package/dist/utils/user.js
CHANGED
|
@@ -74,7 +74,12 @@ export var determineUserType = /*#__PURE__*/function () {
|
|
|
74
74
|
timeout = 5000;
|
|
75
75
|
_context2.prev = 4;
|
|
76
76
|
_context2.next = 7;
|
|
77
|
-
return fetchWithTimeout(url, {
|
|
77
|
+
return fetchWithTimeout(url, {
|
|
78
|
+
method: 'GET',
|
|
79
|
+
headers: {
|
|
80
|
+
'Content-Type': 'application/json; charset=utf-8'
|
|
81
|
+
}
|
|
82
|
+
}, timeout);
|
|
78
83
|
case 7:
|
|
79
84
|
res = _context2.sent;
|
|
80
85
|
if ((res === null || res === void 0 ? void 0 : res.buserviceErrorCode) === 'USER_NOT_LOGIN') {
|