@antv/dumi-theme-antv 0.3.0-beta.8 → 0.3.0

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.
Files changed (72) hide show
  1. package/dist/builtins/Playground/index.d.ts +3 -6
  2. package/dist/builtins/Playground/index.js +27 -7
  3. package/dist/layouts/DocLayout.js +4 -5
  4. package/dist/layouts/entry/Index.js +21 -12
  5. package/dist/layouts/entry/Manual.js +6 -4
  6. package/dist/pages/404.js +7 -4
  7. package/dist/pages/Example/index.js +15 -4
  8. package/dist/pages/Example/utils.d.ts +1 -0
  9. package/dist/pages/Example/utils.js +9 -0
  10. package/dist/pages/Examples/components/ExampleTopicMenu/components/LeftMenu/index.js +2 -1
  11. package/dist/pages/Examples/components/GalleryPageContent/DemoCard/index.js +10 -5
  12. package/dist/pages/Examples/components/GalleryPageContent/index.js +2 -1
  13. package/dist/pages/Examples/index.js +13 -4
  14. package/dist/pages/Examples/index.module.less +13 -0
  15. package/dist/pages/Examples/utils.d.ts +1 -0
  16. package/dist/pages/Examples/utils.js +3 -0
  17. package/dist/plugin/index.js +11 -0
  18. package/dist/slots/Article/index.d.ts +3 -0
  19. package/dist/slots/Article/index.js +11 -0
  20. package/dist/slots/Article/index.module.less +8 -0
  21. package/dist/slots/Banner/Notification.d.ts +10 -0
  22. package/dist/slots/Banner/Notification.js +43 -0
  23. package/dist/slots/Banner/Notification.module.less +120 -0
  24. package/dist/slots/Banner/index.d.ts +26 -0
  25. package/dist/slots/Banner/index.js +184 -0
  26. package/dist/slots/Banner/index.module.less +449 -0
  27. package/dist/slots/Cases/index.d.ts +1 -1
  28. package/dist/slots/Cases/index.js +13 -7
  29. package/dist/slots/Cases/index.module.less +2 -1
  30. package/dist/slots/CodeEditor/Toolbar.js +13 -6
  31. package/dist/slots/CodeEditor/index.d.ts +4 -0
  32. package/dist/slots/CodeEditor/index.js +43 -21
  33. package/dist/slots/CodeEditor/utils.js +1 -1
  34. package/dist/slots/CodePreview/CodeHeader.js +15 -14
  35. package/dist/slots/CodePreview/index.d.ts +8 -0
  36. package/dist/slots/CodePreview/index.js +15 -6
  37. package/dist/slots/CodePreview/index.module.less +11 -2
  38. package/dist/slots/CodeRunner/index.d.ts +2 -0
  39. package/dist/slots/CodeRunner/index.js +13 -5
  40. package/dist/slots/Companies/index.d.ts +1 -1
  41. package/dist/slots/{TOC.d.ts → ContentTable/index.d.ts} +2 -1
  42. package/dist/slots/{TOC.js → ContentTable/index.js} +2 -1
  43. package/dist/slots/ContentTable/index.module.less +11 -0
  44. package/dist/slots/Detail/News.js +3 -2
  45. package/dist/slots/Detail/index.js +3 -1
  46. package/dist/slots/ExampleSider/index.js +21 -20
  47. package/dist/slots/Features/index.js +5 -2
  48. package/dist/slots/Features/index.module.less +3 -3
  49. package/dist/slots/Footer/index.js +34 -14
  50. package/dist/slots/Header/LogoWhite.js +1 -2
  51. package/dist/slots/Header/Navs.d.ts +10 -1
  52. package/dist/slots/Header/Navs.js +36 -25
  53. package/dist/slots/Header/Products/NavigatorBanner.js +4 -3
  54. package/dist/slots/Header/Products/Product.js +7 -3
  55. package/dist/slots/Header/Products/getProducts.js +4 -2
  56. package/dist/slots/Header/Products/index.js +5 -3
  57. package/dist/slots/Header/Search.js +5 -3
  58. package/dist/slots/Header/index.d.ts +7 -2
  59. package/dist/slots/Header/index.js +128 -24
  60. package/dist/slots/ManualContent/NavigatorBanner.js +5 -3
  61. package/dist/slots/ManualContent/ReadingTime.js +6 -2
  62. package/dist/slots/ManualContent/index.js +36 -30
  63. package/dist/slots/ManualContent/index.module.less +52 -33
  64. package/dist/slots/ManualContent/utils.d.ts +15 -0
  65. package/dist/slots/ManualContent/utils.js +30 -1
  66. package/dist/slots/SEO.d.ts +10 -0
  67. package/dist/slots/SEO.js +59 -0
  68. package/dist/slots/_.less +1 -1
  69. package/dist/slots/hooks.d.ts +1 -1
  70. package/dist/slots/hooks.js +5 -8
  71. package/dist/slots/utils.js +6 -1
  72. package/package.json +5 -2
@@ -21,22 +21,27 @@ import React, { useState, useEffect } from 'react';
21
21
  import { useMedia } from 'react-use';
22
22
  import { useNavigate } from "react-router-dom";
23
23
  import cx from 'classnames';
24
- import { useSiteData, useLocale } from 'dumi';
24
+ import { useSiteData, useLocale, FormattedMessage } from 'dumi';
25
25
  import { GithubOutlined, MenuOutlined, CaretDownFilled, DownOutlined, WechatOutlined, LinkOutlined, CheckOutlined } from '@ant-design/icons';
26
- import { Popover, Menu, Dropdown, Select } from 'antd';
27
- import { map, size } from 'lodash-es';
26
+ import { Modal, Button, Popover, Menu, Dropdown, Select } from 'antd';
27
+ import { get, map, size } from 'lodash-es';
28
28
  import { Search } from "./Search";
29
29
  import { Products } from "./Products";
30
30
  import { Navs } from "./Navs";
31
31
  import { Logo } from "./Logo";
32
32
  import { LogoWhite } from "./LogoWhite";
33
33
  import { getLangUrl } from "./utils";
34
- import { useT } from "../hooks";
34
+ import { ic } from "../hooks";
35
35
  import styles from "./index.module.less";
36
36
 
37
+ function redirectChinaMirror(chinaMirrorOrigin) {
38
+ window.location.href = window.location.href.replace(window.location.origin, chinaMirrorOrigin);
39
+ }
37
40
  /**
38
41
  * 头部菜单
39
42
  */
43
+
44
+
40
45
  var HeaderComponent = function HeaderComponent(_ref) {
41
46
  var _cx, _cx4;
42
47
 
@@ -57,8 +62,6 @@ var HeaderComponent = function HeaderComponent(_ref) {
57
62
  showAntVProductsCard = _ref$showAntVProducts === void 0 ? true : _ref$showAntVProducts,
58
63
  _ref$showLanguageSwit = _ref.showLanguageSwitcher,
59
64
  showLanguageSwitcher = _ref$showLanguageSwit === void 0 ? true : _ref$showLanguageSwit,
60
- _ref$showChinaMirror = _ref.showChinaMirror,
61
- showChinaMirror = _ref$showChinaMirror === void 0 ? true : _ref$showChinaMirror,
62
65
  logo = _ref.logo,
63
66
  onLanguageChange = _ref.onLanguageChange,
64
67
  _ref$showWxQrcode = _ref.showWxQrcode,
@@ -76,22 +79,41 @@ var HeaderComponent = function HeaderComponent(_ref) {
76
79
  _ref$rootDomain = _ref.rootDomain,
77
80
  rootDomain = _ref$rootDomain === void 0 ? '' : _ref$rootDomain,
78
81
  versions = _ref.versions,
82
+ internalSite = _ref.internalSite,
79
83
  ecosystems = _ref.ecosystems,
80
84
  searchOptions = _ref.searchOptions;
81
85
  var isAntVHome = isAntVSite && isHomePage; // 是否为AntV官网首页
82
86
 
83
- var locale = useLocale();
84
- var nav = useNavigate();
87
+ var showChinaMirror = !!internalSite;
88
+ var chinaMirrorUrl = get(internalSite, 'url');
85
89
 
86
- var _useState = useState(locale.id),
90
+ var _useState = useState(false),
87
91
  _useState2 = _slicedToArray(_useState, 2),
88
- lang = _useState2[0],
89
- setLang = _useState2[1];
92
+ chinaMirrorHintVisible = _useState2[0],
93
+ updateChinaMirrorHintVisible = _useState2[1];
90
94
 
91
- var _useState3 = useState(false),
95
+ useEffect(function () {
96
+ var timeout = setTimeout(function () {
97
+ if (showChinaMirror && lang === 'zh' && !localStorage.getItem('china-mirror-no-more-hint') && window.location.host.includes('antv.vision')) {
98
+ updateChinaMirrorHintVisible(true);
99
+ }
100
+ }, 5000);
101
+ return function () {
102
+ clearTimeout(timeout);
103
+ };
104
+ });
105
+ var locale = useLocale();
106
+ var nav = useNavigate();
107
+
108
+ var _useState3 = useState(locale.id),
92
109
  _useState4 = _slicedToArray(_useState3, 2),
93
- productMenuVisible = _useState4[0],
94
- setProductMenuVisible = _useState4[1];
110
+ lang = _useState4[0],
111
+ setLang = _useState4[1];
112
+
113
+ var _useState5 = useState(false),
114
+ _useState6 = _slicedToArray(_useState5, 2),
115
+ productMenuVisible = _useState6[0],
116
+ setProductMenuVisible = _useState6[1];
95
117
 
96
118
  var productMenuHovering = false;
97
119
 
@@ -121,10 +143,10 @@ var HeaderComponent = function HeaderComponent(_ref) {
121
143
  setProductMenuVisible(!productMenuVisible);
122
144
  };
123
145
 
124
- var _useState5 = useState(false),
125
- _useState6 = _slicedToArray(_useState5, 2),
126
- popupMenuVisible = _useState6[0],
127
- setPopupMenuVisible = _useState6[1];
146
+ var _useState7 = useState(false),
147
+ _useState8 = _slicedToArray(_useState7, 2),
148
+ popupMenuVisible = _useState8[0],
149
+ setPopupMenuVisible = _useState8[1];
128
150
 
129
151
  var onTogglePopupMenuVisible = function onTogglePopupMenuVisible() {
130
152
  setPopupMenuVisible(!popupMenuVisible);
@@ -191,13 +213,89 @@ var HeaderComponent = function HeaderComponent(_ref) {
191
213
  href: url
192
214
  }, ecosystemName === null || ecosystemName === void 0 ? void 0 : ecosystemName[lang], " ", /*#__PURE__*/React.createElement(LinkOutlined, null)));
193
215
  }))
194
- }, /*#__PURE__*/React.createElement("span", null, useT('周边生态'), /*#__PURE__*/React.createElement(DownOutlined, {
216
+ }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(FormattedMessage, {
217
+ id: "\u5468\u8FB9\u751F\u6001"
218
+ }), /*#__PURE__*/React.createElement(DownOutlined, {
195
219
  style: {
196
220
  marginLeft: '6px'
197
221
  }
198
- })))) : null,
222
+ })))) : null, showChinaMirror && isWide ? /*#__PURE__*/React.createElement(Popover, {
223
+ title: null,
224
+ content: /*#__PURE__*/React.createElement("div", {
225
+ style: {
226
+ width: 300
227
+ }
228
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", {
229
+ role: "img",
230
+ "aria-labelledby": "\u4E2D\u56FD",
231
+ style: {
232
+ marginRight: '8px'
233
+ }
234
+ }, "\uD83C\uDDE8\uD83C\uDDF3"), "AntV \u7CFB\u5217\u7F51\u7AD9\u90E8\u7F72\u5728 gh-pages \u4E0A\uFF0C\u82E5\u8BBF\u95EE\u901F\u5EA6\u4E0D\u4F73\uFF0C\u53EF\u4EE5\u524D\u5F80\u56FD\u5185\u955C\u50CF\u7AD9\u70B9\u3002"), /*#__PURE__*/React.createElement("div", {
235
+ style: {
236
+ marginTop: 16,
237
+ textAlign: 'right'
238
+ }
239
+ }, /*#__PURE__*/React.createElement(Button, {
240
+ onClick: function onClick() {
241
+ return updateChinaMirrorHintVisible(false);
242
+ },
243
+ size: "small",
244
+ style: {
245
+ marginRight: 8
246
+ }
247
+ }, "\u6682\u65F6\u5173\u95ED"), /*#__PURE__*/React.createElement(Button, {
248
+ type: "primary",
249
+ size: "small",
250
+ onClick: function onClick() {
251
+ localStorage.setItem('china-mirror-no-more-hint', Date.now().toString());
252
+ updateChinaMirrorHintVisible(false);
253
+ }
254
+ }, "\u4E0D\u518D\u63D0\u9192"))),
255
+ visible: chinaMirrorHintVisible,
256
+ placement: "bottomRight",
257
+ align: {
258
+ offset: [-12, -16]
259
+ }
260
+ }, /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("a", {
261
+ href: chinaMirrorUrl,
262
+ onClick: function onClick(e) {
263
+ e.preventDefault();
264
+ redirectChinaMirror(chinaMirrorUrl);
265
+ }
266
+ }, ic(get(internalSite, 'name')), !isAntVHome && /*#__PURE__*/React.createElement(LinkOutlined, null)))) : null, showChinaMirror && !isWide && /*#__PURE__*/React.createElement(Modal, {
267
+ visible: chinaMirrorHintVisible,
268
+ cancelText: "\u4E0D\u518D\u63D0\u9192",
269
+ okText: "\u7ACB\u5373\u524D\u5F80",
270
+ onCancel: function onCancel() {
271
+ updateChinaMirrorHintVisible(false);
272
+ },
273
+ onOk: function onOk() {
274
+ return redirectChinaMirror(chinaMirrorUrl);
275
+ },
276
+ cancelButtonProps: {
277
+ onClick: function onClick() {
278
+ localStorage.setItem('china-mirror-no-more-hint', Date.now().toString());
279
+ updateChinaMirrorHintVisible(false);
280
+ }
281
+ }
282
+ }, /*#__PURE__*/React.createElement("div", {
283
+ className: styles.modalContent
284
+ }, /*#__PURE__*/React.createElement("span", {
285
+ role: "img",
286
+ "aria-labelledby": "\u4E2D\u56FD"
287
+ }, "\uD83C\uDDE8\uD83C\uDDF3"), "AntV \u7CFB\u5217\u7F51\u7AD9\u90E8\u7F72\u5728 gh-pages \u4E0A\uFF0C\u82E5\u8BBF\u95EE\u901F\u5EA6\u4E0D\u4F73\uFF0C\u53EF\u4EE5\u524D\u5F80", /*#__PURE__*/React.createElement("a", {
288
+ href: chinaMirrorUrl,
289
+ onClick: function onClick(e) {
290
+ e.preventDefault();
291
+ window.location.href = chinaMirrorUrl;
292
+ },
293
+ className: styles.remindHref
294
+ }, ic(get(internalSite, 'name')), /*#__PURE__*/React.createElement(LinkOutlined, null)), /*#__PURE__*/React.createElement("span", null, " \u7AD9\u70B9\u3002"))),
199
295
  /** 产品列表 */
200
- showAntVProductsCard && /*#__PURE__*/React.createElement("li", productItemProps, /*#__PURE__*/React.createElement("a", null, useT('所有产品'), !isAntVHome ? /*#__PURE__*/React.createElement("img", {
296
+ showAntVProductsCard && /*#__PURE__*/React.createElement("li", productItemProps, /*#__PURE__*/React.createElement("a", null, /*#__PURE__*/React.createElement(FormattedMessage, {
297
+ id: "\u6240\u6709\u4EA7\u54C1"
298
+ }), !isAntVHome ? /*#__PURE__*/React.createElement("img", {
201
299
  src: "https://gw.alipayobjects.com/zos/antfincdn/FLrTNDvlna/antv.png",
202
300
  alt: "antv logo arrow",
203
301
  className: cx(styles.arrow, _defineProperty({}, styles.open, productMenuVisible))
@@ -322,8 +420,8 @@ var HeaderComponent = function HeaderComponent(_ref) {
322
420
  }, /*#__PURE__*/React.createElement("div", {
323
421
  className: styles.left
324
422
  }, /*#__PURE__*/React.createElement("h1", null, /*#__PURE__*/React.createElement("a", {
325
- href: siteUrl
326
- }, img)), subTitle && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
423
+ href: siteUrl[lang] ? siteUrl[lang] : siteUrl
424
+ }, img)), !isAntVHome && subTitle && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
327
425
  className: styles.divider
328
426
  }), /*#__PURE__*/React.createElement("h2", {
329
427
  className: styles.subProduceName
@@ -343,6 +441,7 @@ export var Header = function Header(props) {
343
441
  githubUrl = themeConfig.githubUrl,
344
442
  isAntVSite = themeConfig.isAntVSite,
345
443
  subTitleHref = themeConfig.subTitleHref,
444
+ internalSite = themeConfig.internalSite,
346
445
  showSearch = themeConfig.showSearch,
347
446
  showGithubCorner = themeConfig.showGithubCorner,
348
447
  showGithubStars = themeConfig.showGithubStars,
@@ -357,12 +456,16 @@ export var Header = function Header(props) {
357
456
  var searchOptions = {
358
457
  docsearchOptions: docsearchOptions
359
458
  };
459
+ var locale = useLocale();
460
+ var path = window.location.pathname;
461
+ var isHomePage = path === '/' || path === "/".concat(locale.id) || path === "/".concat(locale.id, "/");
360
462
  var headerProps = {
361
463
  subTitle: title,
362
464
  subTitleHref: subTitleHref,
363
465
  githubUrl: githubUrl,
364
466
  isAntVSite: isAntVSite,
365
467
  siteUrl: siteUrl,
468
+ internalSite: internalSite,
366
469
  showSearch: showSearch,
367
470
  showGithubCorner: showGithubCorner,
368
471
  showGithubStars: showGithubStars,
@@ -374,7 +477,8 @@ export var Header = function Header(props) {
374
477
  ecosystems: ecosystems,
375
478
  navs: navs,
376
479
  searchOptions: searchOptions,
377
- isHomePage: true
480
+ isHomePage: isHomePage,
481
+ transparent: isHomePage && isAntVSite
378
482
  };
379
483
  return /*#__PURE__*/React.createElement(HeaderComponent, Object.assign({}, headerProps, props));
380
484
  };
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import classNames from 'classnames';
3
- import { history } from 'dumi';
3
+ import { history, FormattedMessage } from 'dumi';
4
4
  import styles from "./NavigatorBanner.module.less";
5
- import { useScrollToTop, useT } from "../hooks";
5
+ import { useScrollToTop } from "../hooks";
6
6
  export var NavigatorBanner = function NavigatorBanner(_ref) {
7
7
  var post = _ref.post,
8
8
  type = _ref.type;
@@ -30,7 +30,9 @@ export var NavigatorBanner = function NavigatorBanner(_ref) {
30
30
  onClick: go
31
31
  }, /*#__PURE__*/React.createElement("div", {
32
32
  className: styles.label
33
- }, useT(type === 'prev' ? '上一篇' : '下一篇')), /*#__PURE__*/React.createElement("div", {
33
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
34
+ id: type === 'prev' ? '上一篇' : '下一篇'
35
+ })), /*#__PURE__*/React.createElement("div", {
34
36
  className: styles.title
35
37
  }, title));
36
38
  };
@@ -1,10 +1,14 @@
1
1
  import React from 'react';
2
2
  import { Tag } from 'antd';
3
- import { useT } from "../hooks";
3
+ import { FormattedMessage } from 'dumi';
4
4
 
5
5
  var ReadingTime = function ReadingTime(_ref) {
6
6
  var readingTime = _ref.readingTime;
7
- return /*#__PURE__*/React.createElement(Tag, null, "".concat(useT('阅读时间约'), " ").concat(Math.ceil(readingTime / 60000), " ").concat(useT('分钟')));
7
+ return /*#__PURE__*/React.createElement(Tag, null, /*#__PURE__*/React.createElement(FormattedMessage, {
8
+ id: "\u9605\u8BFB\u65F6\u95F4\u7EA6"
9
+ }), " ", Math.ceil(readingTime / 60000), " ", /*#__PURE__*/React.createElement(FormattedMessage, {
10
+ id: "\u5206\u949F"
11
+ }));
8
12
  };
9
13
 
10
14
  export default ReadingTime;
@@ -19,17 +19,19 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
19
19
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
20
 
21
21
  import React, { useEffect, useState } from 'react';
22
- import { Layout, Affix, BackTop, Menu, Tooltip } from 'antd';
22
+ import { Layout, Affix, BackTop, Menu } from 'antd';
23
23
  import { useMedia } from 'react-use';
24
24
  import Drawer from 'rc-drawer';
25
25
  import { useLocale, useSiteData, useFullSidebarData, useRouteMeta } from 'dumi';
26
26
  import { useNavigate } from "react-router-dom";
27
- import { EditOutlined, MenuFoldOutlined, MenuUnfoldOutlined, VerticalAlignTopOutlined } from '@ant-design/icons';
27
+ import { MenuFoldOutlined, MenuUnfoldOutlined, VerticalAlignTopOutlined } from '@ant-design/icons';
28
28
  import readingTime from 'reading-time';
29
- import { getBaseRoute, getIndexRoute, getOpenKeys } from "./utils";
29
+ import URI from 'uri-parse';
30
+ import { SEO } from "dumi/theme/slots/SEO";
31
+ import { getBaseRoute, getIndexRoute, getOpenKeys, getNavigateUrl } from "./utils";
30
32
  import { NavigatorBanner } from "./NavigatorBanner";
31
33
  import ReadingTime from "./ReadingTime";
32
- import { TOC } from "../TOC";
34
+ import { ContentTable } from "dumi/theme/slots/ContentTable";
33
35
  import { useScrollToTop } from "../hooks";
34
36
  import 'rc-drawer/assets/index.css';
35
37
  import styles from "./index.module.less";
@@ -49,7 +51,8 @@ export var ManualContent = function ManualContent(_ref) {
49
51
  docs = _useSiteData$themeCon.docs;
50
52
 
51
53
  var sidebar = useFullSidebarData();
52
- var isWide = useMedia('(min-width: 767.99px)', true);
54
+ var is767Wide = useMedia('(min-width: 767.99px)', true);
55
+ var is991Wide = useMedia('(min-width: 991.99px)', true);
53
56
 
54
57
  var _useState = useState(false),
55
58
  _useState2 = _slicedToArray(_useState, 2),
@@ -89,7 +92,7 @@ export var ManualContent = function ManualContent(_ref) {
89
92
  function fullSidebarDataToMenuData(rootList, hrefId, list) {
90
93
  // 递归
91
94
  rootList.forEach(function (item) {
92
- var href = !baseRoute.startsWith('/en') ? "/".concat(item.slug) : "/en/".concat(item.slug);
95
+ var href = (!baseRoute.startsWith('/en') ? "/".concat(item.slug) : "/en/".concat(item.slug)).toLocaleLowerCase();
93
96
  var id = href.split("/").slice(0, href.split("/").length - 1).join("/");
94
97
 
95
98
  if (href.includes(baseRoute)) {
@@ -112,13 +115,17 @@ export var ManualContent = function ManualContent(_ref) {
112
115
  var item = _step.value;
113
116
  item.children = [];
114
117
  fullSidebarDataToMenuData(rootList, item.key, item.children);
115
- (_funllSidebarData$ite = funllSidebarData[item.key][0].children) === null || _funllSidebarData$ite === void 0 ? void 0 : _funllSidebarData$ite.forEach(function (itemChild) {
118
+ funllSidebarData[item.key] && ((_funllSidebarData$ite = funllSidebarData[item.key][0].children) === null || _funllSidebarData$ite === void 0 ? void 0 : _funllSidebarData$ite.forEach(function (itemChild) {
116
119
  var label = itemChild.title;
117
120
  var key = itemChild.link;
118
121
  item.children.push(_objectSpread(_objectSpread({}, itemChild), {}, {
119
122
  label: label,
120
123
  key: key
121
124
  }));
125
+ })); // children 的 order 排序
126
+
127
+ item.children.sort(function (a, b) {
128
+ return a.order - b.order;
122
129
  });
123
130
 
124
131
  if (item.children.length == 0) {
@@ -172,7 +179,7 @@ export var ManualContent = function ManualContent(_ref) {
172
179
  useScrollToTop();
173
180
  };
174
181
 
175
- var _useState5 = useState(renderSidebar.length !== 0 ? [renderSidebar[0].key] : ['']),
182
+ var _useState5 = useState(),
176
183
  _useState6 = _slicedToArray(_useState5, 2),
177
184
  defaultSelectedKey = _useState6[0],
178
185
  setDefaultSelectedKey = _useState6[1]; //上一夜下一页
@@ -194,11 +201,14 @@ export var ManualContent = function ManualContent(_ref) {
194
201
  for (var _i3 = 0, _Object$keys = Object.keys(linkoTitle); _i3 < _Object$keys.length; _i3++) {
195
202
  var route = _Object$keys[_i3];
196
203
  sidebarRoutes.push(route);
197
- } // 兜底 如果 nav 指定有误则自动重定向到 indexDocRoute
204
+ }
198
205
 
206
+ var uri = new URI(location.href);
207
+ uri.path = getNavigateUrl("/".concat(uri.path), indexRoute, sidebarRoutes);
199
208
 
200
- if (window.location.pathname.startsWith('/docs/') || !sidebarRoutes.includes(window.location.pathname)) {
201
- navigate(indexRoute);
209
+ if ("".concat(uri.path) !== window.location.pathname) {
210
+ uri.path = uri.path.slice(1);
211
+ navigate(uri.toURI().replace(location.origin, ''));
202
212
  } // 改变菜单栏选中和 openKeys 状态
203
213
 
204
214
 
@@ -262,7 +272,10 @@ export var ManualContent = function ManualContent(_ref) {
262
272
  forceSubMenuRender: true,
263
273
  triggerSubMenuAction: "click"
264
274
  });
265
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Layout, {
275
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SEO, {
276
+ title: linkoTitle[window.location.pathname],
277
+ lang: locale.id
278
+ }), /*#__PURE__*/React.createElement(Layout, {
266
279
  style: {
267
280
  background: '#fff'
268
281
  },
@@ -272,9 +285,9 @@ export var ManualContent = function ManualContent(_ref) {
272
285
  offsetTop: 0,
273
286
  className: styles.affix,
274
287
  style: {
275
- height: isWide ? '100vh' : 'inherit'
288
+ height: is767Wide ? '100vh' : 'inherit'
276
289
  }
277
- }, isWide ? /*#__PURE__*/React.createElement(Layout.Sider, {
290
+ }, is767Wide ? /*#__PURE__*/React.createElement(Layout.Sider, {
278
291
  width: "auto",
279
292
  theme: "light",
280
293
  className: styles.sider
@@ -292,22 +305,15 @@ export var ManualContent = function ManualContent(_ref) {
292
305
  }, menu)), /*#__PURE__*/React.createElement(Layout.Content, {
293
306
  className: styles.content
294
307
  }, /*#__PURE__*/React.createElement("div", {
295
- className: styles.contentMain
296
- }, /*#__PURE__*/React.createElement("h1", null, linkoTitle[window.location.pathname], /*#__PURE__*/React.createElement(Tooltip, {
297
- title: '在 GitHub 上编辑'
298
- }, /*#__PURE__*/React.createElement("a", {
299
- href: getGithubSourceUrl({
300
- githubUrl: githubUrl,
301
- relativePath: relativePath,
302
- prefix: 'docs'
303
- }),
304
- target: "_blank",
305
- rel: "noopener noreferrer",
306
- className: styles.editOnGtiHubButton
307
- }, /*#__PURE__*/React.createElement(EditOutlined, null)))), /*#__PURE__*/React.createElement(ReadingTime, {
308
+ className: styles.main
309
+ }, /*#__PURE__*/React.createElement("h1", {
310
+ className: styles.contentTitle
311
+ }, linkoTitle[window.location.pathname]), /*#__PURE__*/React.createElement("div", {
312
+ className: styles.readtimeContainer
313
+ }, /*#__PURE__*/React.createElement(ReadingTime, {
308
314
  readingTime: time,
309
315
  className: styles.readtime
310
- }), /*#__PURE__*/React.createElement("div", {
316
+ })), /*#__PURE__*/React.createElement("div", {
311
317
  className: styles.markdown
312
318
  }, children), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
313
319
  className: styles.preandnext
@@ -323,10 +329,10 @@ export var ManualContent = function ManualContent(_ref) {
323
329
  }
324
330
  }, /*#__PURE__*/React.createElement("div", {
325
331
  className: styles.backTop
326
- }, /*#__PURE__*/React.createElement(VerticalAlignTopOutlined, null))))))), /*#__PURE__*/React.createElement(Layout.Sider, {
332
+ }, /*#__PURE__*/React.createElement(VerticalAlignTopOutlined, null))))))), is991Wide ? /*#__PURE__*/React.createElement(Layout.Sider, {
327
333
  theme: "light",
328
334
  width: 260
329
335
  }, /*#__PURE__*/React.createElement(Affix, {
330
336
  className: styles.toc
331
- }, /*#__PURE__*/React.createElement(TOC, null)))));
337
+ }, /*#__PURE__*/React.createElement(ContentTable, null))) : /*#__PURE__*/React.createElement("div", null)));
332
338
  };
@@ -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;
@@ -83,6 +84,14 @@
83
84
  background-color: rgba(0, 0, 0, 0.03);
84
85
  }
85
86
 
87
+ code {
88
+ padding: 0.2em 0.4em;
89
+ margin: 0;
90
+ font-size: 85%;
91
+ background-color: rgba(175, 184, 193, 0.2);
92
+ border-radius: 6px;
93
+ }
94
+
86
95
  code[class*='language-'] {
87
96
  background: none;
88
97
  }
@@ -196,6 +205,10 @@
196
205
  > p > br {
197
206
  clear: both;
198
207
  }
208
+
209
+ img {
210
+ max-width: 100%;
211
+ }
199
212
  }
200
213
 
201
214
  .layout {
@@ -203,7 +216,7 @@
203
216
  }
204
217
 
205
218
  .main {
206
- width: calc(100% - @toc-width);
219
+ width: 100%;
207
220
  padding-left: 48px;
208
221
  padding-right: 24px;
209
222
  overflow: hidden;
@@ -236,21 +249,39 @@
236
249
 
237
250
  // reference yuque UI
238
251
  .toc {
239
- :global {
240
- .dumi-default-toc {
241
- > li {
242
- > a {
243
- font-size: 12px;
244
-
245
- &.active {
246
- border-left: 1px solid @primary-color !important;
247
- }
248
- }
249
- }
252
+ width: @toc-width;
253
+ float: right;
254
+ font-size: 12px;
255
+ background: #fff;
256
+ max-height: 100vh;
257
+ overflow: scroll;
258
+
259
+ position: sticky;
260
+ top: 0;
261
+
262
+ ul>li {
263
+ list-style: none !important;
264
+ padding: 0 !important;
265
+ margin-left: -1px !important;
266
+
267
+ // 超出部分省略号显示
268
+ text-overflow: ellipsis;
269
+ overflow: hidden;
270
+ white-space: nowrap;
271
+
272
+ a {
273
+ color: @text-color;
250
274
  }
251
275
  }
252
276
  }
253
-
277
+ .contentTitle {
278
+ margin-top: 8px;
279
+ margin-bottom: 20px;
280
+ font-weight: 500;
281
+ font-size: 30px;
282
+ font-family: Avenir, -apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Helvetica Neue, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;
283
+ line-height: 38px;
284
+ }
254
285
  .sider {
255
286
  width: 280px !important;
256
287
  height: inherit;
@@ -460,16 +491,11 @@
460
491
  padding-left: 32px;
461
492
  padding-right: 32px;
462
493
  }
463
-
464
- .toc {
465
- display: none;
466
- }
467
494
  }
468
-
469
- .sider {
470
- width: 240px !important;
495
+ .tocSiderbar {
496
+ display: none;
471
497
  }
472
-
498
+
473
499
  .gallery {
474
500
  .galleryCard {
475
501
  width: 50%;
@@ -487,11 +513,9 @@
487
513
  }
488
514
 
489
515
  .sider {
490
- width: 100% !important;
491
516
  margin-bottom: 32px;
492
517
  padding-bottom: 32px;
493
518
  border-bottom: 1px solid #e8e8e8;
494
- display: none;
495
519
  }
496
520
 
497
521
  .markdown {
@@ -596,19 +620,13 @@
596
620
  margin-bottom: 20px;
597
621
  font-weight: 500;
598
622
  font-size: 30px;
599
- font-family: Avenir, -apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Helvetica Neue, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;
600
623
  line-height: 38px;
601
624
  }
602
625
 
603
626
  .content {
604
- display: flex;
605
- justify-content: center;
627
+ width: 100% !important;
606
628
  min-width: 400px;
607
-
608
- .contentMain {
609
- width: 100%;
610
- padding: 0 24px 0 48px;
611
- }
629
+ justify-content: center;
612
630
  }
613
631
 
614
632
  .menuSwitch {
@@ -630,10 +648,11 @@
630
648
  border-radius: 0 4px 4px 0;
631
649
  }
632
650
 
633
-
651
+ .readtimeContainer {
652
+ margin-bottom: 1.2em;
653
+ }
634
654
 
635
655
  .readtime {
636
- margin-bottom: 1.2em;
637
656
  color: #0d1a26;
638
657
  line-height: 1.5715;
639
658
  list-style: none;
@@ -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.every(function (item) {
58
+ return ![item, "".concat(item, "/")].includes(pathname);
59
+ })) {
60
+ return first;
61
+ }
62
+
63
+ return pathname;
35
64
  }
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ interface SEOProps {
3
+ description?: string;
4
+ lang?: string;
5
+ meta?: any[];
6
+ title?: string;
7
+ titleSuffix?: string;
8
+ }
9
+ export declare const SEO: React.FC<SEOProps>;
10
+ export {};