@antv/dumi-theme-antv 0.3.0-beta.9 → 0.3.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.
Files changed (69) 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 +2 -3
  4. package/dist/layouts/entry/Index.js +14 -13
  5. package/dist/layouts/entry/Manual.js +6 -3
  6. package/dist/pages/404.js +4 -4
  7. package/dist/pages/Example/index.js +4 -4
  8. package/dist/pages/Examples/components/ExampleTopicMenu/components/LeftMenu/index.js +2 -1
  9. package/dist/pages/Examples/components/GalleryPageContent/DemoCard/index.js +10 -5
  10. package/dist/pages/Examples/components/GalleryPageContent/index.js +2 -1
  11. package/dist/pages/Examples/index.js +3 -3
  12. package/dist/pages/Examples/index.module.less +13 -0
  13. package/dist/pages/Examples/utils.d.ts +1 -0
  14. package/dist/pages/Examples/utils.js +3 -0
  15. package/dist/plugin/index.js +10 -0
  16. package/dist/slots/Article/index.d.ts +3 -0
  17. package/dist/slots/Article/index.js +11 -0
  18. package/dist/slots/Article/index.module.less +8 -0
  19. package/dist/slots/Banner/Notification.d.ts +10 -0
  20. package/dist/slots/Banner/Notification.js +43 -0
  21. package/dist/slots/Banner/Notification.module.less +120 -0
  22. package/dist/slots/Banner/index.d.ts +26 -0
  23. package/dist/slots/Banner/index.js +184 -0
  24. package/dist/slots/Banner/index.module.less +449 -0
  25. package/dist/slots/Cases/index.d.ts +1 -1
  26. package/dist/slots/Cases/index.js +13 -7
  27. package/dist/slots/Cases/index.module.less +2 -1
  28. package/dist/slots/CodeEditor/Toolbar.js +13 -6
  29. package/dist/slots/CodeEditor/index.d.ts +4 -0
  30. package/dist/slots/CodeEditor/index.js +43 -21
  31. package/dist/slots/CodeEditor/utils.js +1 -1
  32. package/dist/slots/CodePreview/CodeHeader.js +15 -14
  33. package/dist/slots/CodePreview/index.d.ts +8 -0
  34. package/dist/slots/CodePreview/index.js +15 -6
  35. package/dist/slots/CodePreview/index.module.less +11 -2
  36. package/dist/slots/CodeRunner/index.d.ts +2 -0
  37. package/dist/slots/CodeRunner/index.js +13 -5
  38. package/dist/slots/Companies/index.d.ts +1 -1
  39. package/dist/slots/{TOC.d.ts → ContentTable/index.d.ts} +2 -1
  40. package/dist/slots/{TOC.js → ContentTable/index.js} +2 -1
  41. package/dist/slots/ContentTable/index.module.less +11 -0
  42. package/dist/slots/Detail/News.js +3 -2
  43. package/dist/slots/Detail/index.js +3 -1
  44. package/dist/slots/ExampleSider/index.js +23 -21
  45. package/dist/slots/Features/index.js +5 -2
  46. package/dist/slots/Features/index.module.less +3 -3
  47. package/dist/slots/Footer/index.js +34 -14
  48. package/dist/slots/Footer/index.module.less +0 -1
  49. package/dist/slots/Header/LogoWhite.js +1 -2
  50. package/dist/slots/Header/Navs.d.ts +2 -2
  51. package/dist/slots/Header/Navs.js +7 -7
  52. package/dist/slots/Header/Products/NavigatorBanner.js +4 -3
  53. package/dist/slots/Header/Products/Product.js +7 -3
  54. package/dist/slots/Header/Products/getProducts.js +4 -2
  55. package/dist/slots/Header/Products/index.js +5 -3
  56. package/dist/slots/Header/Search.js +5 -3
  57. package/dist/slots/Header/index.d.ts +7 -2
  58. package/dist/slots/Header/index.js +128 -24
  59. package/dist/slots/ManualContent/NavigatorBanner.js +5 -3
  60. package/dist/slots/ManualContent/ReadingTime.js +6 -2
  61. package/dist/slots/ManualContent/index.js +22 -28
  62. package/dist/slots/ManualContent/index.module.less +17 -9
  63. package/dist/slots/ManualContent/utils.d.ts +15 -0
  64. package/dist/slots/ManualContent/utils.js +31 -1
  65. package/dist/slots/_.less +1 -1
  66. package/dist/slots/hooks.d.ts +1 -1
  67. package/dist/slots/hooks.js +5 -8
  68. package/dist/slots/utils.js +6 -1
  69. package/package.json +5 -2
@@ -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: useT('在 Riddle 中打开')
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: useT('在 StackBlitz 中打开')
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: useT('在 CodeSandbox 中打开')
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: useT('执行代码')
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: {
@@ -4,6 +4,10 @@ export declare type CodeEditorProps = {
4
4
  * 标题
5
5
  */
6
6
  title?: string;
7
+ /**
8
+ * 示例的 id
9
+ */
10
+ exampleId: string;
7
11
  /**
8
12
  * 输入的源码
9
13
  */
@@ -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 "../Loading";
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]; // 出发 auto resize
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, 'playgroundScriptContainer', playground === null || playground === void 0 ? void 0 : playground.container, replaceId);
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
- }, [source]);
140
+ }, [exampleId]); // 代码变化的时候,运行代码
141
+
137
142
  useEffect(function () {
138
143
  executeCode(code);
139
144
  }, [code]);
140
145
  useEffect(function () {
141
- var dom = document.getElementById('playgroundScriptContainer');
142
- bind(dom, debounce(function () {
143
- dispatchResizeEvent();
144
- }, 100));
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
- useEffect(function () {
174
- if (monacoRef.current) {
175
- monacoRef.current.setValue(currentEditorTab === EDITOR_TABS.JAVASCRIPT ? code : JSON.stringify(data, null, 2));
176
- }
177
- }, [currentEditorTab]);
178
- var onCodeChange = useCallback(function (value) {
179
- if (currentEditorTab === EDITOR_TABS.JAVASCRIPT) {
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: setCurrentEditorTab,
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, Tooltip, Space, Divider } from 'antd';
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: /*#__PURE__*/React.createElement(Tooltip, {
19
- title: useT('在 GitHub 上编辑')
20
- }, /*#__PURE__*/React.createElement("a", {
21
- href: getGithubSourceURL(githubUrl, relativePath, 'examples'),
22
- target: "_blank",
23
- rel: "noopener noreferrer",
24
- className: styles.editOnGtiHubButton
25
- }, /*#__PURE__*/React.createElement(EditOutlined, null))),
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,5 +1,13 @@
1
1
  import React from 'react';
2
2
  export declare type CodePreviewProps = {
3
+ /**
4
+ * 在文档中预览
5
+ */
6
+ isPlayground: boolean;
7
+ /**
8
+ * id
9
+ */
10
+ exampleId: string;
3
11
  /**
4
12
  * 预览页面头部组件,用于显示 demo 名称,一些操作栏等
5
13
  */
@@ -1,29 +1,38 @@
1
1
  import React from 'react';
2
2
  import { Result } from 'antd';
3
- import { useT } from "../hooks";
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 header = _ref.header,
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: "playgroundScriptContainer",
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: useT('演示代码报错,请检查'),
27
- subTitle: /*#__PURE__*/React.createElement("pre", null, error && error.toString())
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: 16px;
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
- :global(#playgroundScriptContainer) {
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 "../CodeEditor";
18
- import { CodePreview } from "../CodePreview";
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 "../404";
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[locale.id],
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,
@@ -4,7 +4,7 @@ declare type Company = {
4
4
  img: string;
5
5
  };
6
6
  interface CompaniesProps {
7
- title: string;
7
+ title: any;
8
8
  companies: Company[];
9
9
  className?: string;
10
10
  style?: React.CSSProperties;
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
+ import './index.module.less';
2
3
  /**
3
4
  * 文档右侧的指示器(table of content)
4
5
  */
5
- export declare const TOC: React.FC<{}>;
6
+ export declare const ContentTable: React.FC<{}>;
@@ -1,6 +1,7 @@
1
1
  import Toc from 'dumi/theme-default/slots/Toc';
2
+ import "./index.module.less";
2
3
  /**
3
4
  * 文档右侧的指示器(table of content)
4
5
  */
5
6
 
6
- export var TOC = Toc;
7
+ export var ContentTable = Toc;
@@ -0,0 +1,11 @@
1
+ :global {
2
+ ul.dumi-default-toc {
3
+ >li {
4
+ margin-left: 0px!important;
5
+ }
6
+ .active {
7
+ color: #873bf4!important;
8
+ border-left: 3px solid #873bf4!important;
9
+ }
10
+ }
11
+ }
@@ -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,29 +57,27 @@ 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
- if (searchValue) {
63
- var res = filterTreeNode({
64
- id: 'FAKE_ID',
65
- childrenKey: 'exampleTopics',
66
- title: {
67
- 'zh': 'FAKE_TITLE',
68
- 'en': 'FAKE_TITLE'
69
- },
70
- exampleTopics: exampleTopics
71
- }, searchValue, locale.id);
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
 
79
76
  useEffect(function () {
80
77
  var targetExample = currentDemo.targetExample,
81
78
  targetTopic = currentDemo.targetTopic;
82
- setOpenKeys(["TOPIC-".concat(targetTopic === null || targetTopic === void 0 ? void 0 : targetTopic.id), "EXAMPLE-".concat(targetExample === null || targetExample === void 0 ? void 0 : targetExample.id)]);
79
+ var keys = ["TOPIC-".concat(targetTopic === null || targetTopic === void 0 ? void 0 : targetTopic.id), "EXAMPLE-".concat(targetTopic.id, "-").concat(targetExample === null || targetExample === void 0 ? void 0 : targetExample.id)];
80
+ setOpenKeys(keys);
83
81
  }, [currentDemo]); // 初始化滚动到中间
84
82
 
85
83
  useEffect(function () {
@@ -131,11 +129,11 @@ export var ExampleSider = function ExampleSider(props) {
131
129
  }, topic.title && getSearchValueTitle(topic.title[locale.id])))
132
130
  }, topic.examples.map(function (example) {
133
131
  return /*#__PURE__*/React.createElement(Menu.SubMenu, {
134
- key: "EXAMPLE-".concat(example.id),
132
+ key: "EXAMPLE-".concat(topic.id, "-").concat(example.id),
135
133
  title: example.title[locale.id]
136
134
  }, example.demos.map(function (demo) {
137
135
  return /*#__PURE__*/React.createElement(Menu.Item, {
138
- key: "DEMO-".concat(demo.id),
136
+ key: "DEMO-".concat(topic.id, "-").concat(example.id, "-").concat(demo.id),
139
137
  style: {
140
138
  height: 70,
141
139
  padding: 0,
@@ -161,7 +159,9 @@ export var ExampleSider = function ExampleSider(props) {
161
159
  className: styles.searchSider
162
160
  }, /*#__PURE__*/React.createElement(Input, {
163
161
  size: "small",
164
- placeholder: useT('搜索…'),
162
+ placeholder: intl.formatMessage({
163
+ id: '搜索…'
164
+ }),
165
165
  prefix: /*#__PURE__*/React.createElement(SearchOutlined, null),
166
166
  value: searchValue,
167
167
  onChange: function onChange(e) {
@@ -169,7 +169,9 @@ export var ExampleSider = function ExampleSider(props) {
169
169
  }
170
170
  }), /*#__PURE__*/React.createElement(Tooltip, {
171
171
  placement: "right",
172
- title: useT('收起所有')
172
+ title: /*#__PURE__*/React.createElement(FormattedMessage, {
173
+ id: "\u6536\u8D77\u6240\u6709"
174
+ })
173
175
  }, /*#__PURE__*/React.createElement(VerticalAlignTopOutlined, {
174
176
  className: styles.searchSiderIcon,
175
177
  onClick: function onClick() {
@@ -68,7 +68,7 @@ export var Features = function Features(_ref) {
68
68
  }) : /*#__PURE__*/React.createElement("div", {
69
69
  className: cx(styles.lefttopWithoutTitle, styles.lefttop)
70
70
  }), /*#__PURE__*/React.createElement("div", {
71
- className: cx(styles.rightbottomWithoutTitle, styles.rightbottom)
71
+ className: title ? styles.rightbottom : cx(styles.rightbottomWithoutTitle, styles.rightbottom)
72
72
  }, /*#__PURE__*/React.createElement("div", {
73
73
  className: cx(styles.slicerbar, styles.slicerbarv, styles.slicerbarv1)
74
74
  }), /*#__PURE__*/React.createElement("div", {
@@ -85,7 +85,10 @@ export var Features = function Features(_ref) {
85
85
  className: styles.content
86
86
  }, /*#__PURE__*/React.createElement("div", {
87
87
  key: "content"
88
- }, /*#__PURE__*/React.createElement("div", {
88
+ }, /*#__PURE__*/React.createElement("p", {
89
+ key: "title",
90
+ className: styles.title
91
+ }, title ? title : ''), /*#__PURE__*/React.createElement("div", {
89
92
  key: "block",
90
93
  className: styles.cardsContainer
91
94
  }, /*#__PURE__*/React.createElement(Row, {
@@ -23,7 +23,7 @@
23
23
  font-size: 2.8em;
24
24
  padding-left: 4.06%;
25
25
  font-weight: 500;
26
- margin: 48px 0 0 0;
26
+ margin: 17px 0 0 0;
27
27
  position: relative;
28
28
  height: min-content;
29
29
  color: #fff;
@@ -58,7 +58,7 @@
58
58
  position: absolute;
59
59
  width: 95.83%;
60
60
  left: 4.17%;
61
- top: 144px;
61
+ top: 88px;
62
62
  background: #fff;
63
63
  height: 65%;
64
64
  box-shadow: -5px 5px 15px rgba(0, 0, 0, 0.1);
@@ -197,4 +197,4 @@
197
197
  display: block;
198
198
  z-index: 2;
199
199
  }
200
- }
200
+ }