@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.
- package/dist/builtins/Playground/index.d.ts +3 -6
- package/dist/builtins/Playground/index.js +27 -7
- package/dist/layouts/DocLayout.js +4 -5
- package/dist/layouts/entry/Index.js +21 -12
- package/dist/layouts/entry/Manual.js +6 -4
- package/dist/pages/404.js +7 -4
- package/dist/pages/Example/index.js +15 -4
- package/dist/pages/Example/utils.d.ts +1 -0
- package/dist/pages/Example/utils.js +9 -0
- package/dist/pages/Examples/components/ExampleTopicMenu/components/LeftMenu/index.js +2 -1
- package/dist/pages/Examples/components/GalleryPageContent/DemoCard/index.js +10 -5
- package/dist/pages/Examples/components/GalleryPageContent/index.js +2 -1
- package/dist/pages/Examples/index.js +13 -4
- package/dist/pages/Examples/index.module.less +13 -0
- package/dist/pages/Examples/utils.d.ts +1 -0
- package/dist/pages/Examples/utils.js +3 -0
- package/dist/plugin/index.js +11 -0
- package/dist/slots/Article/index.d.ts +3 -0
- package/dist/slots/Article/index.js +11 -0
- package/dist/slots/Article/index.module.less +8 -0
- package/dist/slots/Banner/Notification.d.ts +10 -0
- package/dist/slots/Banner/Notification.js +43 -0
- package/dist/slots/Banner/Notification.module.less +120 -0
- package/dist/slots/Banner/index.d.ts +26 -0
- package/dist/slots/Banner/index.js +184 -0
- package/dist/slots/Banner/index.module.less +449 -0
- package/dist/slots/Cases/index.d.ts +1 -1
- package/dist/slots/Cases/index.js +13 -7
- package/dist/slots/Cases/index.module.less +2 -1
- package/dist/slots/CodeEditor/Toolbar.js +13 -6
- package/dist/slots/CodeEditor/index.d.ts +4 -0
- package/dist/slots/CodeEditor/index.js +43 -21
- package/dist/slots/CodeEditor/utils.js +1 -1
- package/dist/slots/CodePreview/CodeHeader.js +15 -14
- package/dist/slots/CodePreview/index.d.ts +8 -0
- package/dist/slots/CodePreview/index.js +15 -6
- package/dist/slots/CodePreview/index.module.less +11 -2
- package/dist/slots/CodeRunner/index.d.ts +2 -0
- package/dist/slots/CodeRunner/index.js +13 -5
- package/dist/slots/Companies/index.d.ts +1 -1
- package/dist/slots/{TOC.d.ts → ContentTable/index.d.ts} +2 -1
- package/dist/slots/{TOC.js → ContentTable/index.js} +2 -1
- package/dist/slots/ContentTable/index.module.less +11 -0
- package/dist/slots/Detail/News.js +3 -2
- package/dist/slots/Detail/index.js +3 -1
- package/dist/slots/ExampleSider/index.js +21 -20
- package/dist/slots/Features/index.js +5 -2
- package/dist/slots/Features/index.module.less +3 -3
- package/dist/slots/Footer/index.js +34 -14
- package/dist/slots/Header/LogoWhite.js +1 -2
- package/dist/slots/Header/Navs.d.ts +10 -1
- package/dist/slots/Header/Navs.js +36 -25
- package/dist/slots/Header/Products/NavigatorBanner.js +4 -3
- package/dist/slots/Header/Products/Product.js +7 -3
- package/dist/slots/Header/Products/getProducts.js +4 -2
- package/dist/slots/Header/Products/index.js +5 -3
- package/dist/slots/Header/Search.js +5 -3
- package/dist/slots/Header/index.d.ts +7 -2
- package/dist/slots/Header/index.js +128 -24
- package/dist/slots/ManualContent/NavigatorBanner.js +5 -3
- package/dist/slots/ManualContent/ReadingTime.js +6 -2
- package/dist/slots/ManualContent/index.js +36 -30
- package/dist/slots/ManualContent/index.module.less +52 -33
- package/dist/slots/ManualContent/utils.d.ts +15 -0
- package/dist/slots/ManualContent/utils.js +30 -1
- package/dist/slots/SEO.d.ts +10 -0
- package/dist/slots/SEO.js +59 -0
- package/dist/slots/_.less +1 -1
- package/dist/slots/hooks.d.ts +1 -1
- package/dist/slots/hooks.js +5 -8
- package/dist/slots/utils.js +6 -1
- package/package.json +5 -2
|
@@ -2,12 +2,13 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
2
2
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { ArrowLeftOutlined, ArrowRightOutlined } from '@ant-design/icons';
|
|
5
|
-
import { Link } from 'dumi';
|
|
5
|
+
import { Link, FormattedMessage } from 'dumi';
|
|
6
6
|
import Slider from 'react-slick';
|
|
7
7
|
import cx from 'classnames';
|
|
8
|
+
import { useLocale } from 'dumi';
|
|
9
|
+
import { ic, icWithLocale } from "../hooks";
|
|
8
10
|
import 'slick-carousel/slick/slick.css';
|
|
9
11
|
import 'slick-carousel/slick/slick-theme.css';
|
|
10
|
-
import { useT, ic } from "../hooks";
|
|
11
12
|
import styles from "./index.module.less";
|
|
12
13
|
export var Cases = function Cases(_ref) {
|
|
13
14
|
var _ref$cases = _ref.cases,
|
|
@@ -15,6 +16,7 @@ export var Cases = function Cases(_ref) {
|
|
|
15
16
|
_ref$style = _ref.style,
|
|
16
17
|
style = _ref$style === void 0 ? {} : _ref$style,
|
|
17
18
|
className = _ref.className;
|
|
19
|
+
var lang = useLocale().id;
|
|
18
20
|
var slider = React.useRef(null);
|
|
19
21
|
|
|
20
22
|
var clickPrevious = function clickPrevious() {
|
|
@@ -68,15 +70,19 @@ export var Cases = function Cases(_ref) {
|
|
|
68
70
|
href: app.link,
|
|
69
71
|
target: "_blank",
|
|
70
72
|
rel: "noopener noreferrer"
|
|
71
|
-
},
|
|
73
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
74
|
+
id: "\u67E5\u770B\u8BE6\u60C5"
|
|
75
|
+
})) : /*#__PURE__*/React.createElement(Link, {
|
|
72
76
|
className: styles.detail,
|
|
73
|
-
to: app.link
|
|
74
|
-
},
|
|
77
|
+
to: icWithLocale(app.link, lang) || ''
|
|
78
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
79
|
+
id: "\u67E5\u770B\u8BE6\u60C5"
|
|
80
|
+
})));
|
|
75
81
|
return /*#__PURE__*/React.createElement("div", {
|
|
76
82
|
className: styles.appWrapper,
|
|
77
83
|
key: ic(app.title)
|
|
78
84
|
}, /*#__PURE__*/React.createElement("img", {
|
|
79
|
-
className: styles.appTeaser,
|
|
85
|
+
className: cx(styles.appTeaser, 'index-cases-image'),
|
|
80
86
|
src: app.image,
|
|
81
87
|
alt: ic(app.title)
|
|
82
88
|
}), /*#__PURE__*/React.createElement("div", {
|
|
@@ -84,7 +90,7 @@ export var Cases = function Cases(_ref) {
|
|
|
84
90
|
}, /*#__PURE__*/React.createElement("div", {
|
|
85
91
|
className: styles.appContent
|
|
86
92
|
}, /*#__PURE__*/React.createElement("img", {
|
|
87
|
-
className: styles.appLogo,
|
|
93
|
+
className: cx(styles.appLogo, 'index-case-logo'),
|
|
88
94
|
src: app.logo,
|
|
89
95
|
alt: "logo",
|
|
90
96
|
style: {
|
|
@@ -21,12 +21,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
21
21
|
import React, { useEffect, useState } from 'react';
|
|
22
22
|
import { CodeSandboxOutlined, PlayCircleOutlined, ThunderboltOutlined } from '@ant-design/icons';
|
|
23
23
|
import { Typography, Tooltip } from 'antd';
|
|
24
|
-
import { useLocale } from 'dumi';
|
|
24
|
+
import { useLocale, FormattedMessage } from 'dumi';
|
|
25
25
|
import { getParameters } from 'codesandbox/lib/api/define';
|
|
26
26
|
import stackblitzSdk from '@stackblitz/sdk';
|
|
27
27
|
import { ping } from "../utils";
|
|
28
28
|
import { extractImportDeps, getCodeSandboxConfig, getStackblitzConfig, getRiddleConfig } from "./utils";
|
|
29
|
-
import { useT } from "../hooks";
|
|
30
29
|
import styles from "./Toolbar.module.less";
|
|
31
30
|
var Paragraph = Typography.Paragraph;
|
|
32
31
|
export var EDITOR_TABS;
|
|
@@ -93,20 +92,26 @@ export var Toolbar = function Toolbar(_ref) {
|
|
|
93
92
|
name: "data",
|
|
94
93
|
value: JSON.stringify(riddlePrefillConfig)
|
|
95
94
|
}), /*#__PURE__*/React.createElement(Tooltip, {
|
|
96
|
-
title:
|
|
95
|
+
title: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
96
|
+
id: "\u5728 Riddle \u4E2D\u6253\u5F00"
|
|
97
|
+
})
|
|
97
98
|
}, /*#__PURE__*/React.createElement("input", {
|
|
98
99
|
type: "submit",
|
|
99
100
|
value: "Create New Riddle with Prefilled Data",
|
|
100
101
|
className: styles.riddle
|
|
101
102
|
}))) : null, /*#__PURE__*/React.createElement(Tooltip, {
|
|
102
|
-
title:
|
|
103
|
+
title: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
104
|
+
id: "\u5728 StackBlitz \u4E2D\u6253\u5F00"
|
|
105
|
+
})
|
|
103
106
|
}, /*#__PURE__*/React.createElement(ThunderboltOutlined, {
|
|
104
107
|
className: styles.stackblitz,
|
|
105
108
|
onClick: function onClick() {
|
|
106
109
|
stackblitzSdk.openProject(stackblitzPrefillConfig);
|
|
107
110
|
}
|
|
108
111
|
})), /*#__PURE__*/React.createElement(Tooltip, {
|
|
109
|
-
title:
|
|
112
|
+
title: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
113
|
+
id: "\u5728 CodeSandbox \u4E2D\u6253\u5F00"
|
|
114
|
+
})
|
|
110
115
|
}, /*#__PURE__*/React.createElement("form", {
|
|
111
116
|
action: "https://codesandbox.io/api/v1/sandboxes/define",
|
|
112
117
|
method: "POST",
|
|
@@ -130,7 +135,9 @@ export var Toolbar = function Toolbar(_ref) {
|
|
|
130
135
|
marginLeft: 6
|
|
131
136
|
}
|
|
132
137
|
}), /*#__PURE__*/React.createElement(Tooltip, {
|
|
133
|
-
title:
|
|
138
|
+
title: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
139
|
+
id: "\u6267\u884C\u4EE3\u7801"
|
|
140
|
+
})
|
|
134
141
|
}, /*#__PURE__*/React.createElement(PlayCircleOutlined, {
|
|
135
142
|
onClick: onExecuteCode,
|
|
136
143
|
style: {
|
|
@@ -17,7 +17,7 @@ import { debounce, noop } from 'lodash-es';
|
|
|
17
17
|
import { bind, clear } from 'size-sensor';
|
|
18
18
|
import { replaceInsertCss, execute, compile } from "./utils";
|
|
19
19
|
import { Toolbar, EDITOR_TABS } from "./Toolbar";
|
|
20
|
-
import { Loading } from "
|
|
20
|
+
import { Loading } from "dumi/theme/slots/Loading";
|
|
21
21
|
import styles from "./index.module.less";
|
|
22
22
|
loader.config({
|
|
23
23
|
'vs/nls': {
|
|
@@ -43,6 +43,7 @@ export var CodeEditor = function CodeEditor(_ref) {
|
|
|
43
43
|
_ref$replaceId = _ref.replaceId,
|
|
44
44
|
replaceId = _ref$replaceId === void 0 ? 'container' : _ref$replaceId,
|
|
45
45
|
isFullscreen = _ref.isFullscreen,
|
|
46
|
+
exampleId = _ref.exampleId,
|
|
46
47
|
_ref$onReady = _ref.onReady,
|
|
47
48
|
onReady = _ref$onReady === void 0 ? noop : _ref$onReady,
|
|
48
49
|
_ref$onDestroy = _ref.onDestroy,
|
|
@@ -79,8 +80,9 @@ export var CodeEditor = function CodeEditor(_ref) {
|
|
|
79
80
|
var _useState7 = useState(EDITOR_TABS.JAVASCRIPT),
|
|
80
81
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
81
82
|
currentEditorTab = _useState8[0],
|
|
82
|
-
setCurrentEditorTab = _useState8[1];
|
|
83
|
+
setCurrentEditorTab = _useState8[1];
|
|
83
84
|
|
|
85
|
+
var containerId = "playgroundScriptContainer_".concat(exampleId); // 出发 auto resize
|
|
84
86
|
|
|
85
87
|
var dispatchResizeEvent = function dispatchResizeEvent() {
|
|
86
88
|
var e = new Event('resize');
|
|
@@ -116,6 +118,7 @@ export var CodeEditor = function CodeEditor(_ref) {
|
|
|
116
118
|
};
|
|
117
119
|
}, []);
|
|
118
120
|
var executeCode = useCallback(debounce(function (v) {
|
|
121
|
+
if (currentEditorTab !== EDITOR_TABS.JAVASCRIPT) return;
|
|
119
122
|
if (!v) return; // 1. 先编译代码
|
|
120
123
|
|
|
121
124
|
var compiled;
|
|
@@ -129,19 +132,31 @@ export var CodeEditor = function CodeEditor(_ref) {
|
|
|
129
132
|
} // 2. 执行代码,try catch 在内部已经做了
|
|
130
133
|
|
|
131
134
|
|
|
132
|
-
execute(compiled,
|
|
133
|
-
}, 300), []);
|
|
135
|
+
execute(compiled, containerId, playground === null || playground === void 0 ? void 0 : playground.container, replaceId);
|
|
136
|
+
}, 300), [exampleId, currentEditorTab]); // 案例变化的时候,修改期待吗
|
|
137
|
+
|
|
134
138
|
useEffect(function () {
|
|
135
139
|
setCode(source);
|
|
136
|
-
}, [
|
|
140
|
+
}, [exampleId]); // 代码变化的时候,运行代码
|
|
141
|
+
|
|
137
142
|
useEffect(function () {
|
|
138
143
|
executeCode(code);
|
|
139
144
|
}, [code]);
|
|
140
145
|
useEffect(function () {
|
|
141
|
-
var dom = document.getElementById(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
146
|
+
var dom = document.getElementById(containerId);
|
|
147
|
+
|
|
148
|
+
if (dom) {
|
|
149
|
+
bind(dom, debounce(function () {
|
|
150
|
+
dispatchResizeEvent();
|
|
151
|
+
}, 100));
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return function () {
|
|
155
|
+
dom && clear(dom);
|
|
156
|
+
};
|
|
157
|
+
}, []); // 生命周期
|
|
158
|
+
|
|
159
|
+
useEffect(function () {
|
|
145
160
|
onReady();
|
|
146
161
|
|
|
147
162
|
if (playground !== null && playground !== void 0 && playground.playgroundDidMount) {
|
|
@@ -149,7 +164,6 @@ export var CodeEditor = function CodeEditor(_ref) {
|
|
|
149
164
|
}
|
|
150
165
|
|
|
151
166
|
return function () {
|
|
152
|
-
clear(dom);
|
|
153
167
|
onDestroy();
|
|
154
168
|
|
|
155
169
|
if (playground !== null && playground !== void 0 && playground.playgroundWillUnmount) {
|
|
@@ -168,18 +182,25 @@ export var CodeEditor = function CodeEditor(_ref) {
|
|
|
168
182
|
setEditorTabs([EDITOR_TABS.JAVASCRIPT, EDITOR_TABS.DATA]);
|
|
169
183
|
setData(data);
|
|
170
184
|
});
|
|
185
|
+
} else {
|
|
186
|
+
setEditorTabs([EDITOR_TABS.JAVASCRIPT]);
|
|
171
187
|
}
|
|
172
|
-
}, []);
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
188
|
+
}, [exampleId]); // 切换 tab
|
|
189
|
+
|
|
190
|
+
var onTabChange = useCallback(function (tab) {
|
|
191
|
+
setCurrentEditorTab(tab);
|
|
192
|
+
}, [exampleId]); // useEffect(() => {
|
|
193
|
+
// if (monacoRef.current) {
|
|
194
|
+
// const v = currentEditorTab === EDITOR_TABS.JAVASCRIPT ? code : JSON.stringify(data, null, 2);
|
|
195
|
+
// monacoRef.current.setValue(v);
|
|
196
|
+
// }
|
|
197
|
+
// }, [currentEditorTab]);
|
|
198
|
+
|
|
199
|
+
var onCodeChange = useCallback(function (value, event) {
|
|
200
|
+
if (!event.isFlush && currentEditorTab === EDITOR_TABS.JAVASCRIPT) {
|
|
180
201
|
setCode(value);
|
|
181
202
|
}
|
|
182
|
-
}, []);
|
|
203
|
+
}, [currentEditorTab]);
|
|
183
204
|
return /*#__PURE__*/React.createElement("div", {
|
|
184
205
|
className: styles.editor
|
|
185
206
|
}, /*#__PURE__*/React.createElement(Toolbar, {
|
|
@@ -194,7 +215,7 @@ export var CodeEditor = function CodeEditor(_ref) {
|
|
|
194
215
|
onExecuteCode: function onExecuteCode() {
|
|
195
216
|
return executeCode(code);
|
|
196
217
|
},
|
|
197
|
-
onEditorTabChange:
|
|
218
|
+
onEditorTabChange: onTabChange,
|
|
198
219
|
onToggleFullscreen: onFullscreen
|
|
199
220
|
}), /*#__PURE__*/React.createElement("div", {
|
|
200
221
|
className: styles.monaco,
|
|
@@ -203,7 +224,8 @@ export var CodeEditor = function CodeEditor(_ref) {
|
|
|
203
224
|
}
|
|
204
225
|
}, /*#__PURE__*/React.createElement(MonacoEditor, {
|
|
205
226
|
language: currentEditorTab === EDITOR_TABS.JAVASCRIPT ? 'javascript' : 'json',
|
|
206
|
-
value: code,
|
|
227
|
+
value: currentEditorTab === EDITOR_TABS.JAVASCRIPT ? code : JSON.stringify(data, null, 2) // defaultValue={code}
|
|
228
|
+
,
|
|
207
229
|
path: relativePath,
|
|
208
230
|
loading: /*#__PURE__*/React.createElement(Loading, null),
|
|
209
231
|
options: {
|
|
@@ -137,7 +137,7 @@ export function execute(code, playgroundScriptContainer, container) {
|
|
|
137
137
|
var newCode = code.replace(/'container'|"container"/, "'".concat(replaceId, "'"));
|
|
138
138
|
script.innerHTML = "\n// Can only have one anonymous define call per script file\n// \u548C monaco loader \u52A0\u8F7D\u51B2\u7A81\nvar __runnerDefine = window['define'];\nwindow['define'] = null;\ntry {\n ".concat(newCode, "\n\n // \u6E05\u9664\u663E\u793A\u7684\u9519\u8BEF\n window.__reportErrorInPlayground && window.__reportErrorInPlayground(null);\n} catch(e) {\n window.__reportErrorInPlayground && window.__reportErrorInPlayground(e);\n} finally {\n window['define'] = __runnerDefine;\n}\n "); // 追加图表容器
|
|
139
139
|
|
|
140
|
-
node.innerHTML = container || "<div id=".concat(replaceId, " />"); // 运行 script
|
|
140
|
+
node.innerHTML = container || "<div id=".concat(replaceId, " class=\"playgroundCodeContainer\" />"); // 运行 script
|
|
141
141
|
|
|
142
142
|
node.appendChild(script);
|
|
143
143
|
}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { PageHeader,
|
|
3
|
-
import { EditOutlined } from '@ant-design/icons';
|
|
4
|
-
import { useT } from "../hooks";
|
|
5
|
-
import { getGithubSourceURL } from "../utils";
|
|
6
|
-
import styles from "./CodeHeader.module.less";
|
|
2
|
+
import { PageHeader, Space, Divider } from 'antd';
|
|
7
3
|
|
|
8
4
|
/**
|
|
9
5
|
* 组件的 header
|
|
@@ -14,15 +10,20 @@ export var CodeHeader = function CodeHeader(_ref) {
|
|
|
14
10
|
githubUrl = _ref.githubUrl;
|
|
15
11
|
return /*#__PURE__*/React.createElement(PageHeader, {
|
|
16
12
|
ghost: false,
|
|
17
|
-
title: title
|
|
18
|
-
subTitle
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
title: title // todo 编辑地址各种各样,需要有单独的配置,暂时关闭!
|
|
14
|
+
// subTitle={
|
|
15
|
+
// <Tooltip title={<FormattedMessage id="在 GitHub 上编辑" />}>
|
|
16
|
+
// <a
|
|
17
|
+
// href={getGithubSourceURL(githubUrl, relativePath, 'examples')}
|
|
18
|
+
// target="_blank"
|
|
19
|
+
// rel="noopener noreferrer"
|
|
20
|
+
// className={styles.editOnGtiHubButton}
|
|
21
|
+
// >
|
|
22
|
+
// <EditOutlined />
|
|
23
|
+
// </a>
|
|
24
|
+
// </Tooltip>
|
|
25
|
+
// }
|
|
26
|
+
,
|
|
26
27
|
extra: /*#__PURE__*/React.createElement(Space, {
|
|
27
28
|
split: /*#__PURE__*/React.createElement(Divider, {
|
|
28
29
|
type: "vertical"
|
|
@@ -1,29 +1,38 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Result } from 'antd';
|
|
3
|
-
import {
|
|
3
|
+
import { FormattedMessage } from 'dumi';
|
|
4
4
|
import styles from "./index.module.less";
|
|
5
5
|
|
|
6
|
+
function getErrorMessage(e) {
|
|
7
|
+
return (e.reason ? e.reason : e.message ? e.message : e).toString();
|
|
8
|
+
}
|
|
6
9
|
/**
|
|
7
10
|
* DEMO 预览页面的预览,主要包含有:
|
|
8
11
|
* 1. 一些 header 菜单
|
|
9
12
|
* 2. 错误预览
|
|
10
13
|
*/
|
|
14
|
+
|
|
15
|
+
|
|
11
16
|
export var CodePreview = function CodePreview(_ref) {
|
|
12
|
-
var
|
|
17
|
+
var isPlayground = _ref.isPlayground,
|
|
18
|
+
exampleId = _ref.exampleId,
|
|
19
|
+
header = _ref.header,
|
|
13
20
|
error = _ref.error;
|
|
14
21
|
return /*#__PURE__*/React.createElement("div", {
|
|
15
22
|
className: styles.preview
|
|
16
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
23
|
+
}, isPlayground ? null : /*#__PURE__*/React.createElement("div", {
|
|
17
24
|
className: styles.header
|
|
18
25
|
}, header), /*#__PURE__*/React.createElement("div", {
|
|
19
26
|
className: styles.content
|
|
20
27
|
}, /*#__PURE__*/React.createElement("div", {
|
|
21
|
-
id: "
|
|
28
|
+
id: "playgroundScriptContainer_".concat(exampleId),
|
|
22
29
|
className: styles.playgroundScriptContainer
|
|
23
30
|
}), error ? /*#__PURE__*/React.createElement(Result, {
|
|
24
31
|
className: styles.result,
|
|
25
32
|
status: "error",
|
|
26
|
-
title:
|
|
27
|
-
|
|
33
|
+
title: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
34
|
+
id: "\u6F14\u793A\u4EE3\u7801\u62A5\u9519\uFF0C\u8BF7\u68C0\u67E5"
|
|
35
|
+
}),
|
|
36
|
+
subTitle: /*#__PURE__*/React.createElement("pre", null, getErrorMessage(error))
|
|
28
37
|
}) : null));
|
|
29
38
|
};
|
|
@@ -3,13 +3,16 @@
|
|
|
3
3
|
height: 100%;
|
|
4
4
|
position: relative;
|
|
5
5
|
|
|
6
|
-
padding:
|
|
6
|
+
padding: 24px;
|
|
7
7
|
overflow: auto;
|
|
8
8
|
|
|
9
9
|
display: flex;
|
|
10
10
|
flex-direction: column;
|
|
11
11
|
|
|
12
12
|
.header {
|
|
13
|
+
:global(.ant-page-header) {
|
|
14
|
+
padding-left: 0;
|
|
15
|
+
}
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
.content {
|
|
@@ -17,11 +20,17 @@
|
|
|
17
20
|
flex: 1;
|
|
18
21
|
min-height: 0;
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
.playgroundScriptContainer, .playgroundCodeContainer {
|
|
21
24
|
position: relative;
|
|
22
25
|
width: 100%;
|
|
23
26
|
height: 100%;
|
|
24
27
|
|
|
28
|
+
:global(.playgroundCodeContainer) {
|
|
29
|
+
position: relative;
|
|
30
|
+
width: 100%;
|
|
31
|
+
height: 100%;
|
|
32
|
+
}
|
|
33
|
+
|
|
25
34
|
:global(#container) {
|
|
26
35
|
position: relative;
|
|
27
36
|
width: 100%;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ExampleTopic } from '../../types';
|
|
3
3
|
declare type CodeRunnerProps = {
|
|
4
|
+
isPlayground?: boolean;
|
|
4
5
|
topic: string;
|
|
5
6
|
example: string;
|
|
6
7
|
demo: string;
|
|
7
8
|
exampleTopics: ExampleTopic[];
|
|
8
9
|
size?: number;
|
|
10
|
+
replaceId?: string;
|
|
9
11
|
notFound?: React.Element;
|
|
10
12
|
};
|
|
11
13
|
/**
|
|
@@ -14,11 +14,12 @@ import React, { useState } from 'react';
|
|
|
14
14
|
import { useSiteData, useLocale } from 'dumi';
|
|
15
15
|
import { noop } from 'lodash-es';
|
|
16
16
|
import SplitPane from 'react-split-pane';
|
|
17
|
-
import { CodeEditor } from "
|
|
18
|
-
import { CodePreview } from "
|
|
17
|
+
import { CodeEditor } from "dumi/theme/slots/CodeEditor";
|
|
18
|
+
import { CodePreview } from "dumi/theme/slots/CodePreview";
|
|
19
19
|
import { CodeHeader } from "../CodePreview/CodeHeader";
|
|
20
20
|
import { getDemoInfo } from "./utils";
|
|
21
|
-
import { NotFound } from "
|
|
21
|
+
import { NotFound } from "dumi/theme/slots/404";
|
|
22
|
+
import { ic } from "../hooks";
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* 代码编辑器 + 代码预览区域
|
|
@@ -29,6 +30,8 @@ export var CodeRunner = function CodeRunner(_ref) {
|
|
|
29
30
|
example = _ref.example,
|
|
30
31
|
demo = _ref.demo,
|
|
31
32
|
size = _ref.size,
|
|
33
|
+
replaceId = _ref.replaceId,
|
|
34
|
+
isPlayground = _ref.isPlayground,
|
|
32
35
|
_ref$notFound = _ref.notFound,
|
|
33
36
|
notFound = _ref$notFound === void 0 ? /*#__PURE__*/React.createElement(NotFound, null) : _ref$notFound;
|
|
34
37
|
var demoInfo = getDemoInfo(exampleTopics, topic, example, demo); // 找不到,啥也别干了,404 页面
|
|
@@ -56,20 +59,25 @@ export var CodeRunner = function CodeRunner(_ref) {
|
|
|
56
59
|
|
|
57
60
|
var locale = useLocale();
|
|
58
61
|
var header = /*#__PURE__*/React.createElement(CodeHeader, {
|
|
59
|
-
title: title
|
|
62
|
+
title: ic(title),
|
|
60
63
|
relativePath: relativePath,
|
|
61
64
|
githubUrl: githubUrl
|
|
62
65
|
});
|
|
66
|
+
var exampleId = "".concat(topic, "_").concat(example, "_").concat(demo);
|
|
63
67
|
return /*#__PURE__*/React.createElement(SplitPane, {
|
|
64
68
|
split: "vertical",
|
|
65
69
|
defaultSize: "".concat((1 - size) * 100, "%"),
|
|
66
70
|
minSize: 100
|
|
67
71
|
}, /*#__PURE__*/React.createElement(CodePreview, {
|
|
72
|
+
exampleId: exampleId,
|
|
68
73
|
error: error,
|
|
69
|
-
header: header
|
|
74
|
+
header: header,
|
|
75
|
+
isPlayground: isPlayground
|
|
70
76
|
}), /*#__PURE__*/React.createElement(CodeEditor, {
|
|
77
|
+
exampleId: exampleId,
|
|
71
78
|
source: source,
|
|
72
79
|
relativePath: relativePath,
|
|
80
|
+
replaceId: replaceId,
|
|
73
81
|
onError: setError,
|
|
74
82
|
onFullscreen: setFullscreen,
|
|
75
83
|
onDestroy: noop,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Link } from 'dumi';
|
|
2
|
+
import { Link, useLocale } from 'dumi';
|
|
3
3
|
import { ic } from "../hooks";
|
|
4
4
|
import styles from "./News.module.less";
|
|
5
5
|
var numberImages = ['https://gw.alipayobjects.com/zos/antfincdn/IqREAm36K7/1.png', 'https://gw.alipayobjects.com/zos/antfincdn/3fG1Iqjfnz/2.png'];
|
|
@@ -11,6 +11,7 @@ export var News = function News(_ref) {
|
|
|
11
11
|
date = _ref.date,
|
|
12
12
|
_ref$link = _ref.link,
|
|
13
13
|
link = _ref$link === void 0 ? '' : _ref$link;
|
|
14
|
+
var lang = useLocale().id;
|
|
14
15
|
var children = /*#__PURE__*/React.createElement("div", {
|
|
15
16
|
className: styles.container
|
|
16
17
|
}, /*#__PURE__*/React.createElement("img", {
|
|
@@ -35,7 +36,7 @@ export var News = function News(_ref) {
|
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
return /*#__PURE__*/React.createElement(Link, {
|
|
38
|
-
to: link,
|
|
39
|
+
to: link[lang] ? link[lang] : link,
|
|
39
40
|
className: styles.news
|
|
40
41
|
}, children);
|
|
41
42
|
};
|
|
@@ -22,6 +22,7 @@ import React, { useState, useEffect } from 'react';
|
|
|
22
22
|
import cx from 'classnames';
|
|
23
23
|
import gh from 'parse-github-url';
|
|
24
24
|
import GitHubButton from 'react-github-button';
|
|
25
|
+
import { useLocale } from 'dumi/dist/client/theme-api';
|
|
25
26
|
import { ic } from "../hooks";
|
|
26
27
|
import { News } from "./News";
|
|
27
28
|
import styles from "./index.module.less";
|
|
@@ -50,6 +51,7 @@ export var Detail = function Detail(_ref) {
|
|
|
50
51
|
removeNews = _useState2[0],
|
|
51
52
|
setRemoteNews = _useState2[1];
|
|
52
53
|
|
|
54
|
+
var lang = useLocale().id;
|
|
53
55
|
useEffect(function () {
|
|
54
56
|
fetch(AssetsNewsURL).then(function (res) {
|
|
55
57
|
return res.json();
|
|
@@ -86,7 +88,7 @@ export var Detail = function Detail(_ref) {
|
|
|
86
88
|
style: _objectSpread({
|
|
87
89
|
borderRadius: shape === 'square' ? '4px' : '1000px'
|
|
88
90
|
}, style),
|
|
89
|
-
href: link
|
|
91
|
+
href: link[lang] ? link[lang] : link
|
|
90
92
|
}, /*#__PURE__*/React.createElement("span", {
|
|
91
93
|
className: styles.button
|
|
92
94
|
}, ic(text)));
|
|
@@ -18,10 +18,10 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
18
18
|
|
|
19
19
|
import React, { useEffect, useRef, useState } from 'react';
|
|
20
20
|
import { Input, Menu, Tooltip } from 'antd';
|
|
21
|
-
import { useLocale } from 'dumi';
|
|
21
|
+
import { useLocale, FormattedMessage, useIntl } from 'dumi';
|
|
22
|
+
import { cloneDeep } from 'lodash-es';
|
|
22
23
|
import { createFromIconfontCN, SearchOutlined, VerticalAlignTopOutlined } from '@ant-design/icons';
|
|
23
24
|
import classNames from 'classnames';
|
|
24
|
-
import { useT } from "../hooks";
|
|
25
25
|
import { filterTreeNode } from "../utils";
|
|
26
26
|
import styles from "./index.module.less"; // menu icon
|
|
27
27
|
|
|
@@ -57,22 +57,19 @@ export var ExampleSider = function ExampleSider(props) {
|
|
|
57
57
|
setSearchValue = _useState6[1];
|
|
58
58
|
|
|
59
59
|
var locale = useLocale();
|
|
60
|
+
var intl = useIntl();
|
|
60
61
|
|
|
61
62
|
var getCurrentTopics = function getCurrentTopics() {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return (res === null || res === void 0 ? void 0 : res.exampleTopics) || [];
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return exampleTopics;
|
|
63
|
+
var res = filterTreeNode({
|
|
64
|
+
id: 'FAKE_ID',
|
|
65
|
+
childrenKey: 'exampleTopics',
|
|
66
|
+
title: {
|
|
67
|
+
'zh': 'FAKE_TITLE',
|
|
68
|
+
'en': 'FAKE_TITLE'
|
|
69
|
+
},
|
|
70
|
+
exampleTopics: cloneDeep(exampleTopics)
|
|
71
|
+
}, searchValue, locale.id);
|
|
72
|
+
return (res === null || res === void 0 ? void 0 : res.exampleTopics) || [];
|
|
76
73
|
}; // 初始化菜单栏展开keys
|
|
77
74
|
|
|
78
75
|
|
|
@@ -131,11 +128,11 @@ export var ExampleSider = function ExampleSider(props) {
|
|
|
131
128
|
}, topic.title && getSearchValueTitle(topic.title[locale.id])))
|
|
132
129
|
}, topic.examples.map(function (example) {
|
|
133
130
|
return /*#__PURE__*/React.createElement(Menu.SubMenu, {
|
|
134
|
-
key: "EXAMPLE-".concat(example.id),
|
|
131
|
+
key: "EXAMPLE-".concat(topic.id, "-").concat(example.id),
|
|
135
132
|
title: example.title[locale.id]
|
|
136
133
|
}, example.demos.map(function (demo) {
|
|
137
134
|
return /*#__PURE__*/React.createElement(Menu.Item, {
|
|
138
|
-
key: "DEMO-".concat(demo.id),
|
|
135
|
+
key: "DEMO-".concat(topic.id, "-").concat(example.id, "-").concat(demo.id),
|
|
139
136
|
style: {
|
|
140
137
|
height: 70,
|
|
141
138
|
padding: 0,
|
|
@@ -161,7 +158,9 @@ export var ExampleSider = function ExampleSider(props) {
|
|
|
161
158
|
className: styles.searchSider
|
|
162
159
|
}, /*#__PURE__*/React.createElement(Input, {
|
|
163
160
|
size: "small",
|
|
164
|
-
placeholder:
|
|
161
|
+
placeholder: intl.formatMessage({
|
|
162
|
+
id: '搜索…'
|
|
163
|
+
}),
|
|
165
164
|
prefix: /*#__PURE__*/React.createElement(SearchOutlined, null),
|
|
166
165
|
value: searchValue,
|
|
167
166
|
onChange: function onChange(e) {
|
|
@@ -169,7 +168,9 @@ export var ExampleSider = function ExampleSider(props) {
|
|
|
169
168
|
}
|
|
170
169
|
}), /*#__PURE__*/React.createElement(Tooltip, {
|
|
171
170
|
placement: "right",
|
|
172
|
-
title:
|
|
171
|
+
title: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
172
|
+
id: "\u6536\u8D77\u6240\u6709"
|
|
173
|
+
})
|
|
173
174
|
}, /*#__PURE__*/React.createElement(VerticalAlignTopOutlined, {
|
|
174
175
|
className: styles.searchSiderIcon,
|
|
175
176
|
onClick: function onClick() {
|