@antv/dumi-theme-antv 0.3.0-beta.4 → 0.3.0-beta.6
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/context.d.ts +2 -1
- package/dist/layouts/DocLayout.js +26 -14
- package/dist/pages/Example/index.js +8 -2
- package/dist/pages/Examples/types.d.ts +7 -6
- package/dist/plugin/examples.d.ts +13 -5
- package/dist/plugin/examples.js +14 -2
- package/dist/plugin/index.js +16 -8
- package/dist/slots/Cases/index.d.ts +1 -0
- package/dist/slots/CodeEditor/index.js +28 -8
- package/dist/slots/CodePreview/index.js +1 -1
- package/dist/slots/CodePreview/index.module.less +3 -5
- package/dist/slots/CodeRunner/index.d.ts +3 -2
- package/dist/slots/CodeRunner/index.js +5 -3
- package/dist/slots/CodeRunner/utils.d.ts +3 -2
- package/dist/slots/CodeRunner/utils.js +1 -1
- package/dist/slots/Detail/News.d.ts +1 -0
- package/dist/slots/Detail/index.d.ts +1 -0
- package/dist/slots/ExampleSider/index.d.ts +4 -3
- package/dist/slots/ExampleSider/index.js +2 -2
- package/dist/slots/Features/FeatureCard.d.ts +1 -0
- package/dist/slots/Header/Navs.js +8 -4
- package/dist/slots/Header/index.js +6 -6
- package/dist/slots/Loading/index.d.ts +6 -1
- package/dist/slots/Loading/index.js +24 -10
- package/dist/slots/Loading/index.module.less +276 -9
- package/dist/slots/ManualContent/index.js +114 -112
- package/dist/slots/ManualContent/utils.d.ts +3 -0
- package/dist/slots/ManualContent/utils.js +35 -0
- package/dist/slots/utils.d.ts +2 -2
- package/dist/types.d.ts +82 -0
- package/dist/typings.d.ts +0 -101
- package/package.json +1 -1
- package/dist/slots/Loading.d.ts +0 -5
- package/dist/slots/Loading.js +0 -8
package/dist/context.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { ExampleTopic } from './types';
|
|
2
3
|
export declare type IThemeAntVContext = {
|
|
3
|
-
exampleTopics?:
|
|
4
|
+
exampleTopics?: ExampleTopic[];
|
|
4
5
|
};
|
|
5
6
|
export declare const ThemeAntVContext: import("react").Context<IThemeAntVContext>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { useOutlet, useLocation } from 'dumi';
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { useOutlet, useLocation, useSiteData } from 'dumi';
|
|
3
3
|
import { Index } from "./entry/Index";
|
|
4
|
-
import { API } from "./entry/API";
|
|
5
4
|
import { Manual } from "./entry/Manual"; // 用户手动添加自己的
|
|
6
5
|
|
|
7
6
|
import "../slots/global";
|
|
@@ -11,26 +10,39 @@ import "../slots/_.less";
|
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
export default (function () {
|
|
13
|
+
var _useSiteData = useSiteData(),
|
|
14
|
+
themeConfig = _useSiteData.themeConfig;
|
|
15
|
+
|
|
16
|
+
var navs = themeConfig.navs; // 打印控制台文案
|
|
17
|
+
|
|
18
|
+
useEffect(function () {
|
|
19
|
+
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");
|
|
20
|
+
}, []);
|
|
14
21
|
var outlet = useOutlet();
|
|
15
22
|
|
|
16
23
|
var _useLocation = useLocation(),
|
|
17
24
|
pathname = _useLocation.pathname;
|
|
18
25
|
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
if (p === '/' || p === '/zh' || p === '/en' || p === '/en/') return /*#__PURE__*/React.createElement(Index, null); // API 页面
|
|
26
|
+
var path = pathname; // 统一去掉中英文前缀
|
|
22
27
|
|
|
23
|
-
|
|
24
|
-
p.startsWith('/zh/api') || p.startsWith('/en/api') || p.startsWith('/zh/docs/api') || p.startsWith('/en/docs/api')) {
|
|
25
|
-
return /*#__PURE__*/React.createElement(API, null, " ", outlet, " ");
|
|
26
|
-
} // 教程页面
|
|
28
|
+
var p = path.replace('/zh/', '/').replace('/en/', '/'); // 首页
|
|
27
29
|
|
|
30
|
+
if (p === '/' || p === '/zh' || p === '/en' || p === '/en/') return /*#__PURE__*/React.createElement(Index, null); // 匹配 navs 中的 docs 路由
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
var hasDocsRoutes = navs.filter(function (nav) {
|
|
33
|
+
return nav.slug.startsWith('docs/');
|
|
34
|
+
});
|
|
35
|
+
var docsRoutes = hasDocsRoutes.map(function (nav) {
|
|
36
|
+
return nav.slug.split('/').find(function (item) {
|
|
37
|
+
return item !== 'docs';
|
|
38
|
+
});
|
|
39
|
+
});
|
|
33
40
|
|
|
41
|
+
if (docsRoutes.some(function (route) {
|
|
42
|
+
return p.startsWith("/".concat(route)) || p.startsWith("/docs/".concat(route));
|
|
43
|
+
})) {
|
|
44
|
+
return /*#__PURE__*/React.createElement(Manual, null, outlet);
|
|
45
|
+
}
|
|
34
46
|
|
|
35
47
|
return outlet;
|
|
36
48
|
});
|
|
@@ -12,8 +12,9 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
12
12
|
|
|
13
13
|
import React, { useContext, useEffect, useState } from 'react';
|
|
14
14
|
import { useParams, useLocation, useNavigate } from 'react-router-dom';
|
|
15
|
+
import { get } from 'lodash-es';
|
|
15
16
|
import { Layout } from 'antd';
|
|
16
|
-
import { useLocale } from 'dumi';
|
|
17
|
+
import { useLocale, useSiteData } from 'dumi';
|
|
17
18
|
import { Header } from "../../slots/Header";
|
|
18
19
|
import { ExampleSider } from "../../slots/ExampleSider";
|
|
19
20
|
import { CodeRunner } from "../../slots/CodeRunner";
|
|
@@ -40,6 +41,10 @@ var Example = function Example() {
|
|
|
40
41
|
|
|
41
42
|
var metaData = useContext(ThemeAntVContext);
|
|
42
43
|
var locale = useLocale();
|
|
44
|
+
|
|
45
|
+
var _useSiteData = useSiteData(),
|
|
46
|
+
themeConfig = _useSiteData.themeConfig;
|
|
47
|
+
|
|
43
48
|
var exampleTopics = metaData.meta.exampleTopics;
|
|
44
49
|
var demo = hash.slice(1);
|
|
45
50
|
|
|
@@ -91,7 +96,8 @@ var Example = function Example() {
|
|
|
91
96
|
exampleTopics: exampleTopics,
|
|
92
97
|
topic: topic,
|
|
93
98
|
example: example,
|
|
94
|
-
demo: demo
|
|
99
|
+
demo: demo,
|
|
100
|
+
size: get(themeConfig, 'editor.size', 0.4)
|
|
95
101
|
}))));
|
|
96
102
|
};
|
|
97
103
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { ExampleTopic, Example, Demo } from '../../types';
|
|
2
3
|
export interface AnnouncementProps {
|
|
3
4
|
message: React.ReactNode;
|
|
4
5
|
localStorageId: string;
|
|
@@ -9,19 +10,19 @@ export interface GalleryPageContentProps {
|
|
|
9
10
|
/**
|
|
10
11
|
* 案例主题列表
|
|
11
12
|
*/
|
|
12
|
-
exampleTopics:
|
|
13
|
+
exampleTopics: ExampleTopic[];
|
|
13
14
|
}
|
|
14
15
|
export interface LeftMenuProps {
|
|
15
16
|
/**
|
|
16
17
|
* 案例主题列表
|
|
17
18
|
*/
|
|
18
|
-
exampleTopics:
|
|
19
|
+
exampleTopics: ExampleTopic[];
|
|
19
20
|
}
|
|
20
|
-
export interface ExampleWithTopic extends
|
|
21
|
-
targetTopic:
|
|
21
|
+
export interface ExampleWithTopic extends Example {
|
|
22
|
+
targetTopic: ExampleTopic;
|
|
22
23
|
}
|
|
23
24
|
export interface DemoCardProps {
|
|
24
|
-
demo:
|
|
25
|
+
demo: Demo;
|
|
25
26
|
topicId: string;
|
|
26
27
|
exampleId: string;
|
|
27
28
|
}
|
|
@@ -29,5 +30,5 @@ export interface LeftMenuProps {
|
|
|
29
30
|
/**
|
|
30
31
|
* 案例主题列表
|
|
31
32
|
*/
|
|
32
|
-
exampleTopics:
|
|
33
|
+
exampleTopics: ExampleTopic[];
|
|
33
34
|
}
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
+
import { Example, ExampleTopic } from '../types';
|
|
1
2
|
/**
|
|
2
3
|
* 获取案例页面的所有主题
|
|
3
4
|
*
|
|
4
|
-
* @returns {
|
|
5
|
+
* @returns {ExampleTopic[]} 案例主题列表
|
|
5
6
|
* @author YuZhanglong <loveyzl1123@gmail.com>
|
|
6
7
|
*/
|
|
7
|
-
export declare const getExamplesPageTopics: (exampleTopics:
|
|
8
|
+
export declare const getExamplesPageTopics: (exampleTopics: ExampleTopic[]) => {
|
|
8
9
|
id: string;
|
|
9
|
-
title:
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
title: {
|
|
11
|
+
zh: string;
|
|
12
|
+
en: string;
|
|
13
|
+
};
|
|
14
|
+
icon: string;
|
|
15
|
+
examples: Example[];
|
|
12
16
|
childrenKey: string;
|
|
13
17
|
}[];
|
|
18
|
+
/**
|
|
19
|
+
* 根据目录结构返回,所有的 example 页面,用于 buiild static
|
|
20
|
+
*/
|
|
21
|
+
export declare function getExamplePaths(): string[];
|
package/dist/plugin/examples.js
CHANGED
|
@@ -22,6 +22,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
22
22
|
// src/plugin/examples.ts
|
|
23
23
|
var examples_exports = {};
|
|
24
24
|
__export(examples_exports, {
|
|
25
|
+
getExamplePaths: () => getExamplePaths,
|
|
25
26
|
getExamplesPageTopics: () => getExamplesPageTopics
|
|
26
27
|
});
|
|
27
28
|
module.exports = __toCommonJS(examples_exports);
|
|
@@ -64,10 +65,11 @@ var getTopicExamples = (topicPath) => {
|
|
|
64
65
|
en: exampleMetaEnContent.attributes.title,
|
|
65
66
|
zh: exampleMetaZhContent.attributes.title
|
|
66
67
|
},
|
|
67
|
-
childrenKey: "demos"
|
|
68
|
+
childrenKey: "demos",
|
|
69
|
+
order: exampleMetaZhContent.attributes.order || 0
|
|
68
70
|
};
|
|
69
71
|
return example;
|
|
70
|
-
});
|
|
72
|
+
}).sort((a, b) => a.order - b.order);
|
|
71
73
|
};
|
|
72
74
|
var getExamplesPageTopics = (exampleTopics) => {
|
|
73
75
|
return exampleTopics.map(({ id, slug, title, icon }) => {
|
|
@@ -87,7 +89,17 @@ var getExamplesPageTopics = (exampleTopics) => {
|
|
|
87
89
|
};
|
|
88
90
|
});
|
|
89
91
|
};
|
|
92
|
+
function getExamplePaths() {
|
|
93
|
+
const exampleTopicPaths = glob.sync(`${examplesBaseDir}/*/*`);
|
|
94
|
+
const paths = exampleTopicPaths.map((p) => p.replace(process.cwd(), ""));
|
|
95
|
+
return [
|
|
96
|
+
...paths,
|
|
97
|
+
...paths.map((p) => `/zh${p}`),
|
|
98
|
+
...paths.map((p) => `/en${p}`)
|
|
99
|
+
];
|
|
100
|
+
}
|
|
90
101
|
// Annotate the CommonJS export names for ESM import in node:
|
|
91
102
|
0 && (module.exports = {
|
|
103
|
+
getExamplePaths,
|
|
92
104
|
getExamplesPageTopics
|
|
93
105
|
});
|
package/dist/plugin/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
17
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
21
|
|
|
19
22
|
// src/plugin/index.ts
|
|
@@ -22,33 +25,39 @@ __export(plugin_exports, {
|
|
|
22
25
|
default: () => plugin_default
|
|
23
26
|
});
|
|
24
27
|
module.exports = __toCommonJS(plugin_exports);
|
|
28
|
+
var path = __toESM(require("path"));
|
|
25
29
|
var import_examples = require("./examples");
|
|
26
30
|
var import_utils = require("./utils");
|
|
27
31
|
var plugin_default = (api) => {
|
|
28
32
|
api.describe({ key: `dumi-theme:${require("../../package.json").name}` });
|
|
29
33
|
api.modifyDefaultConfig((memo) => {
|
|
30
34
|
memo.resolve.codeBlockMode = "passive";
|
|
35
|
+
memo.exportStatic.extraRoutePaths = (0, import_examples.getExamplePaths)();
|
|
31
36
|
return memo;
|
|
32
37
|
});
|
|
33
38
|
const pages = [
|
|
39
|
+
{
|
|
40
|
+
id: "dumi-theme-antv-homepage",
|
|
41
|
+
absPath: "/"
|
|
42
|
+
},
|
|
34
43
|
{
|
|
35
44
|
id: "dumi-theme-antv-example-list-zh",
|
|
36
|
-
|
|
45
|
+
absPath: "/examples",
|
|
37
46
|
file: (0, import_utils.myResolve)("../pages/Examples/index.tsx")
|
|
38
47
|
},
|
|
39
48
|
{
|
|
40
49
|
id: "dumi-theme-antv-example-list-lang",
|
|
41
|
-
|
|
50
|
+
absPath: "/:language/examples",
|
|
42
51
|
file: (0, import_utils.myResolve)("../pages/Examples/index.tsx")
|
|
43
52
|
},
|
|
44
53
|
{
|
|
45
54
|
id: "dumi-theme-antv-single-example-zh",
|
|
46
|
-
|
|
55
|
+
absPath: "/examples/:topic/:example",
|
|
47
56
|
file: (0, import_utils.myResolve)("../pages/Example/index.tsx")
|
|
48
57
|
},
|
|
49
58
|
{
|
|
50
59
|
id: "dumi-theme-antv-single-example-lang",
|
|
51
|
-
|
|
60
|
+
absPath: "/:language/examples/:topic/:example",
|
|
52
61
|
file: (0, import_utils.myResolve)("../pages/Example/index.tsx")
|
|
53
62
|
}
|
|
54
63
|
];
|
|
@@ -64,8 +73,6 @@ import { ThemeAntVContext } from '${contextFilePath}';
|
|
|
64
73
|
|
|
65
74
|
export default function ThemeAntVContextWrapper() {
|
|
66
75
|
const outlet = useOutlet();
|
|
67
|
-
// const { themeConfig } = useSiteData();
|
|
68
|
-
// const exampleTopics = themeConfig?.examples || [];
|
|
69
76
|
|
|
70
77
|
return (
|
|
71
78
|
<ThemeAntVContext.Provider
|
|
@@ -90,8 +97,8 @@ export default function ThemeAntVContextWrapper() {
|
|
|
90
97
|
pages.forEach((page) => {
|
|
91
98
|
routes[page.id] = {
|
|
92
99
|
id: page.id,
|
|
93
|
-
path: page.
|
|
94
|
-
absPath: page.
|
|
100
|
+
path: page.absPath.slice(1),
|
|
101
|
+
absPath: page.absPath,
|
|
95
102
|
file: page.file,
|
|
96
103
|
parentId: "DocLayout"
|
|
97
104
|
};
|
|
@@ -99,6 +106,7 @@ export default function ThemeAntVContextWrapper() {
|
|
|
99
106
|
routes["404"].file = (0, import_utils.myResolve)("../pages/404.tsx");
|
|
100
107
|
return routes;
|
|
101
108
|
});
|
|
109
|
+
api.addTmpGenerateWatcherPaths(() => [path.resolve(process.cwd(), "examples")]);
|
|
102
110
|
};
|
|
103
111
|
// Annotate the CommonJS export names for ESM import in node:
|
|
104
112
|
0 && (module.exports = {});
|
|
@@ -16,6 +16,7 @@ import { useSiteData, useLocale } from 'dumi';
|
|
|
16
16
|
import { debounce, noop } from 'lodash-es';
|
|
17
17
|
import { replaceInsertCss, execute, compile } from "./utils";
|
|
18
18
|
import { Toolbar, EDITOR_TABS } from "./Toolbar";
|
|
19
|
+
import { Loading } from "../Loading";
|
|
19
20
|
import styles from "./index.module.less";
|
|
20
21
|
loader.config({
|
|
21
22
|
'vs/nls': {
|
|
@@ -85,16 +86,30 @@ export var CodeEditor = function CodeEditor(_ref) {
|
|
|
85
86
|
window.dispatchEvent(e);
|
|
86
87
|
};
|
|
87
88
|
|
|
89
|
+
var reportError = useCallback(function (e) {
|
|
90
|
+
if (e) {
|
|
91
|
+
console.error(e);
|
|
92
|
+
onError(e);
|
|
93
|
+
}
|
|
94
|
+
}, []);
|
|
88
95
|
useEffect(function () {
|
|
89
96
|
// 用于上报错误信息,使用 script 执行代码
|
|
90
97
|
if (typeof window !== 'undefined') {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
98
|
+
// Cath error of code.
|
|
99
|
+
window.__reportErrorInPlayground = reportError; // Catch error of timeout/raf.
|
|
100
|
+
|
|
101
|
+
window.onerror = reportError; // Catch error of promise.
|
|
102
|
+
|
|
103
|
+
window.addEventListener('unhandledrejection', reportError);
|
|
97
104
|
}
|
|
105
|
+
|
|
106
|
+
return function () {
|
|
107
|
+
if (window) {
|
|
108
|
+
window.__reportErrorInPlayground = undefined;
|
|
109
|
+
window.onerror = undefined;
|
|
110
|
+
window.removeEventListener('unhandledrejection', reportError);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
98
113
|
});
|
|
99
114
|
var executeCode = useCallback(debounce(function (v) {
|
|
100
115
|
if (!v) return; // 1. 先编译代码
|
|
@@ -149,6 +164,11 @@ export var CodeEditor = function CodeEditor(_ref) {
|
|
|
149
164
|
});
|
|
150
165
|
}
|
|
151
166
|
}, []);
|
|
167
|
+
useEffect(function () {
|
|
168
|
+
if (monacoRef.current) {
|
|
169
|
+
monacoRef.current.setValue(currentEditorTab === EDITOR_TABS.JAVASCRIPT ? code : JSON.stringify(data, null, 2));
|
|
170
|
+
}
|
|
171
|
+
}, [currentEditorTab]);
|
|
152
172
|
var onCodeChange = useCallback(function (value) {
|
|
153
173
|
if (currentEditorTab === EDITOR_TABS.JAVASCRIPT) {
|
|
154
174
|
setCode(value);
|
|
@@ -177,9 +197,9 @@ export var CodeEditor = function CodeEditor(_ref) {
|
|
|
177
197
|
}
|
|
178
198
|
}, /*#__PURE__*/React.createElement(MonacoEditor, {
|
|
179
199
|
language: currentEditorTab === EDITOR_TABS.JAVASCRIPT ? 'javascript' : 'json',
|
|
180
|
-
value:
|
|
200
|
+
value: code,
|
|
181
201
|
path: relativePath,
|
|
182
|
-
loading:
|
|
202
|
+
loading: /*#__PURE__*/React.createElement(Loading, null),
|
|
183
203
|
options: {
|
|
184
204
|
readOnly: currentEditorTab === EDITOR_TABS.DATA,
|
|
185
205
|
automaticLayout: true,
|
|
@@ -24,6 +24,6 @@ export var CodePreview = function CodePreview(_ref) {
|
|
|
24
24
|
className: styles.result,
|
|
25
25
|
status: "error",
|
|
26
26
|
title: useT('演示代码报错,请检查'),
|
|
27
|
-
subTitle: /*#__PURE__*/React.createElement("pre", null, error && error.
|
|
27
|
+
subTitle: /*#__PURE__*/React.createElement("pre", null, error && error.toString())
|
|
28
28
|
}) : null));
|
|
29
29
|
};
|
|
@@ -10,24 +10,22 @@
|
|
|
10
10
|
flex-direction: column;
|
|
11
11
|
|
|
12
12
|
.header {
|
|
13
|
-
flex: 0
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
.content {
|
|
17
|
-
width: 100%;
|
|
18
|
-
height: 100%;
|
|
19
16
|
position: relative;
|
|
17
|
+
flex: 1;
|
|
18
|
+
min-height: 0;
|
|
20
19
|
|
|
21
20
|
:global(#playgroundScriptContainer) {
|
|
22
|
-
flex: 1;
|
|
23
21
|
position: relative;
|
|
24
22
|
width: 100%;
|
|
25
23
|
height: 100%;
|
|
26
24
|
|
|
27
25
|
:global(#container) {
|
|
26
|
+
position: relative;
|
|
28
27
|
width: 100%;
|
|
29
28
|
height: 100%;
|
|
30
|
-
position: relative;
|
|
31
29
|
}
|
|
32
30
|
}
|
|
33
31
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ExampleTopic } from '../../types';
|
|
3
3
|
declare type CodeRunnerProps = {
|
|
4
4
|
topic: string;
|
|
5
5
|
example: string;
|
|
6
6
|
demo: string;
|
|
7
|
-
exampleTopics:
|
|
7
|
+
exampleTopics: ExampleTopic[];
|
|
8
|
+
size?: number;
|
|
8
9
|
notFound?: React.Element;
|
|
9
10
|
};
|
|
10
11
|
/**
|
|
@@ -28,6 +28,7 @@ export var CodeRunner = function CodeRunner(_ref) {
|
|
|
28
28
|
topic = _ref.topic,
|
|
29
29
|
example = _ref.example,
|
|
30
30
|
demo = _ref.demo,
|
|
31
|
+
size = _ref.size,
|
|
31
32
|
_ref$notFound = _ref.notFound,
|
|
32
33
|
notFound = _ref$notFound === void 0 ? /*#__PURE__*/React.createElement(NotFound, null) : _ref$notFound;
|
|
33
34
|
var demoInfo = getDemoInfo(exampleTopics, topic, example, demo); // 找不到,啥也别干了,404 页面
|
|
@@ -40,7 +41,8 @@ export var CodeRunner = function CodeRunner(_ref) {
|
|
|
40
41
|
var _useSiteData = useSiteData(),
|
|
41
42
|
themeConfig = _useSiteData.themeConfig;
|
|
42
43
|
|
|
43
|
-
var githubUrl = themeConfig.githubUrl
|
|
44
|
+
var githubUrl = themeConfig.githubUrl,
|
|
45
|
+
playground = themeConfig.playground;
|
|
44
46
|
|
|
45
47
|
var _useState = useState(),
|
|
46
48
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -60,7 +62,7 @@ export var CodeRunner = function CodeRunner(_ref) {
|
|
|
60
62
|
});
|
|
61
63
|
return /*#__PURE__*/React.createElement(SplitPane, {
|
|
62
64
|
split: "vertical",
|
|
63
|
-
defaultSize: "
|
|
65
|
+
defaultSize: "".concat((1 - size) * 100, "%"),
|
|
64
66
|
minSize: 100
|
|
65
67
|
}, /*#__PURE__*/React.createElement(CodePreview, {
|
|
66
68
|
error: error,
|
|
@@ -72,6 +74,6 @@ export var CodeRunner = function CodeRunner(_ref) {
|
|
|
72
74
|
onFullscreen: setFullscreen,
|
|
73
75
|
onDestroy: noop,
|
|
74
76
|
onReady: noop,
|
|
75
|
-
playground:
|
|
77
|
+
playground: playground
|
|
76
78
|
}));
|
|
77
79
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { Demo, ExampleTopic } from '../../types';
|
|
1
2
|
/**
|
|
2
3
|
* 将数据结构转化成 map,便于后续检索的速度
|
|
3
4
|
* @param exampleTopics
|
|
4
5
|
* @returns
|
|
5
6
|
*/
|
|
6
|
-
export declare function getExampleTopicMap(exampleTopics:
|
|
7
|
+
export declare function getExampleTopicMap(exampleTopics: ExampleTopic[]): Map<string, Demo>;
|
|
7
8
|
/**
|
|
8
9
|
* 从 Context 信息中,获取到 Example 相关的信息,用于页面渲染
|
|
9
10
|
*/
|
|
10
|
-
export declare function getDemoInfo(exampleTopics:
|
|
11
|
+
export declare function getDemoInfo(exampleTopics: ExampleTopic[], topic: string, example: string, demo: string): Demo;
|
|
@@ -5,12 +5,12 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
5
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
6
|
|
|
7
7
|
import { map } from 'lodash-es';
|
|
8
|
+
|
|
8
9
|
/**
|
|
9
10
|
* 将数据结构转化成 map,便于后续检索的速度
|
|
10
11
|
* @param exampleTopics
|
|
11
12
|
* @returns
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
14
|
export function getExampleTopicMap(exampleTopics) {
|
|
15
15
|
var exampleTopicMap = new Map();
|
|
16
16
|
map(exampleTopics, function (topic) {
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { Demo, ExampleTopic } from '../../types';
|
|
2
3
|
export interface ExampleSiderProps {
|
|
3
4
|
/**
|
|
4
5
|
* 当前 Example (受控)
|
|
5
6
|
*/
|
|
6
|
-
currentDemo:
|
|
7
|
+
currentDemo: Demo;
|
|
7
8
|
/**
|
|
8
9
|
* 当选中的 Demo 被改变时做些什么
|
|
9
10
|
*/
|
|
10
|
-
onDemoClicked: (demo:
|
|
11
|
+
onDemoClicked: (demo: Demo) => void;
|
|
11
12
|
/**
|
|
12
13
|
* 所有的案例主题
|
|
13
14
|
*/
|
|
14
|
-
exampleTopics:
|
|
15
|
+
exampleTopics: ExampleTopic[];
|
|
15
16
|
showExampleDemoTitle: boolean;
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
@@ -22,8 +22,8 @@ import { useLocale } from 'dumi';
|
|
|
22
22
|
import { createFromIconfontCN, SearchOutlined, VerticalAlignTopOutlined } from '@ant-design/icons';
|
|
23
23
|
import classNames from 'classnames';
|
|
24
24
|
import { useT } from "../hooks";
|
|
25
|
-
import
|
|
26
|
-
import
|
|
25
|
+
import { filterTreeNode } from "../utils";
|
|
26
|
+
import styles from "./index.module.less"; // menu icon
|
|
27
27
|
|
|
28
28
|
var MenuIcon = createFromIconfontCN({
|
|
29
29
|
scriptUrl: '//at.alicdn.com/t/font_470089_1lnym745udm.js' // generated by iconfont.cn
|
|
@@ -26,19 +26,23 @@ export var Navs = function Navs(_ref) {
|
|
|
26
26
|
var locale = useLocale();
|
|
27
27
|
return /*#__PURE__*/React.createElement(React.Fragment, null, navs.map(function (nav) {
|
|
28
28
|
var href = nav.slug.startsWith('http') ? nav.slug : "/".concat(nav.slug);
|
|
29
|
+
var isAnotherSite = nav.slug.startsWith('http');
|
|
30
|
+
var anotherSite = isAnotherSite ? href : '';
|
|
29
31
|
var title = getDocument(navs, nav.slug).title[locale.id];
|
|
30
32
|
href = nav.slug.startsWith('/') ? nav.slug : "/".concat(nav.slug);
|
|
31
33
|
|
|
32
|
-
if (
|
|
34
|
+
if (locale.id == 'en') {
|
|
33
35
|
href = "/en".concat(href);
|
|
34
|
-
}
|
|
36
|
+
} // 去除 docs 防止二次点击相同nav跳转出现04
|
|
35
37
|
|
|
38
|
+
|
|
39
|
+
href = href.replace('/docs/', '/');
|
|
36
40
|
var className = cx('header-menu-item-active', _defineProperty({}, styles.activeItem, path.startsWith(href) || isEqual(path.split('/').slice(0, 4), href.split('/').slice(0, 4))));
|
|
37
41
|
return /*#__PURE__*/React.createElement("li", {
|
|
38
42
|
key: title,
|
|
39
43
|
className: className
|
|
40
|
-
}, nav.target === '_blank' ||
|
|
41
|
-
href:
|
|
44
|
+
}, nav.target === '_blank' || isAnotherSite ? /*#__PURE__*/React.createElement("a", {
|
|
45
|
+
href: anotherSite,
|
|
42
46
|
target: "_blank",
|
|
43
47
|
rel: "noreferrer"
|
|
44
48
|
}, title, /*#__PURE__*/React.createElement(LinkOutlined, null)) : /*#__PURE__*/React.createElement(Link, {
|
|
@@ -22,7 +22,7 @@ import { useMedia } from 'react-use';
|
|
|
22
22
|
import { useNavigate } from "react-router-dom";
|
|
23
23
|
import cx from 'classnames';
|
|
24
24
|
import { useSiteData, useLocale } from 'dumi';
|
|
25
|
-
import { GithubOutlined, MenuOutlined, CaretDownFilled, DownOutlined, WechatOutlined,
|
|
25
|
+
import { GithubOutlined, MenuOutlined, CaretDownFilled, DownOutlined, WechatOutlined, LinkOutlined, CheckOutlined } from '@ant-design/icons';
|
|
26
26
|
import { Popover, Menu, Dropdown, Select } from 'antd';
|
|
27
27
|
import { map, size } from 'lodash-es';
|
|
28
28
|
import { Search } from "./Search";
|
|
@@ -173,12 +173,12 @@ var HeaderComponent = function HeaderComponent(_ref) {
|
|
|
173
173
|
className: cx(styles.menu, (_cx = {}, _defineProperty(_cx, styles.popup, !isWide), _defineProperty(_cx, styles.popupHidden, !popupMenuVisible), _cx))
|
|
174
174
|
},
|
|
175
175
|
/** 最左侧的菜单,一般是 教程、API、示例,或者其他自定义,有配置文件中的 `navs` 决定 */
|
|
176
|
-
size(navs)
|
|
176
|
+
size(navs) ? /*#__PURE__*/React.createElement(Navs, {
|
|
177
177
|
navs: navs,
|
|
178
178
|
path: window.location.pathname
|
|
179
|
-
}),
|
|
179
|
+
}) : null,
|
|
180
180
|
/** 生态产品 */
|
|
181
|
-
size(ecosystems)
|
|
181
|
+
size(ecosystems) ? /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement(Dropdown, {
|
|
182
182
|
className: styles.ecoSystems,
|
|
183
183
|
overlay: /*#__PURE__*/React.createElement(Menu, null, map(ecosystems, function (_ref2) {
|
|
184
184
|
var url = _ref2.url,
|
|
@@ -189,13 +189,13 @@ var HeaderComponent = function HeaderComponent(_ref) {
|
|
|
189
189
|
target: "_blank",
|
|
190
190
|
rel: "noreferrer",
|
|
191
191
|
href: url
|
|
192
|
-
}, ecosystemName === null || ecosystemName === void 0 ? void 0 : ecosystemName[lang], " ", /*#__PURE__*/React.createElement(
|
|
192
|
+
}, ecosystemName === null || ecosystemName === void 0 ? void 0 : ecosystemName[lang], " ", /*#__PURE__*/React.createElement(LinkOutlined, null)));
|
|
193
193
|
}))
|
|
194
194
|
}, /*#__PURE__*/React.createElement("span", null, useT('周边生态'), /*#__PURE__*/React.createElement(DownOutlined, {
|
|
195
195
|
style: {
|
|
196
196
|
marginLeft: '6px'
|
|
197
197
|
}
|
|
198
|
-
})))),
|
|
198
|
+
})))) : null,
|
|
199
199
|
/** 产品列表 */
|
|
200
200
|
showAntVProductsCard && /*#__PURE__*/React.createElement("li", productItemProps, /*#__PURE__*/React.createElement("a", null, useT('所有产品'), !isAntVHome ? /*#__PURE__*/React.createElement("img", {
|
|
201
201
|
src: "https://gw.alipayobjects.com/zos/antfincdn/FLrTNDvlna/antv.png",
|