@antv/dumi-theme-antv 0.6.4-beta.0 → 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/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,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
|
}));
|