@antv/dumi-theme-antv 0.6.3 → 0.6.4-alpha.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/builtins/Playground/index.js +1 -1
- package/dist/common/ClientOnly.js +21 -0
- package/dist/common/{SEO.js → CommonHelmet.js} +12 -6
- package/dist/common/InViewSuspense.js +29 -0
- package/dist/hooks/useLocale.js +11 -0
- package/dist/hooks/useMenu.js +35 -23
- package/dist/layouts/DocLayout.js +15 -11
- package/dist/layouts/IndexLayout/index.js +16 -0
- package/dist/layouts/{entry/Manual.js → ManualLayout/index.js} +6 -6
- package/dist/pages/404.js +5 -4
- package/dist/pages/Example/index.js +72 -53
- package/dist/pages/Examples/components/ExampleTopicMenu/index.js +3 -2
- package/dist/pages/Examples/index.js +28 -32
- package/dist/{slots → pages/Index/components}/Cases/index.js +1 -1
- package/dist/{slots → pages/Index/components}/Detail/News.js +1 -1
- package/dist/{slots → pages/Index/components}/Detail/index.js +1 -1
- package/dist/{slots → pages/Index/components}/Features/FeatureCard.js +1 -1
- package/dist/{slots → pages/Index/components}/Features/index.js +1 -1
- package/dist/pages/Index/components/_.less +119 -0
- package/dist/{layouts/entry/Index.js → pages/Index/index.js} +17 -21
- package/dist/plugin/index.js +52 -43
- package/dist/slots/CodeEditor/index.js +4 -3
- package/dist/slots/CodePreview/CodeHeader.js +3 -2
- package/dist/slots/CodePreview/index.js +3 -2
- package/dist/slots/CodeRunner/index.js +34 -29
- package/dist/slots/ExampleSider/index.js +3 -2
- package/dist/slots/Feedback/Contributors.js +3 -2
- package/dist/slots/Feedback/EditButton.js +3 -2
- package/dist/slots/Feedback/PageFeedback.js +4 -3
- package/dist/slots/Feedback/SectionFeedback.js +3 -2
- package/dist/slots/Feedback/index.js +12 -10
- package/dist/slots/Footer/index.js +3 -2
- package/dist/slots/Header/Search/index.js +1 -1
- package/dist/slots/Header/index.js +17 -12
- package/dist/slots/ManualContent/Main.js +16 -17
- package/dist/slots/ManualContent/NavigatorBanner.js +4 -2
- package/dist/slots/ManualContent/ObPreview.js +17 -0
- package/dist/slots/ManualContent/index.js +3 -4
- package/dist/slots/ManualContent/usePreview.js +6 -1
- package/dist/slots/ManualContent/utils.js +3 -13
- package/dist/slots/global.js +4 -4
- package/dist/slots/hooks.js +0 -25
- package/dist/slots/utils.js +0 -7
- package/dist/utils/env.js +10 -0
- package/dist/utils/location.js +6 -0
- package/package.json +5 -4
- package/dist/layouts/entry/API.js +0 -12
- package/dist/pages/Example/utils.js +0 -9
- package/dist/slots/Article/index.js +0 -9
- package/dist/slots/Article/index.module.less +0 -8
- package/dist/slots/CodePreview/CodeHeader.module.less +0 -0
- package/dist/slots/Header/Products/NavigatorBanner.js +0 -29
- package/dist/slots/Header/Products/NavigatorBanner.module.less +0 -39
- /package/dist/{slots → pages/Index/components}/Cases/index.module.less +0 -0
- /package/dist/{slots → pages/Index/components}/Companies/index.js +0 -0
- /package/dist/{slots → pages/Index/components}/Companies/index.module.less +0 -0
- /package/dist/{slots → pages/Index/components}/Detail/News.module.less +0 -0
- /package/dist/{slots → pages/Index/components}/Detail/index.module.less +0 -0
- /package/dist/{slots → pages/Index/components}/Features/FeatureCard.module.less +0 -0
- /package/dist/{slots → pages/Index/components}/Features/index.module.less +0 -0
|
@@ -9,7 +9,7 @@ import { get } from 'lodash-es';
|
|
|
9
9
|
import React, { useContext } from 'react';
|
|
10
10
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
11
11
|
import { ThemeAntVContext } from "../../context";
|
|
12
|
-
import
|
|
12
|
+
import CodeRunner from "dumi/theme/slots/CodeRunner";
|
|
13
13
|
import styles from "./index.module.less";
|
|
14
14
|
/**
|
|
15
15
|
* Markdown 标签插件 Playground
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { useLayoutEffect, useState } from 'react';
|
|
8
|
+
var ClientOnly = function ClientOnly(_ref) {
|
|
9
|
+
var children = _ref.children,
|
|
10
|
+
_ref$fallback = _ref.fallback,
|
|
11
|
+
fallback = _ref$fallback === void 0 ? null : _ref$fallback;
|
|
12
|
+
var _useState = useState(false),
|
|
13
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
14
|
+
clientReady = _useState2[0],
|
|
15
|
+
setClientReady = _useState2[1];
|
|
16
|
+
useLayoutEffect(function () {
|
|
17
|
+
setClientReady(true);
|
|
18
|
+
}, []);
|
|
19
|
+
return clientReady ? children : fallback;
|
|
20
|
+
};
|
|
21
|
+
export default ClientOnly;
|
|
@@ -5,8 +5,8 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symb
|
|
|
5
5
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
6
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
7
|
import { Helmet, useLocale, useRouteMeta, useSiteData } from 'dumi';
|
|
8
|
-
import React from 'react';
|
|
9
|
-
var
|
|
8
|
+
import React, { useLayoutEffect } from 'react';
|
|
9
|
+
var CommonHelmet = function CommonHelmet(_ref) {
|
|
10
10
|
var titleSuffix = _ref.titleSuffix,
|
|
11
11
|
propTitle = _ref.title,
|
|
12
12
|
propDescription = _ref.description,
|
|
@@ -21,10 +21,13 @@ var SEO = function SEO(_ref) {
|
|
|
21
21
|
defaultDescription = themeConfig.defaultDescription;
|
|
22
22
|
var title = propTitle || meta.frontmatter.title;
|
|
23
23
|
var description = propDescription || meta.frontmatter.description || defaultDescription;
|
|
24
|
+
var fullTitle = "".concat(title, " | ").concat(titleSuffix || defaultTitle);
|
|
24
25
|
var defaultMeta = [{
|
|
25
26
|
name: "description",
|
|
26
27
|
content: description
|
|
27
|
-
},
|
|
28
|
+
},
|
|
29
|
+
// "og" 全称为 Open Graph,用于指定页面在社交媒体上的展示效果
|
|
30
|
+
{
|
|
28
31
|
property: "og:title",
|
|
29
32
|
content: title
|
|
30
33
|
}, {
|
|
@@ -49,13 +52,16 @@ var SEO = function SEO(_ref) {
|
|
|
49
52
|
property: "twitter:image",
|
|
50
53
|
content: 'https://gw.alipayobjects.com/zos/antfincdn/FLrTNDvlna/antv.png'
|
|
51
54
|
}];
|
|
55
|
+
useLayoutEffect(function () {
|
|
56
|
+
// 直接设置 document.title 作为备份机制
|
|
57
|
+
document.title = fullTitle;
|
|
58
|
+
}, [fullTitle]);
|
|
52
59
|
return /*#__PURE__*/React.createElement(Helmet, {
|
|
53
60
|
htmlAttributes: {
|
|
54
61
|
lang: lang
|
|
55
62
|
},
|
|
56
|
-
|
|
57
|
-
title: title,
|
|
63
|
+
title: fullTitle,
|
|
58
64
|
meta: [].concat(defaultMeta, _toConsumableArray(propMeta))
|
|
59
65
|
});
|
|
60
66
|
};
|
|
61
|
-
export default
|
|
67
|
+
export default CommonHelmet;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 只在组件进入视口(可见区域)时才会加载和渲染被包裹的懒加载组件
|
|
3
|
+
*/
|
|
4
|
+
import { Skeleton } from 'antd';
|
|
5
|
+
import React, { Suspense } from 'react';
|
|
6
|
+
import { InView } from 'react-intersection-observer';
|
|
7
|
+
var InViewSuspense = function InViewSuspense(_ref) {
|
|
8
|
+
var children = _ref.children,
|
|
9
|
+
_ref$fallback = _ref.fallback,
|
|
10
|
+
fallback = _ref$fallback === void 0 ? /*#__PURE__*/React.createElement(Skeleton.Input, {
|
|
11
|
+
active: true,
|
|
12
|
+
size: "small"
|
|
13
|
+
}) : _ref$fallback,
|
|
14
|
+
_ref$delay = _ref.delay,
|
|
15
|
+
delay = _ref$delay === void 0 ? 200 : _ref$delay;
|
|
16
|
+
return /*#__PURE__*/React.createElement(InView, {
|
|
17
|
+
triggerOnce: true,
|
|
18
|
+
delay: delay
|
|
19
|
+
}, function (_ref2) {
|
|
20
|
+
var inView = _ref2.inView,
|
|
21
|
+
ref = _ref2.ref;
|
|
22
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
23
|
+
ref: ref
|
|
24
|
+
}, /*#__PURE__*/React.createElement(Suspense, {
|
|
25
|
+
fallback: fallback
|
|
26
|
+
}, inView ? children : /*#__PURE__*/React.createElement("span", null)));
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
export default InViewSuspense;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useLocale as useDumiLocale } from 'dumi';
|
|
2
|
+
/**
|
|
3
|
+
* 获取国际化
|
|
4
|
+
*/
|
|
5
|
+
var useLocale = function useLocale(localeMap) {
|
|
6
|
+
var _useDumiLocale = useDumiLocale(),
|
|
7
|
+
id = _useDumiLocale.id;
|
|
8
|
+
var localeType = id === 'zh' ? 'zh' : 'en';
|
|
9
|
+
return [localeMap === null || localeMap === void 0 ? void 0 : localeMap[localeType], localeType];
|
|
10
|
+
};
|
|
11
|
+
export default useLocale;
|
package/dist/hooks/useMenu.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
5
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
2
6
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
3
7
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
8
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
@@ -9,13 +13,12 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
9
13
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
14
|
import { useFullSidebarData, useLocale, useLocation, useNavigate, useSiteData } from 'dumi';
|
|
11
15
|
import { get } from 'lodash-es';
|
|
12
|
-
import React, { useMemo } from 'react';
|
|
16
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
13
17
|
import Link from "../common/Link";
|
|
14
18
|
import styles from "../slots/ManualContent/index.module.less";
|
|
15
19
|
import { getBaseRoute } from "../slots/ManualContent/utils";
|
|
16
20
|
import { flattenMenu } from "../utils/menu";
|
|
17
21
|
export var useMenu = function useMenu() {
|
|
18
|
-
var _navOf;
|
|
19
22
|
var fullData = useFullSidebarData();
|
|
20
23
|
var _useLocation = useLocation(),
|
|
21
24
|
pathname = _useLocation.pathname;
|
|
@@ -23,7 +26,7 @@ export var useMenu = function useMenu() {
|
|
|
23
26
|
_useSiteData$themeCon = _useSiteData.themeConfig,
|
|
24
27
|
docs = _useSiteData$themeCon.docs,
|
|
25
28
|
navs = _useSiteData$themeCon.navs;
|
|
26
|
-
var baseRoute = getBaseRoute();
|
|
29
|
+
var baseRoute = getBaseRoute(pathname);
|
|
27
30
|
var navigate = useNavigate();
|
|
28
31
|
var locale = useLocale();
|
|
29
32
|
var currentLocale = locale.id;
|
|
@@ -109,28 +112,37 @@ export var useMenu = function useMenu() {
|
|
|
109
112
|
var flattedMenuData = useMemo(function () {
|
|
110
113
|
return flattenMenu(menuData);
|
|
111
114
|
}, [menuData]);
|
|
112
|
-
var selectedKey = pathname;
|
|
113
115
|
|
|
114
|
-
//
|
|
115
|
-
var
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
116
|
+
// 添加本地状态来存储选中的key
|
|
117
|
+
var _useState = useState(pathname),
|
|
118
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
119
|
+
selectedKey = _useState2[0],
|
|
120
|
+
setSelectedKey = _useState2[1];
|
|
121
|
+
useEffect(function () {
|
|
122
|
+
var _navOf;
|
|
123
|
+
// Nav 跳转但不在菜单中,则选中第一个菜单项
|
|
124
|
+
var navOf = function navOf(navs) {
|
|
125
|
+
return navs.some(function (nav) {
|
|
126
|
+
var _nav$slug;
|
|
127
|
+
return (nav === null || nav === void 0 || (_nav$slug = nav.slug) === null || _nav$slug === void 0 ? void 0 : _nav$slug.replace('docs/', '/')) === pathname;
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
var isNavLink = !!navOf(navs);
|
|
131
|
+
var isExactLink = (_navOf = navOf(navs)) === null || _navOf === void 0 ? void 0 : _navOf.exact;
|
|
132
|
+
var isLinkInMenu = flattedMenuData === null || flattedMenuData === void 0 ? void 0 : flattedMenuData.some(function (item) {
|
|
133
|
+
return item.link === pathname;
|
|
129
134
|
});
|
|
130
|
-
if (
|
|
131
|
-
|
|
132
|
-
|
|
135
|
+
if (isNavLink && !isExactLink && !isLinkInMenu) {
|
|
136
|
+
var firstValidMenuItem = flattedMenuData === null || flattedMenuData === void 0 ? void 0 : flattedMenuData.find(function (item) {
|
|
137
|
+
return item.link;
|
|
138
|
+
});
|
|
139
|
+
if (firstValidMenuItem) {
|
|
140
|
+
navigate(firstValidMenuItem.link);
|
|
141
|
+
setSelectedKey(firstValidMenuItem.link);
|
|
142
|
+
}
|
|
143
|
+
} else {
|
|
144
|
+
setSelectedKey(pathname);
|
|
133
145
|
}
|
|
134
|
-
}
|
|
146
|
+
}, [pathname, flattedMenuData, navs, navigate]);
|
|
135
147
|
return [menuData, selectedKey, flattedMenuData];
|
|
136
148
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { useLocation, useOutlet, useSiteData } from 'dumi';
|
|
2
2
|
import React, { useEffect } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
3
|
+
import { getPurePathname } from "../utils/location";
|
|
4
|
+
import IndexLayout from "./IndexLayout";
|
|
5
|
+
import ManualLayout from "./ManualLayout";
|
|
6
6
|
|
|
7
7
|
// 用户手动添加自己的
|
|
8
8
|
import "../slots/_.less";
|
|
9
9
|
import "../slots/global";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* DocLayout 是 dumi2 的内置 layout 入口,在这里使用页面路径进行区分成自己不同的 Layout。
|
|
13
13
|
*/
|
|
14
14
|
export default (function () {
|
|
15
15
|
var _useSiteData = useSiteData(),
|
|
@@ -22,8 +22,10 @@ export default (function () {
|
|
|
22
22
|
console.log('%cAntV 让数据栩栩如生', 'color:#5B7102; font-size: 20px;'), console.log('%c新一代数据可视化解决方案', 'color:#5B7102;'), console.log('--------------------------'), console.log('%c关注我们的微信公众号 %c“数据可视化 AntV”%c,获取我们团队最新的进展、动态、分享,也欢迎加入我们!', 'color: red', 'color: pink', 'color: red');
|
|
23
23
|
}, []);
|
|
24
24
|
var outlet = useOutlet();
|
|
25
|
-
var
|
|
26
|
-
|
|
25
|
+
var location = useLocation();
|
|
26
|
+
var pathname = location.pathname,
|
|
27
|
+
hash = location.hash;
|
|
28
|
+
var purePathname = getPurePathname(pathname);
|
|
27
29
|
|
|
28
30
|
// 监听 hash 变更,跳转到锚点位置
|
|
29
31
|
// 同时监听页面 loading 状态,因为路由按需加载时需要等待页面渲染完毕才能找到锚点位置
|
|
@@ -34,9 +36,11 @@ export default (function () {
|
|
|
34
36
|
if (elm) document.documentElement.scrollTo(0, elm.offsetTop - 80);
|
|
35
37
|
}
|
|
36
38
|
}, [loading, hash]);
|
|
37
|
-
|
|
39
|
+
|
|
38
40
|
// 首页
|
|
39
|
-
if (
|
|
41
|
+
if (['/', ''].includes(purePathname)) {
|
|
42
|
+
return /*#__PURE__*/React.createElement(IndexLayout, null, outlet);
|
|
43
|
+
}
|
|
40
44
|
|
|
41
45
|
// 匹配 navs 中的 docs 路由
|
|
42
46
|
var docsRoutes = navs.filter(function (nav) {
|
|
@@ -46,10 +50,10 @@ export default (function () {
|
|
|
46
50
|
return item !== 'docs';
|
|
47
51
|
});
|
|
48
52
|
});
|
|
49
|
-
if (docsRoutes.some(function (
|
|
50
|
-
return
|
|
53
|
+
if (docsRoutes.some(function (slug) {
|
|
54
|
+
return purePathname.startsWith("/".concat(slug)) || purePathname.startsWith("/docs/".concat(slug));
|
|
51
55
|
})) {
|
|
52
|
-
return /*#__PURE__*/React.createElement(
|
|
56
|
+
return /*#__PURE__*/React.createElement(ManualLayout, null, outlet);
|
|
53
57
|
}
|
|
54
58
|
return outlet;
|
|
55
59
|
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Footer from "dumi/theme/slots/Footer";
|
|
3
|
+
import Header from "dumi/theme/slots/Header";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 首页布局
|
|
7
|
+
*/
|
|
8
|
+
var IndexLayout = function IndexLayout(props) {
|
|
9
|
+
var children = props.children;
|
|
10
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Header, null), /*#__PURE__*/React.createElement("div", {
|
|
11
|
+
style: {
|
|
12
|
+
minHeight: '100vh'
|
|
13
|
+
}
|
|
14
|
+
}, children), /*#__PURE__*/React.createElement(Footer, null));
|
|
15
|
+
};
|
|
16
|
+
export default IndexLayout;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { Header } from "dumi/theme/slots/Header";
|
|
2
|
+
import Footer from "dumi/theme/slots/Footer";
|
|
3
|
+
import Header from "dumi/theme/slots/Header";
|
|
5
4
|
import { ManualContent } from "dumi/theme/slots/ManualContent";
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Manual 路由下的入口
|
|
9
8
|
*/
|
|
10
|
-
|
|
9
|
+
var ManualLayout = function ManualLayout(_ref) {
|
|
11
10
|
var children = _ref.children;
|
|
12
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(
|
|
11
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Header, {
|
|
13
12
|
isHomePage: false
|
|
14
13
|
}), /*#__PURE__*/React.createElement(ManualContent, null, children), /*#__PURE__*/React.createElement(Footer, {
|
|
15
14
|
isDynamicFooter: true
|
|
16
15
|
}));
|
|
17
|
-
};
|
|
16
|
+
};
|
|
17
|
+
export default ManualLayout;
|
package/dist/pages/404.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import CommonHelmet from "../common/CommonHelmet";
|
|
3
3
|
import { NotFound as NotFoundPage } from "dumi/theme/slots/404";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import Footer from "dumi/theme/slots/Footer";
|
|
5
|
+
import Header from "dumi/theme/slots/Header";
|
|
6
|
+
|
|
6
7
|
/**
|
|
7
8
|
* 404 页面
|
|
8
9
|
*/
|
|
9
10
|
var NotFound = function NotFound() {
|
|
10
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(
|
|
11
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CommonHelmet, {
|
|
11
12
|
title: "404: Not found"
|
|
12
13
|
}), /*#__PURE__*/React.createElement(Header, {
|
|
13
14
|
isHomePage: false
|
|
@@ -1,77 +1,96 @@
|
|
|
1
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
1
|
import { Layout } from 'antd';
|
|
8
2
|
import { useLocale, useSiteData } from 'dumi';
|
|
9
3
|
import { every, find, get } from 'lodash-es';
|
|
10
|
-
import React, { useContext
|
|
4
|
+
import React, { useContext } from 'react';
|
|
11
5
|
import { useLocation, useNavigate, useParams } from 'react-router-dom';
|
|
12
6
|
import { useSnapshot } from 'valtio';
|
|
13
|
-
import
|
|
7
|
+
import InViewSuspense from "../../common/InViewSuspense";
|
|
8
|
+
import CommonHelmet from "../../common/CommonHelmet";
|
|
14
9
|
import { ThemeAntVContext } from "../../context";
|
|
15
10
|
import { store } from "../../model";
|
|
16
11
|
import { API } from "dumi/theme/slots/API";
|
|
17
|
-
import
|
|
12
|
+
import CodeRunner from "dumi/theme/slots/CodeRunner";
|
|
18
13
|
import { getDemoInfo } from "../../slots/CodeRunner/utils";
|
|
19
|
-
import { ExampleSider } from "dumi/theme/slots/ExampleSider";
|
|
20
|
-
import { Header } from "dumi/theme/slots/Header";
|
|
21
14
|
import { CollapsedIcon } from "./components/CollapsedIcon";
|
|
22
15
|
import styles from "./index.module.less";
|
|
23
|
-
import { getCurrentTitle } from "./utils";
|
|
24
16
|
var Sider = Layout.Sider,
|
|
25
17
|
Content = Layout.Content;
|
|
18
|
+
var Header = /*#__PURE__*/React.lazy(function () {
|
|
19
|
+
return import("dumi/theme/slots/Header");
|
|
20
|
+
});
|
|
21
|
+
var ExampleSider = /*#__PURE__*/React.lazy(function () {
|
|
22
|
+
return import("dumi/theme/slots/ExampleSider");
|
|
23
|
+
});
|
|
26
24
|
/**
|
|
27
|
-
*
|
|
25
|
+
* 解析 Example 页面的元数据
|
|
28
26
|
*/
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var
|
|
27
|
+
var useExampleMeta = function useExampleMeta() {
|
|
28
|
+
/** 示例页面的元数据信息 */
|
|
29
|
+
var metaData = useContext(ThemeAntVContext);
|
|
30
|
+
var exampleTopics = metaData.meta.exampleTopics;
|
|
33
31
|
var _useParams = useParams(),
|
|
34
32
|
topic = _useParams.topic,
|
|
35
33
|
example = _useParams.example;
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
var _useLocation = useLocation(),
|
|
35
|
+
hash = _useLocation.hash;
|
|
36
|
+
var examples = get(exampleTopics, ['0', 'examples']);
|
|
37
|
+
var exampleDemo = find(examples, function (_ref) {
|
|
38
|
+
var id = _ref.id;
|
|
39
|
+
return id === example;
|
|
40
|
+
});
|
|
41
|
+
// examples/case/id hash 为空,可以默认第一个 example 对应的 demo
|
|
42
|
+
var demo = hash.slice(1) || get(exampleDemo, ['demos', '0', 'id']);
|
|
43
|
+
var locale = useLocale();
|
|
44
|
+
var exampleTitle = get(exampleDemo, ['title', locale.id]);
|
|
45
|
+
var currentDemo = getDemoInfo(exampleTopics, topic, example, demo);
|
|
46
|
+
var demoTitle = get(currentDemo, ['title', locale.id]);
|
|
47
|
+
return {
|
|
48
|
+
// all example topics
|
|
49
|
+
exampleTopics: exampleTopics,
|
|
50
|
+
// topic id
|
|
51
|
+
topic: topic,
|
|
52
|
+
// example id
|
|
53
|
+
example: example,
|
|
54
|
+
// example title
|
|
55
|
+
exampleTitle: exampleTitle,
|
|
56
|
+
// demo id
|
|
57
|
+
demo: demo,
|
|
58
|
+
// current demo info
|
|
59
|
+
currentDemo: currentDemo,
|
|
60
|
+
// demo title
|
|
61
|
+
demoTitle: demoTitle
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 具体单个案例的页面
|
|
67
|
+
*/
|
|
68
|
+
var Example = function Example() {
|
|
69
|
+
var state = useSnapshot(store);
|
|
70
|
+
var navigate = useNavigate();
|
|
38
71
|
var locale = useLocale();
|
|
72
|
+
var _useExampleMeta = useExampleMeta(),
|
|
73
|
+
exampleTopics = _useExampleMeta.exampleTopics,
|
|
74
|
+
exampleTitle = _useExampleMeta.exampleTitle,
|
|
75
|
+
currentDemo = _useExampleMeta.currentDemo,
|
|
76
|
+
topic = _useExampleMeta.topic,
|
|
77
|
+
example = _useExampleMeta.example,
|
|
78
|
+
demo = _useExampleMeta.demo,
|
|
79
|
+
demoTitle = _useExampleMeta.demoTitle;
|
|
39
80
|
var _useSiteData = useSiteData(),
|
|
40
81
|
themeConfig = _useSiteData.themeConfig;
|
|
41
|
-
var exampleTopics = metaData.meta.exampleTopics;
|
|
42
|
-
var demo = useMemo(function () {
|
|
43
|
-
var examples = get(exampleTopics, ['0', 'examples']);
|
|
44
|
-
var exampleDemo = find(examples, function (_ref) {
|
|
45
|
-
var id = _ref.id;
|
|
46
|
-
return id === example;
|
|
47
|
-
});
|
|
48
|
-
// examples/case/id hash 为空,可以默认第一个 example 对应的 demo
|
|
49
|
-
return hash.slice(1) || get(exampleDemo, ['demos', '0', 'id']);
|
|
50
|
-
}, [hash, exampleTopics, example]);
|
|
51
|
-
var _useState = useState(),
|
|
52
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
53
|
-
currentDemo = _useState2[0],
|
|
54
|
-
setCurrentDemo = _useState2[1];
|
|
55
|
-
var state = useSnapshot(store);
|
|
56
|
-
var _useState3 = useState({}),
|
|
57
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
58
|
-
title = _useState4[0],
|
|
59
|
-
setTitle = _useState4[1];
|
|
60
|
-
useEffect(function () {
|
|
61
|
-
if (topic && example && demo) {
|
|
62
|
-
var targetDemoInfo = getDemoInfo(exampleTopics, topic, example, demo);
|
|
63
|
-
setCurrentDemo(targetDemoInfo);
|
|
64
|
-
setTitle(getCurrentTitle(exampleTopics, topic, example));
|
|
65
|
-
}
|
|
66
|
-
}, [topic, example, hash]);
|
|
67
82
|
var showAPI = every([get(themeConfig, 'showAPIDoc'), topic, example], Boolean);
|
|
83
|
+
if (!currentDemo) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
68
86
|
return /*#__PURE__*/React.createElement("div", {
|
|
69
87
|
className: styles.example
|
|
70
|
-
}, /*#__PURE__*/React.createElement(
|
|
71
|
-
title:
|
|
72
|
-
|
|
88
|
+
}, /*#__PURE__*/React.createElement(CommonHelmet, {
|
|
89
|
+
title: exampleTitle,
|
|
90
|
+
description: demoTitle
|
|
91
|
+
}), /*#__PURE__*/React.createElement(InViewSuspense, null, /*#__PURE__*/React.createElement(Header, {
|
|
73
92
|
isHomePage: false
|
|
74
|
-
}), /*#__PURE__*/React.createElement(Layout, {
|
|
93
|
+
})), /*#__PURE__*/React.createElement(Layout, {
|
|
75
94
|
className: styles.container
|
|
76
95
|
}, /*#__PURE__*/React.createElement(Sider, {
|
|
77
96
|
collapsedWidth: 0,
|
|
@@ -81,7 +100,7 @@ var Example = function Example() {
|
|
|
81
100
|
collapsed: state.hideMenu,
|
|
82
101
|
className: styles.menuSider,
|
|
83
102
|
theme: "light"
|
|
84
|
-
},
|
|
103
|
+
}, /*#__PURE__*/React.createElement(InViewSuspense, null, /*#__PURE__*/React.createElement(ExampleSider, {
|
|
85
104
|
showExampleDemoTitle: true,
|
|
86
105
|
currentDemo: currentDemo,
|
|
87
106
|
onDemoClicked: function onDemoClicked(example) {
|
|
@@ -90,10 +109,10 @@ var Example = function Example() {
|
|
|
90
109
|
targetTopic = example.targetTopic;
|
|
91
110
|
// eg: /zh/examples/case/area/#area1
|
|
92
111
|
var newURL = "/".concat(locale.id, "/examples/").concat(targetTopic === null || targetTopic === void 0 ? void 0 : targetTopic.id, "/").concat(targetExample === null || targetExample === void 0 ? void 0 : targetExample.id, "/#").concat(demoId);
|
|
93
|
-
|
|
112
|
+
navigate(newURL);
|
|
94
113
|
},
|
|
95
114
|
exampleTopics: exampleTopics
|
|
96
|
-
}), /*#__PURE__*/React.createElement(CollapsedIcon, {
|
|
115
|
+
})), /*#__PURE__*/React.createElement(CollapsedIcon, {
|
|
97
116
|
isCollapsed: state.hideMenu,
|
|
98
117
|
onClick: function onClick(show) {
|
|
99
118
|
store.hideMenu = show;
|
|
@@ -104,7 +123,7 @@ var Example = function Example() {
|
|
|
104
123
|
}
|
|
105
124
|
})), /*#__PURE__*/React.createElement(Content, {
|
|
106
125
|
className: styles.content
|
|
107
|
-
},
|
|
126
|
+
}, /*#__PURE__*/React.createElement(CodeRunner, {
|
|
108
127
|
exampleTopics: exampleTopics,
|
|
109
128
|
topic: topic,
|
|
110
129
|
example: example,
|
|
@@ -18,7 +18,7 @@ import { LeftMenu } from "./components/LeftMenu";
|
|
|
18
18
|
* @param {LeftMenuProps} props 相关参数,详见类型定义
|
|
19
19
|
* @returns {React.FC} React.FC
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
var ExampleTopicMenu = function ExampleTopicMenu(props) {
|
|
22
22
|
var exampleTopics = props.exampleTopics;
|
|
23
23
|
var isWide = useMedia('(min-width: 767.99px)', true);
|
|
24
24
|
var _useState = useState(false),
|
|
@@ -51,4 +51,5 @@ export var ExampleTopicMenu = function ExampleTopicMenu(props) {
|
|
|
51
51
|
}, /*#__PURE__*/React.createElement(LeftMenu, {
|
|
52
52
|
exampleTopics: exampleTopics
|
|
53
53
|
})));
|
|
54
|
-
};
|
|
54
|
+
};
|
|
55
|
+
export default ExampleTopicMenu;
|
|
@@ -6,39 +6,41 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
6
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
7
|
import { VerticalAlignTopOutlined } from '@ant-design/icons';
|
|
8
8
|
import { Layout as AntLayout, BackTop } from 'antd';
|
|
9
|
-
import {
|
|
10
|
-
import React, { useContext, useEffect } from 'react';
|
|
9
|
+
import React, { lazy, useContext, useEffect } from 'react';
|
|
11
10
|
import { useNavigate } from 'react-router-dom';
|
|
12
|
-
import
|
|
11
|
+
import InViewSuspense from "../../common/InViewSuspense";
|
|
12
|
+
import CommonHelmet from "../../common/CommonHelmet";
|
|
13
13
|
import { ThemeAntVContext } from "../../context";
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import { usePrevAndNext } from "../../slots/hooks";
|
|
14
|
+
import useLocale from "../../hooks/useLocale";
|
|
15
|
+
import Footer from "dumi/theme/slots/Footer";
|
|
16
|
+
import Header from "dumi/theme/slots/Header";
|
|
18
17
|
import { Article } from "./components/Article";
|
|
19
|
-
import { ExampleTopicMenu } from "./components/ExampleTopicMenu";
|
|
20
18
|
import { GalleryPageContent } from "./components/GalleryPageContent";
|
|
21
19
|
import styles from "./index.module.less";
|
|
20
|
+
var ExampleTopicMenu = /*#__PURE__*/lazy(function () {
|
|
21
|
+
return import("./components/ExampleTopicMenu");
|
|
22
|
+
});
|
|
23
|
+
var locales = {
|
|
24
|
+
zh: {
|
|
25
|
+
title: '所有图表'
|
|
26
|
+
},
|
|
27
|
+
en: {
|
|
28
|
+
title: 'Gallery'
|
|
29
|
+
}
|
|
30
|
+
};
|
|
22
31
|
|
|
23
32
|
/**
|
|
24
33
|
* Examples 页面
|
|
25
|
-
*
|
|
26
|
-
* @author YuZhanglong <loveyzl1123@gmail.com>
|
|
27
34
|
*/
|
|
28
|
-
var
|
|
35
|
+
var Examples = function Examples() {
|
|
29
36
|
var nav = useNavigate();
|
|
30
|
-
var
|
|
37
|
+
var _useLocale = useLocale(locales),
|
|
38
|
+
_useLocale2 = _slicedToArray(_useLocale, 1),
|
|
39
|
+
locale = _useLocale2[0];
|
|
40
|
+
|
|
31
41
|
/** 示例页面的元数据信息 */
|
|
32
42
|
var metaData = useContext(ThemeAntVContext);
|
|
33
43
|
var exampleTopics = metaData.meta.exampleTopics;
|
|
34
|
-
var _usePrevAndNext = usePrevAndNext(),
|
|
35
|
-
_usePrevAndNext2 = _slicedToArray(_usePrevAndNext, 2),
|
|
36
|
-
prev = _usePrevAndNext2[0],
|
|
37
|
-
next = _usePrevAndNext2[1];
|
|
38
|
-
var title = {
|
|
39
|
-
zh: '所有图表',
|
|
40
|
-
en: 'Gallery'
|
|
41
|
-
}[locale.id];
|
|
42
44
|
|
|
43
45
|
// 为 zh 做兜底
|
|
44
46
|
useEffect(function () {
|
|
@@ -47,16 +49,16 @@ var Example = function Example() {
|
|
|
47
49
|
nav(p.replace('/zh/', '/'));
|
|
48
50
|
}
|
|
49
51
|
}, []);
|
|
50
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(
|
|
51
|
-
title: title
|
|
52
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CommonHelmet, {
|
|
53
|
+
title: locale.title
|
|
52
54
|
}), /*#__PURE__*/React.createElement(Header, {
|
|
53
55
|
isHomePage: false
|
|
54
56
|
}), /*#__PURE__*/React.createElement(AntLayout, {
|
|
55
57
|
hasSider: true,
|
|
56
58
|
className: styles.layout
|
|
57
|
-
}, /*#__PURE__*/React.createElement(ExampleTopicMenu, {
|
|
59
|
+
}, /*#__PURE__*/React.createElement(InViewSuspense, null, /*#__PURE__*/React.createElement(ExampleTopicMenu, {
|
|
58
60
|
exampleTopics: exampleTopics
|
|
59
|
-
}), /*#__PURE__*/React.createElement(Article, {
|
|
61
|
+
})), /*#__PURE__*/React.createElement(Article, {
|
|
60
62
|
className: styles.markdown
|
|
61
63
|
}, /*#__PURE__*/React.createElement("div", {
|
|
62
64
|
className: styles.main,
|
|
@@ -65,13 +67,7 @@ var Example = function Example() {
|
|
|
65
67
|
}
|
|
66
68
|
}, /*#__PURE__*/React.createElement(GalleryPageContent, {
|
|
67
69
|
exampleTopics: exampleTopics
|
|
68
|
-
}), /*#__PURE__*/React.createElement(
|
|
69
|
-
type: "prev",
|
|
70
|
-
post: prev
|
|
71
|
-
}), /*#__PURE__*/React.createElement(NavigatorBanner, {
|
|
72
|
-
type: "next",
|
|
73
|
-
post: next
|
|
74
|
-
})), /*#__PURE__*/React.createElement(BackTop, {
|
|
70
|
+
}), /*#__PURE__*/React.createElement(BackTop, {
|
|
75
71
|
style: {
|
|
76
72
|
right: 24
|
|
77
73
|
}
|
|
@@ -81,4 +77,4 @@ var Example = function Example() {
|
|
|
81
77
|
isDynamicFooter: true
|
|
82
78
|
}));
|
|
83
79
|
};
|
|
84
|
-
export default
|
|
80
|
+
export default Examples;
|
|
@@ -4,7 +4,7 @@ import cx from 'classnames';
|
|
|
4
4
|
import { FormattedMessage, Link, useLocale } from 'dumi';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import Slider from 'react-slick';
|
|
7
|
-
import { ic, icWithLocale } from "
|
|
7
|
+
import { ic, icWithLocale } from "../../../../slots/hooks";
|
|
8
8
|
import 'slick-carousel/slick/slick-theme.css';
|
|
9
9
|
import 'slick-carousel/slick/slick.css';
|
|
10
10
|
import styles from "./index.module.less";
|