@antv/dumi-theme-antv 0.3.0-beta.10 → 0.3.0-beta.11
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/builtins/Playground/index.js +10 -5
- package/dist/layouts/DocLayout.js +2 -3
- package/dist/layouts/entry/Index.js +1 -1
- package/dist/layouts/entry/Manual.js +4 -1
- package/dist/pages/Examples/components/GalleryPageContent/DemoCard/index.js +7 -4
- package/dist/plugin/index.js +1 -0
- package/dist/slots/Cases/index.js +1 -1
- package/dist/slots/Cases/index.module.less +2 -1
- package/dist/slots/CodeEditor/index.d.ts +4 -0
- package/dist/slots/CodeEditor/index.js +13 -7
- package/dist/slots/CodeEditor/utils.js +1 -1
- package/dist/slots/CodePreview/CodeHeader.js +15 -14
- package/dist/slots/CodePreview/index.d.ts +8 -0
- package/dist/slots/CodePreview/index.js +5 -3
- package/dist/slots/CodePreview/index.module.less +11 -2
- package/dist/slots/CodeRunner/index.d.ts +2 -0
- package/dist/slots/CodeRunner/index.js +12 -1
- package/dist/slots/Footer/index.module.less +0 -1
- package/dist/slots/Header/Navs.d.ts +2 -2
- package/dist/slots/Header/Navs.js +7 -7
- package/dist/slots/ManualContent/index.js +12 -10
- package/dist/slots/ManualContent/index.module.less +5 -10
- package/dist/slots/ManualContent/utils.d.ts +15 -0
- package/dist/slots/ManualContent/utils.js +30 -1
- package/dist/slots/{TOC.d.ts → TOC/index.d.ts} +1 -0
- package/dist/slots/{TOC.js → TOC/index.js} +1 -0
- package/dist/slots/TOC/index.module.less +11 -0
- package/package.json +2 -1
|
@@ -10,6 +10,8 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
10
10
|
|
|
11
11
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
12
|
|
|
13
|
+
import { useSiteData } from 'dumi';
|
|
14
|
+
import { get } from 'lodash-es';
|
|
13
15
|
import React, { useContext } from 'react';
|
|
14
16
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
15
17
|
import { ThemeAntVContext } from "../../context";
|
|
@@ -22,8 +24,7 @@ import styles from "./index.module.less";
|
|
|
22
24
|
var Playground = function Playground(_ref) {
|
|
23
25
|
var rid = _ref.rid,
|
|
24
26
|
path = _ref.path,
|
|
25
|
-
|
|
26
|
-
ratio = _ref$ratio === void 0 ? 0.62 : _ref$ratio,
|
|
27
|
+
ratio = _ref.ratio,
|
|
27
28
|
_ref$height = _ref.height,
|
|
28
29
|
height = _ref$height === void 0 ? 400 : _ref$height;
|
|
29
30
|
|
|
@@ -40,22 +41,26 @@ var Playground = function Playground(_ref) {
|
|
|
40
41
|
example = _ref3[2],
|
|
41
42
|
demo = _ref3[3];
|
|
42
43
|
|
|
44
|
+
var themeConfig = useSiteData();
|
|
45
|
+
var defaultSize = get(themeConfig, 'editor.playgroundSize', 0.38);
|
|
43
46
|
return /*#__PURE__*/React.createElement("div", {
|
|
44
47
|
className: styles.container,
|
|
45
48
|
style: {
|
|
46
49
|
height: height
|
|
47
50
|
}
|
|
48
51
|
}, /*#__PURE__*/React.createElement(CodeRunner, {
|
|
52
|
+
isPlayground: true,
|
|
49
53
|
exampleTopics: exampleTopics,
|
|
50
54
|
topic: topic,
|
|
51
55
|
example: example,
|
|
52
|
-
demo: demo
|
|
56
|
+
demo: demo,
|
|
57
|
+
size: ratio || defaultSize,
|
|
58
|
+
replaceId: rid
|
|
53
59
|
}));
|
|
54
60
|
};
|
|
55
61
|
|
|
56
62
|
function ErrorFallback(_ref4) {
|
|
57
|
-
var error = _ref4.error
|
|
58
|
-
resetErrorBoundary = _ref4.resetErrorBoundary;
|
|
63
|
+
var error = _ref4.error;
|
|
59
64
|
console.log(error);
|
|
60
65
|
return /*#__PURE__*/React.createElement("div", {
|
|
61
66
|
role: "alert"
|
|
@@ -29,10 +29,9 @@ export default (function () {
|
|
|
29
29
|
|
|
30
30
|
if (p === '/' || p === '/zh' || p === '/en' || p === '/en/') return /*#__PURE__*/React.createElement(Index, null); // 匹配 navs 中的 docs 路由
|
|
31
31
|
|
|
32
|
-
var
|
|
32
|
+
var docsRoutes = navs.filter(function (nav) {
|
|
33
33
|
return nav.slug && nav.slug.startsWith('docs/');
|
|
34
|
-
})
|
|
35
|
-
var docsRoutes = hasDocsRoutes.map(function (nav) {
|
|
34
|
+
}).map(function (nav) {
|
|
36
35
|
return nav.slug && nav.slug.split('/').find(function (item) {
|
|
37
36
|
return item !== 'docs';
|
|
38
37
|
});
|
|
@@ -72,7 +72,7 @@ export var Index = function Index() {
|
|
|
72
72
|
title: "".concat(metaTitle[locale.id]),
|
|
73
73
|
titleSuffix: "AntV",
|
|
74
74
|
lang: locale.id
|
|
75
|
-
}), /*#__PURE__*/React.createElement(Header, null), /*#__PURE__*/React.createElement(Detail, detailProps), /*#__PURE__*/React.createElement(Features, featuresProps), /*#__PURE__*/React.createElement(Cases, casesProps), /*#__PURE__*/React.createElement(Companies, {
|
|
75
|
+
}), /*#__PURE__*/React.createElement(Header, null), detail && /*#__PURE__*/React.createElement(Detail, detailProps), features && /*#__PURE__*/React.createElement(Features, featuresProps), cases && /*#__PURE__*/React.createElement(Cases, casesProps), /*#__PURE__*/React.createElement(Companies, {
|
|
76
76
|
title: useT("感谢信赖"),
|
|
77
77
|
companies: companies
|
|
78
78
|
}), /*#__PURE__*/React.createElement(Footer, null));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ManualContent } from "../../slots/ManualContent";
|
|
3
3
|
import { Header } from "../../slots/Header";
|
|
4
|
+
import { Footer } from "../../slots/Footer";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Manual 路由下的入口
|
|
@@ -9,5 +10,7 @@ export var Manual = function Manual(_ref) {
|
|
|
9
10
|
var children = _ref.children;
|
|
10
11
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Header, {
|
|
11
12
|
isHomePage: false
|
|
12
|
-
}), /*#__PURE__*/React.createElement(ManualContent, null, " ", children, " ")
|
|
13
|
+
}), /*#__PURE__*/React.createElement(ManualContent, null, " ", children, " "), /*#__PURE__*/React.createElement(Footer, {
|
|
14
|
+
isDynamicFooter: true
|
|
15
|
+
}));
|
|
13
16
|
};
|
|
@@ -17,10 +17,13 @@ export var DemoCard = function DemoCard(props) {
|
|
|
17
17
|
var locale = useLocale();
|
|
18
18
|
|
|
19
19
|
var renderCardInternal = function renderCardInternal() {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
var img = demo.screenshot || 'https://gw.alipayobjects.com/os/s/prod/antv/assets/image/screenshot-placeholder-b8e70.png';
|
|
21
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
22
|
+
style: {
|
|
23
|
+
backgroundImage: "url(\"".concat(img, "\")"),
|
|
24
|
+
backgroundSize: 'cover'
|
|
25
|
+
}
|
|
26
|
+
}));
|
|
24
27
|
};
|
|
25
28
|
|
|
26
29
|
return /*#__PURE__*/React.createElement(Link, {
|
package/dist/plugin/index.js
CHANGED
|
@@ -34,6 +34,7 @@ var plugin_default = (api) => {
|
|
|
34
34
|
memo.resolve.codeBlockMode = "passive";
|
|
35
35
|
memo.exportStatic.extraRoutePaths = (0, import_examples.getExamplePaths)();
|
|
36
36
|
memo.mfsu = false;
|
|
37
|
+
memo.favicons = ["https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*7svFR6wkPMoAAAAAAAAAAAAADmJ7AQ/original"];
|
|
37
38
|
return memo;
|
|
38
39
|
});
|
|
39
40
|
const pages = [
|
|
@@ -76,7 +76,7 @@ export var Cases = function Cases(_ref) {
|
|
|
76
76
|
className: styles.appWrapper,
|
|
77
77
|
key: ic(app.title)
|
|
78
78
|
}, /*#__PURE__*/React.createElement("img", {
|
|
79
|
-
className: styles.appTeaser,
|
|
79
|
+
className: cx(styles.appTeaser, 'index-cases-image'),
|
|
80
80
|
src: app.image,
|
|
81
81
|
alt: ic(app.title)
|
|
82
82
|
}), /*#__PURE__*/React.createElement("div", {
|
|
@@ -43,6 +43,7 @@ export var CodeEditor = function CodeEditor(_ref) {
|
|
|
43
43
|
_ref$replaceId = _ref.replaceId,
|
|
44
44
|
replaceId = _ref$replaceId === void 0 ? 'container' : _ref$replaceId,
|
|
45
45
|
isFullscreen = _ref.isFullscreen,
|
|
46
|
+
exampleId = _ref.exampleId,
|
|
46
47
|
_ref$onReady = _ref.onReady,
|
|
47
48
|
onReady = _ref$onReady === void 0 ? noop : _ref$onReady,
|
|
48
49
|
_ref$onDestroy = _ref.onDestroy,
|
|
@@ -79,8 +80,9 @@ export var CodeEditor = function CodeEditor(_ref) {
|
|
|
79
80
|
var _useState7 = useState(EDITOR_TABS.JAVASCRIPT),
|
|
80
81
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
81
82
|
currentEditorTab = _useState8[0],
|
|
82
|
-
setCurrentEditorTab = _useState8[1];
|
|
83
|
+
setCurrentEditorTab = _useState8[1];
|
|
83
84
|
|
|
85
|
+
var containerId = "playgroundScriptContainer_".concat(exampleId); // 出发 auto resize
|
|
84
86
|
|
|
85
87
|
var dispatchResizeEvent = function dispatchResizeEvent() {
|
|
86
88
|
var e = new Event('resize');
|
|
@@ -129,7 +131,7 @@ export var CodeEditor = function CodeEditor(_ref) {
|
|
|
129
131
|
} // 2. 执行代码,try catch 在内部已经做了
|
|
130
132
|
|
|
131
133
|
|
|
132
|
-
execute(compiled,
|
|
134
|
+
execute(compiled, containerId, playground === null || playground === void 0 ? void 0 : playground.container, replaceId);
|
|
133
135
|
}, 300), []);
|
|
134
136
|
useEffect(function () {
|
|
135
137
|
setCode(source);
|
|
@@ -138,10 +140,14 @@ export var CodeEditor = function CodeEditor(_ref) {
|
|
|
138
140
|
executeCode(code);
|
|
139
141
|
}, [code]);
|
|
140
142
|
useEffect(function () {
|
|
141
|
-
var dom = document.getElementById('
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
var dom = document.getElementById('containerId');
|
|
144
|
+
|
|
145
|
+
if (dom) {
|
|
146
|
+
bind(dom, debounce(function () {
|
|
147
|
+
dispatchResizeEvent();
|
|
148
|
+
}, 100));
|
|
149
|
+
}
|
|
150
|
+
|
|
145
151
|
onReady();
|
|
146
152
|
|
|
147
153
|
if (playground !== null && playground !== void 0 && playground.playgroundDidMount) {
|
|
@@ -149,7 +155,7 @@ export var CodeEditor = function CodeEditor(_ref) {
|
|
|
149
155
|
}
|
|
150
156
|
|
|
151
157
|
return function () {
|
|
152
|
-
clear(dom);
|
|
158
|
+
dom && clear(dom);
|
|
153
159
|
onDestroy();
|
|
154
160
|
|
|
155
161
|
if (playground !== null && playground !== void 0 && playground.playgroundWillUnmount) {
|
|
@@ -137,7 +137,7 @@ export function execute(code, playgroundScriptContainer, container) {
|
|
|
137
137
|
var newCode = code.replace(/'container'|"container"/, "'".concat(replaceId, "'"));
|
|
138
138
|
script.innerHTML = "\n// Can only have one anonymous define call per script file\n// \u548C monaco loader \u52A0\u8F7D\u51B2\u7A81\nvar __runnerDefine = window['define'];\nwindow['define'] = null;\ntry {\n ".concat(newCode, "\n\n // \u6E05\u9664\u663E\u793A\u7684\u9519\u8BEF\n window.__reportErrorInPlayground && window.__reportErrorInPlayground(null);\n} catch(e) {\n window.__reportErrorInPlayground && window.__reportErrorInPlayground(e);\n} finally {\n window['define'] = __runnerDefine;\n}\n "); // 追加图表容器
|
|
139
139
|
|
|
140
|
-
node.innerHTML = container || "<div id=".concat(replaceId, " />"); // 运行 script
|
|
140
|
+
node.innerHTML = container || "<div id=".concat(replaceId, " class=\"playgroundCodeContainer\" />"); // 运行 script
|
|
141
141
|
|
|
142
142
|
node.appendChild(script);
|
|
143
143
|
}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { PageHeader,
|
|
3
|
-
import { EditOutlined } from '@ant-design/icons';
|
|
4
|
-
import { useT } from "../hooks";
|
|
5
|
-
import { getGithubSourceURL } from "../utils";
|
|
6
|
-
import styles from "./CodeHeader.module.less";
|
|
2
|
+
import { PageHeader, Space, Divider } from 'antd';
|
|
7
3
|
|
|
8
4
|
/**
|
|
9
5
|
* 组件的 header
|
|
@@ -14,15 +10,20 @@ export var CodeHeader = function CodeHeader(_ref) {
|
|
|
14
10
|
githubUrl = _ref.githubUrl;
|
|
15
11
|
return /*#__PURE__*/React.createElement(PageHeader, {
|
|
16
12
|
ghost: false,
|
|
17
|
-
title: title
|
|
18
|
-
subTitle
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
title: title // todo 编辑地址各种各样,需要有单独的配置,暂时关闭!
|
|
14
|
+
// subTitle={
|
|
15
|
+
// <Tooltip title={useT('在 GitHub 上编辑')}>
|
|
16
|
+
// <a
|
|
17
|
+
// href={getGithubSourceURL(githubUrl, relativePath, 'examples')}
|
|
18
|
+
// target="_blank"
|
|
19
|
+
// rel="noopener noreferrer"
|
|
20
|
+
// className={styles.editOnGtiHubButton}
|
|
21
|
+
// >
|
|
22
|
+
// <EditOutlined />
|
|
23
|
+
// </a>
|
|
24
|
+
// </Tooltip>
|
|
25
|
+
// }
|
|
26
|
+
,
|
|
26
27
|
extra: /*#__PURE__*/React.createElement(Space, {
|
|
27
28
|
split: /*#__PURE__*/React.createElement(Divider, {
|
|
28
29
|
type: "vertical"
|
|
@@ -9,16 +9,18 @@ import styles from "./index.module.less";
|
|
|
9
9
|
* 2. 错误预览
|
|
10
10
|
*/
|
|
11
11
|
export var CodePreview = function CodePreview(_ref) {
|
|
12
|
-
var
|
|
12
|
+
var isPlayground = _ref.isPlayground,
|
|
13
|
+
exampleId = _ref.exampleId,
|
|
14
|
+
header = _ref.header,
|
|
13
15
|
error = _ref.error;
|
|
14
16
|
return /*#__PURE__*/React.createElement("div", {
|
|
15
17
|
className: styles.preview
|
|
16
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
18
|
+
}, isPlayground ? null : /*#__PURE__*/React.createElement("div", {
|
|
17
19
|
className: styles.header
|
|
18
20
|
}, header), /*#__PURE__*/React.createElement("div", {
|
|
19
21
|
className: styles.content
|
|
20
22
|
}, /*#__PURE__*/React.createElement("div", {
|
|
21
|
-
id: "
|
|
23
|
+
id: "playgroundScriptContainer_".concat(exampleId),
|
|
22
24
|
className: styles.playgroundScriptContainer
|
|
23
25
|
}), error ? /*#__PURE__*/React.createElement(Result, {
|
|
24
26
|
className: styles.result,
|
|
@@ -3,13 +3,16 @@
|
|
|
3
3
|
height: 100%;
|
|
4
4
|
position: relative;
|
|
5
5
|
|
|
6
|
-
padding:
|
|
6
|
+
padding: 24px;
|
|
7
7
|
overflow: auto;
|
|
8
8
|
|
|
9
9
|
display: flex;
|
|
10
10
|
flex-direction: column;
|
|
11
11
|
|
|
12
12
|
.header {
|
|
13
|
+
:global(.ant-page-header) {
|
|
14
|
+
padding-left: 0;
|
|
15
|
+
}
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
.content {
|
|
@@ -17,11 +20,17 @@
|
|
|
17
20
|
flex: 1;
|
|
18
21
|
min-height: 0;
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
.playgroundScriptContainer, .playgroundCodeContainer {
|
|
21
24
|
position: relative;
|
|
22
25
|
width: 100%;
|
|
23
26
|
height: 100%;
|
|
24
27
|
|
|
28
|
+
:global(.playgroundCodeContainer) {
|
|
29
|
+
position: relative;
|
|
30
|
+
width: 100%;
|
|
31
|
+
height: 100%;
|
|
32
|
+
}
|
|
33
|
+
|
|
25
34
|
:global(#container) {
|
|
26
35
|
position: relative;
|
|
27
36
|
width: 100%;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ExampleTopic } from '../../types';
|
|
3
3
|
declare type CodeRunnerProps = {
|
|
4
|
+
isPlayground?: boolean;
|
|
4
5
|
topic: string;
|
|
5
6
|
example: string;
|
|
6
7
|
demo: string;
|
|
7
8
|
exampleTopics: ExampleTopic[];
|
|
8
9
|
size?: number;
|
|
10
|
+
replaceId?: string;
|
|
9
11
|
notFound?: React.Element;
|
|
10
12
|
};
|
|
11
13
|
/**
|
|
@@ -29,6 +29,8 @@ export var CodeRunner = function CodeRunner(_ref) {
|
|
|
29
29
|
example = _ref.example,
|
|
30
30
|
demo = _ref.demo,
|
|
31
31
|
size = _ref.size,
|
|
32
|
+
replaceId = _ref.replaceId,
|
|
33
|
+
isPlayground = _ref.isPlayground,
|
|
32
34
|
_ref$notFound = _ref.notFound,
|
|
33
35
|
notFound = _ref$notFound === void 0 ? /*#__PURE__*/React.createElement(NotFound, null) : _ref$notFound;
|
|
34
36
|
var demoInfo = getDemoInfo(exampleTopics, topic, example, demo); // 找不到,啥也别干了,404 页面
|
|
@@ -60,16 +62,25 @@ export var CodeRunner = function CodeRunner(_ref) {
|
|
|
60
62
|
relativePath: relativePath,
|
|
61
63
|
githubUrl: githubUrl
|
|
62
64
|
});
|
|
65
|
+
|
|
66
|
+
function getExampleId() {
|
|
67
|
+
return "".concat(topic, "_").concat(example, "_").concat(demo);
|
|
68
|
+
}
|
|
69
|
+
|
|
63
70
|
return /*#__PURE__*/React.createElement(SplitPane, {
|
|
64
71
|
split: "vertical",
|
|
65
72
|
defaultSize: "".concat((1 - size) * 100, "%"),
|
|
66
73
|
minSize: 100
|
|
67
74
|
}, /*#__PURE__*/React.createElement(CodePreview, {
|
|
75
|
+
exampleId: getExampleId(),
|
|
68
76
|
error: error,
|
|
69
|
-
header: header
|
|
77
|
+
header: header,
|
|
78
|
+
isPlayground: isPlayground
|
|
70
79
|
}), /*#__PURE__*/React.createElement(CodeEditor, {
|
|
80
|
+
exampleId: getExampleId(),
|
|
71
81
|
source: source,
|
|
72
82
|
relativePath: relativePath,
|
|
83
|
+
replaceId: replaceId,
|
|
73
84
|
onError: setError,
|
|
74
85
|
onFullscreen: setFullscreen,
|
|
75
86
|
onDestroy: noop,
|
|
@@ -2,7 +2,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
2
2
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import cx from 'classnames';
|
|
5
|
-
import { isEqual } from 'lodash-es';
|
|
5
|
+
import { isEqual, size } from 'lodash-es';
|
|
6
6
|
import { Link, useLocale } from 'dumi';
|
|
7
7
|
import { Dropdown, Menu } from 'antd';
|
|
8
8
|
import { DownOutlined, LinkOutlined } from '@ant-design/icons';
|
|
@@ -32,22 +32,22 @@ export var Navs = function Navs(_ref) {
|
|
|
32
32
|
className = cx('header-menu-item-active', _defineProperty({}, styles.activeItem, path.startsWith(href) || isEqual(path.split('/').slice(0, 4), href.split('/').slice(0, 4))));
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
return nav.
|
|
35
|
+
return size(nav.dropdownItems) ? /*#__PURE__*/React.createElement("li", {
|
|
36
36
|
key: title,
|
|
37
37
|
className: className
|
|
38
38
|
}, /*#__PURE__*/React.createElement(Dropdown, {
|
|
39
39
|
className: styles.ecoSystems,
|
|
40
40
|
placement: "bottom",
|
|
41
41
|
overlay: /*#__PURE__*/React.createElement(Menu, null, nav.dropdownItems.map(function (_ref2) {
|
|
42
|
-
var
|
|
43
|
-
|
|
42
|
+
var name = _ref2.name,
|
|
43
|
+
url = _ref2.url;
|
|
44
44
|
return /*#__PURE__*/React.createElement(Menu.Item, {
|
|
45
|
-
key:
|
|
45
|
+
key: url
|
|
46
46
|
}, /*#__PURE__*/React.createElement("a", {
|
|
47
47
|
target: "_blank",
|
|
48
48
|
rel: "noreferrer",
|
|
49
|
-
href:
|
|
50
|
-
},
|
|
49
|
+
href: url
|
|
50
|
+
}, name[locale.id], " ", /*#__PURE__*/React.createElement(LinkOutlined, null)));
|
|
51
51
|
}))
|
|
52
52
|
}, /*#__PURE__*/React.createElement("span", null, title, /*#__PURE__*/React.createElement(DownOutlined, null)))) : /*#__PURE__*/React.createElement("li", {
|
|
53
53
|
key: title,
|
|
@@ -27,11 +27,10 @@ import { useNavigate } from "react-router-dom";
|
|
|
27
27
|
import { EditOutlined, MenuFoldOutlined, MenuUnfoldOutlined, VerticalAlignTopOutlined } from '@ant-design/icons';
|
|
28
28
|
import readingTime from 'reading-time';
|
|
29
29
|
import { SEO } from "../SEO";
|
|
30
|
-
import { getBaseRoute, getIndexRoute, getOpenKeys } from "./utils";
|
|
30
|
+
import { getBaseRoute, getIndexRoute, getOpenKeys, getNavigateUrl } from "./utils";
|
|
31
31
|
import { NavigatorBanner } from "./NavigatorBanner";
|
|
32
32
|
import ReadingTime from "./ReadingTime";
|
|
33
33
|
import { TOC } from "../TOC";
|
|
34
|
-
import { Footer } from "../Footer";
|
|
35
34
|
import { useScrollToTop } from "../hooks";
|
|
36
35
|
import 'rc-drawer/assets/index.css';
|
|
37
36
|
import styles from "./index.module.less";
|
|
@@ -115,13 +114,17 @@ export var ManualContent = function ManualContent(_ref) {
|
|
|
115
114
|
var item = _step.value;
|
|
116
115
|
item.children = [];
|
|
117
116
|
fullSidebarDataToMenuData(rootList, item.key, item.children);
|
|
118
|
-
(_funllSidebarData$ite = funllSidebarData[item.key][0].children) === null || _funllSidebarData$ite === void 0 ? void 0 : _funllSidebarData$ite.forEach(function (itemChild) {
|
|
117
|
+
funllSidebarData[item.key] && ((_funllSidebarData$ite = funllSidebarData[item.key][0].children) === null || _funllSidebarData$ite === void 0 ? void 0 : _funllSidebarData$ite.forEach(function (itemChild) {
|
|
119
118
|
var label = itemChild.title;
|
|
120
119
|
var key = itemChild.link;
|
|
121
120
|
item.children.push(_objectSpread(_objectSpread({}, itemChild), {}, {
|
|
122
121
|
label: label,
|
|
123
122
|
key: key
|
|
124
123
|
}));
|
|
124
|
+
})); // children 的 order 排序
|
|
125
|
+
|
|
126
|
+
item.children.sort(function (a, b) {
|
|
127
|
+
return a.order - b.order;
|
|
125
128
|
});
|
|
126
129
|
|
|
127
130
|
if (item.children.length == 0) {
|
|
@@ -175,7 +178,7 @@ export var ManualContent = function ManualContent(_ref) {
|
|
|
175
178
|
useScrollToTop();
|
|
176
179
|
};
|
|
177
180
|
|
|
178
|
-
var _useState5 = useState(
|
|
181
|
+
var _useState5 = useState(),
|
|
179
182
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
180
183
|
defaultSelectedKey = _useState6[0],
|
|
181
184
|
setDefaultSelectedKey = _useState6[1]; //上一夜下一页
|
|
@@ -197,11 +200,12 @@ export var ManualContent = function ManualContent(_ref) {
|
|
|
197
200
|
for (var _i3 = 0, _Object$keys = Object.keys(linkoTitle); _i3 < _Object$keys.length; _i3++) {
|
|
198
201
|
var route = _Object$keys[_i3];
|
|
199
202
|
sidebarRoutes.push(route);
|
|
200
|
-
}
|
|
203
|
+
}
|
|
201
204
|
|
|
205
|
+
var url = getNavigateUrl(window.location.pathname, indexRoute, sidebarRoutes);
|
|
202
206
|
|
|
203
|
-
if (
|
|
204
|
-
navigate(
|
|
207
|
+
if (url !== window.location.pathname) {
|
|
208
|
+
navigate(url);
|
|
205
209
|
} // 改变菜单栏选中和 openKeys 状态
|
|
206
210
|
|
|
207
211
|
|
|
@@ -333,9 +337,7 @@ export var ManualContent = function ManualContent(_ref) {
|
|
|
333
337
|
}
|
|
334
338
|
}, /*#__PURE__*/React.createElement("div", {
|
|
335
339
|
className: styles.backTop
|
|
336
|
-
}, /*#__PURE__*/React.createElement(VerticalAlignTopOutlined, null)))))), /*#__PURE__*/React.createElement(
|
|
337
|
-
className: styles.footer
|
|
338
|
-
})), is991Wide ? /*#__PURE__*/React.createElement(Layout.Sider, {
|
|
340
|
+
}, /*#__PURE__*/React.createElement(VerticalAlignTopOutlined, null))))))), is991Wide ? /*#__PURE__*/React.createElement(Layout.Sider, {
|
|
339
341
|
theme: "light",
|
|
340
342
|
width: 260
|
|
341
343
|
}, /*#__PURE__*/React.createElement(Affix, {
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
.markdown {
|
|
8
8
|
font-size: 14px;
|
|
9
9
|
line-height: 2;
|
|
10
|
+
min-height: 600px; // 大概一屏幕占位,防止切换文档的时候,有黑影!
|
|
10
11
|
|
|
11
12
|
h1 {
|
|
12
13
|
margin-bottom: 20px;
|
|
@@ -207,7 +208,6 @@
|
|
|
207
208
|
padding-left: 48px;
|
|
208
209
|
padding-right: 24px;
|
|
209
210
|
overflow: hidden;
|
|
210
|
-
min-height: 760px; // 大概一屏幕占位,防止切换文档的时候,有黑影!
|
|
211
211
|
|
|
212
212
|
.meta {
|
|
213
213
|
margin-bottom: 1.2em;
|
|
@@ -250,7 +250,7 @@
|
|
|
250
250
|
ul>li {
|
|
251
251
|
list-style: none !important;
|
|
252
252
|
padding: 0 !important;
|
|
253
|
-
margin-left:
|
|
253
|
+
margin-left: -1px !important;
|
|
254
254
|
|
|
255
255
|
// 超出部分省略号显示
|
|
256
256
|
text-overflow: ellipsis;
|
|
@@ -262,7 +262,7 @@
|
|
|
262
262
|
}
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
|
-
.contentTitle{
|
|
265
|
+
.contentTitle {
|
|
266
266
|
margin-top: 8px;
|
|
267
267
|
margin-bottom: 20px;
|
|
268
268
|
font-weight: 500;
|
|
@@ -617,10 +617,6 @@
|
|
|
617
617
|
justify-content: center;
|
|
618
618
|
}
|
|
619
619
|
|
|
620
|
-
.footer {
|
|
621
|
-
width: 100%;
|
|
622
|
-
}
|
|
623
|
-
|
|
624
620
|
.menuSwitch {
|
|
625
621
|
position: absolute;
|
|
626
622
|
top: 72px;
|
|
@@ -640,11 +636,10 @@
|
|
|
640
636
|
border-radius: 0 4px 4px 0;
|
|
641
637
|
}
|
|
642
638
|
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
.readtimeContainer{
|
|
639
|
+
.readtimeContainer {
|
|
646
640
|
margin-bottom: 1.2em;
|
|
647
641
|
}
|
|
642
|
+
|
|
648
643
|
.readtime {
|
|
649
644
|
color: #0d1a26;
|
|
650
645
|
line-height: 1.5715;
|
|
@@ -1,3 +1,18 @@
|
|
|
1
1
|
export declare function getOpenKeys(): any[];
|
|
2
2
|
export declare function getBaseRoute(): string;
|
|
3
3
|
export declare function getIndexRoute(MenuData: any): any;
|
|
4
|
+
/**
|
|
5
|
+
* 返回需要跳转的 pathname
|
|
6
|
+
* /en/api/ ----> /en/api/[first-doc]
|
|
7
|
+
* /zh/api/ ----> /api/[first-doc]
|
|
8
|
+
* /en/docs/api/ ----> /en/api/[first-doc]
|
|
9
|
+
* /zh/docs/api/ ----> /api/[first-doc]
|
|
10
|
+
*
|
|
11
|
+
* /en/docs/api/xxx ----> /en/api/xxx
|
|
12
|
+
* /zh/docs/api/xxx ----> /api/xxx
|
|
13
|
+
*
|
|
14
|
+
* /docs/api/xxx -----> /api/xxx
|
|
15
|
+
*
|
|
16
|
+
* @param p
|
|
17
|
+
*/
|
|
18
|
+
export declare function getNavigateUrl(pathname: string, first: string, siderbarMenu: any[]): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export function getOpenKeys() {
|
|
2
|
-
var pathname = window.location.pathname;
|
|
2
|
+
var pathname = window.location.pathname.replace('/docs/', '/').replace('/zh/', '/');
|
|
3
3
|
var pathArr = pathname.split('/');
|
|
4
4
|
var openKeys = [];
|
|
5
5
|
|
|
@@ -32,4 +32,33 @@ export function getIndexRoute(MenuData) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
return defaultOpenKeys[defaultOpenKeys.length - 1];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 返回需要跳转的 pathname
|
|
38
|
+
* /en/api/ ----> /en/api/[first-doc]
|
|
39
|
+
* /zh/api/ ----> /api/[first-doc]
|
|
40
|
+
* /en/docs/api/ ----> /en/api/[first-doc]
|
|
41
|
+
* /zh/docs/api/ ----> /api/[first-doc]
|
|
42
|
+
*
|
|
43
|
+
* /en/docs/api/xxx ----> /en/api/xxx
|
|
44
|
+
* /zh/docs/api/xxx ----> /api/xxx
|
|
45
|
+
*
|
|
46
|
+
* /docs/api/xxx -----> /api/xxx
|
|
47
|
+
*
|
|
48
|
+
* @param p
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
export function getNavigateUrl(pathname, first, siderbarMenu) {
|
|
52
|
+
// 兜底 如果 nav 指定有误则自动重定向到 indexDocRoute
|
|
53
|
+
if (pathname.includes('/docs/') || pathname.includes('/zh/')) {
|
|
54
|
+
return pathname.replace('/docs/', '/').replace('/zh/', '/');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!siderbarMenu.some(function (item) {
|
|
58
|
+
return item === pathname;
|
|
59
|
+
})) {
|
|
60
|
+
return first;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return pathname;
|
|
35
64
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/dumi-theme-antv",
|
|
3
|
-
"version": "0.3.0-beta.
|
|
3
|
+
"version": "0.3.0-beta.11",
|
|
4
4
|
"description": "AntV website theme based on dumi2.",
|
|
5
5
|
"types": "dist/types.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
"react-dom": "^18.2.0",
|
|
78
78
|
"react-error-boundary": "^3.1.4",
|
|
79
79
|
"react-github-button": "^0.1.11",
|
|
80
|
+
"react-helmet": "^6.1.0",
|
|
80
81
|
"react-router-dom": "^6.4.2",
|
|
81
82
|
"react-slick": "^0.29.0",
|
|
82
83
|
"react-split-pane": "^0.1.92",
|