@umijs/plugins 4.0.7 → 4.0.10
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/access.js +69 -53
- package/dist/analytics.js +62 -41
- package/dist/antd.js +139 -123
- package/dist/dva.js +155 -141
- package/dist/icons.js +28 -4
- package/dist/initial-state.js +80 -54
- package/dist/layout.js +219 -215
- package/dist/locale.js +214 -192
- package/dist/mf.d.ts +2 -0
- package/dist/mf.js +197 -0
- package/dist/model.js +79 -78
- package/dist/moment2dayjs.js +102 -81
- package/dist/qiankun/constants.js +41 -8
- package/dist/qiankun/master.js +163 -121
- package/dist/qiankun/slave.js +183 -148
- package/dist/qiankun.js +46 -19
- package/dist/request.js +91 -55
- package/dist/tailwindcss.js +74 -49
- package/dist/unocss.js +57 -37
- package/dist/utils/astUtils.js +38 -34
- package/dist/utils/localeUtils.js +125 -120
- package/dist/utils/modelUtils.js +216 -237
- package/dist/utils/resolveProjectDep.js +36 -13
- package/dist/utils/withTmpPath.js +31 -9
- package/libs/locale/localeExports.tpl +7 -3
- package/libs/qiankun/master/MicroApp.tsx +17 -12
- package/libs/qiankun/master/types.ts +1 -1
- package/libs/qiankun/slave/lifecycles.ts +15 -7
- package/package.json +6 -6
package/dist/layout.js
CHANGED
|
@@ -1,120 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
24
10
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
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));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/layout.ts
|
|
23
|
+
var layout_exports = {};
|
|
24
|
+
__export(layout_exports, {
|
|
25
|
+
default: () => layout_default
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(layout_exports);
|
|
28
|
+
var allIcons = __toESM(require("@ant-design/icons"));
|
|
29
|
+
var import_fs = require("fs");
|
|
30
|
+
var import_path = require("path");
|
|
31
|
+
var import_umi = require("umi");
|
|
32
|
+
var import_plugin_utils = require("umi/plugin-utils");
|
|
33
|
+
var import_withTmpPath = require("./utils/withTmpPath");
|
|
34
|
+
var layout_default = (api) => {
|
|
35
|
+
api.describe({
|
|
36
|
+
key: "layout",
|
|
37
|
+
config: {
|
|
38
|
+
schema(Joi) {
|
|
39
|
+
return Joi.alternatives().try(Joi.object(), Joi.boolean().invalid(true));
|
|
40
|
+
},
|
|
41
|
+
onChange: api.ConfigChangeType.regenerateTmpFiles
|
|
42
|
+
},
|
|
43
|
+
enableBy: api.EnableBy.config
|
|
44
|
+
});
|
|
45
|
+
const depList = ["@alipay/tech-ui", "@ant-design/pro-layout"];
|
|
46
|
+
const pkgHasDep = depList.find((dep) => {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
const { pkg } = api;
|
|
49
|
+
if (((_a = pkg.dependencies) == null ? void 0 : _a[dep]) || ((_b = pkg.devDependencies) == null ? void 0 : _b[dep])) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
});
|
|
54
|
+
const getPkgPath = () => {
|
|
55
|
+
if (pkgHasDep && (0, import_fs.existsSync)((0, import_path.join)(api.cwd, "node_modules", pkgHasDep, "package.json"))) {
|
|
56
|
+
return (0, import_path.join)(api.cwd, "node_modules", pkgHasDep);
|
|
57
|
+
}
|
|
58
|
+
const cwd = process.cwd();
|
|
59
|
+
if (pkgHasDep && api.cwd !== cwd && (0, import_fs.existsSync)((0, import_path.join)(cwd, "node_modules", pkgHasDep, "package.json"))) {
|
|
60
|
+
return (0, import_path.join)(cwd, "node_modules", pkgHasDep);
|
|
61
|
+
}
|
|
62
|
+
return (0, import_path.dirname)(require.resolve("@ant-design/pro-layout/package.json"));
|
|
63
|
+
};
|
|
64
|
+
const pkgPath = (0, import_plugin_utils.winPath)(getPkgPath());
|
|
65
|
+
api.modifyAppData((memo) => {
|
|
66
|
+
const version = require(`${pkgPath}/package.json`).version;
|
|
67
|
+
memo.pluginLayout = {
|
|
68
|
+
pkgPath,
|
|
69
|
+
version
|
|
69
70
|
};
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
api.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
memo.alias['@ant-design/pro-layout'] = pkgPath;
|
|
84
|
-
}
|
|
85
|
-
return memo;
|
|
86
|
-
});
|
|
87
|
-
api.onGenerateFiles(() => {
|
|
88
|
-
const hasInitialStatePlugin = api.config.initialState;
|
|
89
|
-
// Layout.tsx
|
|
90
|
-
api.writeTmpFile({
|
|
91
|
-
path: 'Layout.tsx',
|
|
92
|
-
content: `
|
|
71
|
+
return memo;
|
|
72
|
+
});
|
|
73
|
+
api.modifyConfig((memo) => {
|
|
74
|
+
if (!pkgHasDep) {
|
|
75
|
+
memo.alias["@ant-design/pro-layout"] = pkgPath;
|
|
76
|
+
}
|
|
77
|
+
return memo;
|
|
78
|
+
});
|
|
79
|
+
api.onGenerateFiles(() => {
|
|
80
|
+
const hasInitialStatePlugin = api.config.initialState;
|
|
81
|
+
api.writeTmpFile({
|
|
82
|
+
path: "Layout.tsx",
|
|
83
|
+
content: `
|
|
93
84
|
import { Link, useLocation, useNavigate, Outlet, useAppData, useRouteData, matchRoutes } from 'umi';
|
|
94
85
|
import type { IRoute } from 'umi';
|
|
95
86
|
import React, { useMemo } from 'react';
|
|
96
87
|
import {
|
|
97
88
|
ProLayout,
|
|
98
|
-
} from "${pkgPath ||
|
|
89
|
+
} from "${pkgPath || "@ant-design/pro-layout"}";
|
|
99
90
|
import './Layout.less';
|
|
100
91
|
import Logo from './Logo';
|
|
101
92
|
import Exception from './Exception';
|
|
102
93
|
import { getRightRenderContent } from './rightRender';
|
|
103
|
-
${hasInitialStatePlugin
|
|
104
|
-
|
|
105
|
-
: 'const useModel = null;'}
|
|
106
|
-
${api.config.access
|
|
107
|
-
? `
|
|
94
|
+
${hasInitialStatePlugin ? `import { useModel } from '@@/plugin-model';` : "const useModel = null;"}
|
|
95
|
+
${api.config.access ? `
|
|
108
96
|
import { useAccessMarkedRoutes } from '@@/plugin-access';
|
|
109
|
-
`.trim()
|
|
110
|
-
|
|
111
|
-
${api.config.locale
|
|
112
|
-
? `
|
|
97
|
+
`.trim() : "const useAccessMarkedRoutes = (r) => r;"}
|
|
98
|
+
${api.config.locale ? `
|
|
113
99
|
import { useIntl } from '@@/plugin-locale';
|
|
114
|
-
`.trim()
|
|
115
|
-
: ''}
|
|
100
|
+
`.trim() : ""}
|
|
116
101
|
|
|
117
|
-
//
|
|
102
|
+
// \u8FC7\u6EE4\u51FA\u9700\u8981\u663E\u793A\u7684\u8DEF\u7531, \u8FD9\u91CC\u7684filterFn \u6307 \u4E0D\u5E0C\u671B\u663E\u793A\u7684\u5C42\u7EA7
|
|
118
103
|
const filterRoutes = (routes: IRoute[], filterFn: (route: IRoute) => boolean) => {
|
|
119
104
|
if (routes.length === 0) {
|
|
120
105
|
return []
|
|
@@ -137,13 +122,13 @@ const filterRoutes = (routes: IRoute[], filterFn: (route: IRoute) => boolean) =>
|
|
|
137
122
|
return newRoutes;
|
|
138
123
|
}
|
|
139
124
|
|
|
140
|
-
//
|
|
125
|
+
// \u683C\u5F0F\u5316\u8DEF\u7531 \u5904\u7406\u56E0 wrapper \u5BFC\u81F4\u7684 \u83DC\u5355 path \u4E0D\u4E00\u81F4
|
|
141
126
|
const mapRoutes = (routes: IRoute[]) => {
|
|
142
127
|
if (routes.length === 0) {
|
|
143
128
|
return []
|
|
144
129
|
}
|
|
145
130
|
return routes.map(route => {
|
|
146
|
-
//
|
|
131
|
+
// \u9700\u8981 copy \u4E00\u4EFD, \u5426\u5219\u4F1A\u6C61\u67D3\u539F\u59CB\u6570\u636E
|
|
147
132
|
const newRoute = {...route}
|
|
148
133
|
if (route.originPath) {
|
|
149
134
|
newRoute.path = route.originPath
|
|
@@ -168,11 +153,9 @@ export default (props: any) => {
|
|
|
168
153
|
};
|
|
169
154
|
const { initialState, loading, setInitialState } = initialInfo;
|
|
170
155
|
const userConfig = ${JSON.stringify(api.config.layout, null, 2)};
|
|
171
|
-
${api.config.locale
|
|
172
|
-
? `
|
|
156
|
+
${api.config.locale ? `
|
|
173
157
|
const { formatMessage } = useIntl();
|
|
174
|
-
`.trim()
|
|
175
|
-
: 'const formatMessage = undefined;'}
|
|
158
|
+
`.trim() : "const formatMessage = undefined;"}
|
|
176
159
|
const runtimeConfig = pluginManager.applyPlugins({
|
|
177
160
|
key: 'layout',
|
|
178
161
|
type: 'modify',
|
|
@@ -256,72 +239,92 @@ const { formatMessage } = useIntl();
|
|
|
256
239
|
</ProLayout>
|
|
257
240
|
);
|
|
258
241
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
import type { ProLayoutProps } from "${pkgPath || '@ant-design/pro-layout'}";
|
|
271
|
-
${hasInitialStatePlugin
|
|
272
|
-
? `import type InitialStateType from '@@/plugin-initialState/@@initialState';
|
|
242
|
+
`
|
|
243
|
+
});
|
|
244
|
+
api.writeTmpFile({
|
|
245
|
+
path: "index.ts",
|
|
246
|
+
content: `export type TempType = string`
|
|
247
|
+
});
|
|
248
|
+
api.writeTmpFile({
|
|
249
|
+
path: "types.d.ts",
|
|
250
|
+
content: `
|
|
251
|
+
import type { ProLayoutProps, HeaderProps } from "${pkgPath || "@ant-design/pro-layout"}";
|
|
252
|
+
${hasInitialStatePlugin ? `import type InitialStateType from '@@/plugin-initialState/@@initialState';
|
|
273
253
|
type InitDataType = ReturnType<typeof InitialStateType>;
|
|
274
|
-
`
|
|
275
|
-
: 'type InitDataType = any;'}
|
|
254
|
+
` : "type InitDataType = any;"}
|
|
276
255
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
) =>
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
256
|
+
import { IConfigFromPlugins } from '@@/core/pluginConfig';
|
|
257
|
+
|
|
258
|
+
export type RunTimeLayoutConfig = (initData: InitDataType) => Omit<
|
|
259
|
+
ProLayoutProps,
|
|
260
|
+
'rightContentRender'
|
|
261
|
+
> & {
|
|
262
|
+
childrenRender?: (dom: JSX.Element, props: ProLayoutProps) => React.ReactNode;
|
|
263
|
+
unAccessible?: JSX.Element;
|
|
264
|
+
noFound?: JSX.Element;
|
|
265
|
+
logout?: (initialState: InitDataType['initialState']) => Promise<void> | void;
|
|
266
|
+
rightContentRender?: (
|
|
267
|
+
headerProps: HeaderProps,
|
|
268
|
+
dom: JSX.Element,
|
|
269
|
+
props: {
|
|
270
|
+
userConfig: IConfigFromPlugins['layout'];
|
|
271
|
+
runtimeConfig: RunTimeLayoutConfig;
|
|
272
|
+
loading: InitDataType['loading'];
|
|
273
|
+
initialState: InitDataType['initialState'];
|
|
274
|
+
setInitialState: InitDataType['setInitialState'];
|
|
275
|
+
},
|
|
276
|
+
) => JSX.Element;
|
|
277
|
+
rightRender?: (
|
|
278
|
+
initialState: InitDataType['initialState'],
|
|
279
|
+
setInitialState: InitDataType['setInitialState'],
|
|
280
|
+
runtimeConfig: RunTimeLayoutConfig,
|
|
281
|
+
) => JSX.Element;
|
|
283
282
|
};
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
283
|
+
`
|
|
284
|
+
});
|
|
285
|
+
api.writeTmpFile({
|
|
286
|
+
path: import_umi.RUNTIME_TYPE_FILE_NAME,
|
|
287
|
+
content: `
|
|
288
|
+
import type { RunTimeLayoutConfig } from './types.d';
|
|
289
|
+
export interface IRuntimeConfig {
|
|
290
|
+
layout?: RunTimeLayoutConfig
|
|
291
|
+
}
|
|
292
|
+
`
|
|
293
|
+
});
|
|
294
|
+
const iconsMap = Object.keys(api.appData.routes).reduce((memo, id) => {
|
|
295
|
+
const { icon } = api.appData.routes[id];
|
|
296
|
+
if (icon) {
|
|
297
|
+
const upperIcon = import_plugin_utils.lodash.upperFirst(import_plugin_utils.lodash.camelCase(icon));
|
|
298
|
+
if (allIcons[upperIcon]) {
|
|
299
|
+
memo[upperIcon] = true;
|
|
300
|
+
}
|
|
301
|
+
if (allIcons[`${upperIcon}Outlined`]) {
|
|
302
|
+
memo[`${upperIcon}Outlined`] = true;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return memo;
|
|
306
|
+
}, {});
|
|
307
|
+
const icons = Object.keys(iconsMap);
|
|
308
|
+
const antIconsPath = (0, import_plugin_utils.winPath)((0, import_path.dirname)(require.resolve("@ant-design/icons/package")));
|
|
309
|
+
api.writeTmpFile({
|
|
310
|
+
path: "icons.tsx",
|
|
311
|
+
content: `
|
|
312
|
+
${icons.map((icon) => {
|
|
313
|
+
return `import ${icon} from '${antIconsPath}/es/icons/${icon}';`;
|
|
314
|
+
}).join("\n")}
|
|
315
|
+
export default { ${icons.join(", ")} };
|
|
316
|
+
`
|
|
317
|
+
});
|
|
318
|
+
api.writeTmpFile({
|
|
319
|
+
path: "runtime.tsx",
|
|
320
|
+
content: `
|
|
318
321
|
import React from 'react';
|
|
319
322
|
import icons from './icons';
|
|
320
323
|
|
|
321
324
|
function formatIcon(name: string) {
|
|
322
325
|
return name
|
|
323
326
|
.replace(name[0], name[0].toUpperCase())
|
|
324
|
-
.replace(/-(
|
|
327
|
+
.replace(/-(w)/g, function(all, letter) {
|
|
325
328
|
return letter.toUpperCase();
|
|
326
329
|
});
|
|
327
330
|
}
|
|
@@ -337,9 +340,9 @@ export function patchRoutes({ routes }) {
|
|
|
337
340
|
}
|
|
338
341
|
});
|
|
339
342
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
+
`
|
|
344
|
+
});
|
|
345
|
+
const rightRenderContent = `
|
|
343
346
|
import React from 'react';
|
|
344
347
|
import { Avatar, Dropdown, Menu, Spin } from 'antd';
|
|
345
348
|
import { LogoutOutlined } from '@ant-design/icons';
|
|
@@ -370,7 +373,7 @@ export function getRightRenderContent (opts: {
|
|
|
370
373
|
}
|
|
371
374
|
>
|
|
372
375
|
<LogoutOutlined />
|
|
373
|
-
|
|
376
|
+
\u9000\u51FA\u767B\u5F55
|
|
374
377
|
</Menu.Item>
|
|
375
378
|
</Menu>
|
|
376
379
|
);
|
|
@@ -414,22 +417,20 @@ export function getRightRenderContent (opts: {
|
|
|
414
417
|
);
|
|
415
418
|
}
|
|
416
419
|
`;
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
path: 'Layout.less',
|
|
428
|
-
content: `
|
|
420
|
+
const Locale = api.isPluginEnable("locale");
|
|
421
|
+
api.writeTmpFile({
|
|
422
|
+
path: "rightRender.tsx",
|
|
423
|
+
content: import_plugin_utils.Mustache.render(rightRenderContent, {
|
|
424
|
+
Locale
|
|
425
|
+
})
|
|
426
|
+
});
|
|
427
|
+
api.writeTmpFile({
|
|
428
|
+
path: "Layout.less",
|
|
429
|
+
content: `
|
|
429
430
|
@import '~antd/es/style/themes/default.less';
|
|
430
431
|
@pro-header-hover-bg: rgba(0, 0, 0, 0.025);
|
|
431
432
|
@media screen and (max-width: @screen-xs) {
|
|
432
|
-
//
|
|
433
|
+
// \u5728\u5C0F\u5C4F\u5E55\u7684\u65F6\u5019\u53EF\u4EE5\u6709\u66F4\u597D\u7684\u4F53\u9A8C
|
|
433
434
|
.umi-plugin-layout-container {
|
|
434
435
|
width: 100% !important;
|
|
435
436
|
}
|
|
@@ -479,12 +480,11 @@ export function getRightRenderContent (opts: {
|
|
|
479
480
|
.umi-plugin-layout-name {
|
|
480
481
|
margin-left: 8px;
|
|
481
482
|
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
content: `
|
|
483
|
+
`
|
|
484
|
+
});
|
|
485
|
+
api.writeTmpFile({
|
|
486
|
+
path: "Logo.tsx",
|
|
487
|
+
content: `
|
|
488
488
|
import React from 'react';
|
|
489
489
|
|
|
490
490
|
const LogoIcon: React.FC = () => {
|
|
@@ -576,11 +576,11 @@ const LogoIcon: React.FC = () => {
|
|
|
576
576
|
};
|
|
577
577
|
|
|
578
578
|
export default LogoIcon;
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
579
|
+
`
|
|
580
|
+
});
|
|
581
|
+
api.writeTmpFile({
|
|
582
|
+
path: "Exception.tsx",
|
|
583
|
+
content: `
|
|
584
584
|
import React from 'react';
|
|
585
585
|
import { history, type IRoute } from 'umi';
|
|
586
586
|
import { Result, Button } from 'antd';
|
|
@@ -590,20 +590,22 @@ const Exception: React.FC<{
|
|
|
590
590
|
route?: IRoute;
|
|
591
591
|
notFound?: React.ReactNode;
|
|
592
592
|
noAccessible?: React.ReactNode;
|
|
593
|
+
unAccessible?: React.ReactNode;
|
|
594
|
+
noFound?: React.ReactNode;
|
|
593
595
|
}> = (props) => (
|
|
594
596
|
// render custom 404
|
|
595
|
-
(!props.route && props.notFound) ||
|
|
597
|
+
(!props.route && (props.noFound || props.notFound)) ||
|
|
596
598
|
// render custom 403
|
|
597
|
-
(props.route.unaccessible && props.noAccessible) ||
|
|
599
|
+
(props.route.unaccessible && (props.unAccessible || props.noAccessible)) ||
|
|
598
600
|
// render default exception
|
|
599
601
|
((!props.route || props.route.unaccessible) && (
|
|
600
602
|
<Result
|
|
601
603
|
status={props.route ? '403' : '404'}
|
|
602
604
|
title={props.route ? '403' : '404'}
|
|
603
|
-
subTitle={props.route ? '
|
|
605
|
+
subTitle={props.route ? '\u62B1\u6B49\uFF0C\u4F60\u65E0\u6743\u8BBF\u95EE\u8BE5\u9875\u9762' : '\u62B1\u6B49\uFF0C\u4F60\u8BBF\u95EE\u7684\u9875\u9762\u4E0D\u5B58\u5728'}
|
|
604
606
|
extra={
|
|
605
607
|
<Button type="primary" onClick={() => history.push('/')}>
|
|
606
|
-
|
|
608
|
+
\u8FD4\u56DE\u9996\u9875
|
|
607
609
|
</Button>
|
|
608
610
|
}
|
|
609
611
|
/>
|
|
@@ -613,22 +615,24 @@ const Exception: React.FC<{
|
|
|
613
615
|
);
|
|
614
616
|
|
|
615
617
|
export default Exception;
|
|
616
|
-
|
|
617
|
-
});
|
|
618
|
-
});
|
|
619
|
-
api.addLayouts(() => {
|
|
620
|
-
return [
|
|
621
|
-
{
|
|
622
|
-
id: 'ant-design-pro-layout',
|
|
623
|
-
file: (0, withTmpPath_1.withTmpPath)({ api, path: 'Layout.tsx' }),
|
|
624
|
-
test: (route) => {
|
|
625
|
-
return route.layout !== false;
|
|
626
|
-
},
|
|
627
|
-
},
|
|
628
|
-
];
|
|
629
|
-
});
|
|
630
|
-
api.addRuntimePluginKey(() => ['layout']);
|
|
631
|
-
api.addRuntimePlugin(() => {
|
|
632
|
-
return [(0, withTmpPath_1.withTmpPath)({ api, path: 'runtime.tsx' })];
|
|
618
|
+
`
|
|
633
619
|
});
|
|
620
|
+
});
|
|
621
|
+
api.addLayouts(() => {
|
|
622
|
+
return [
|
|
623
|
+
{
|
|
624
|
+
id: "ant-design-pro-layout",
|
|
625
|
+
file: (0, import_withTmpPath.withTmpPath)({ api, path: "Layout.tsx" }),
|
|
626
|
+
test: (route) => {
|
|
627
|
+
return route.layout !== false;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
];
|
|
631
|
+
});
|
|
632
|
+
api.addRuntimePluginKey(() => ["layout"]);
|
|
633
|
+
api.addRuntimePlugin(() => {
|
|
634
|
+
return [(0, import_withTmpPath.withTmpPath)({ api, path: "runtime.tsx" })];
|
|
635
|
+
});
|
|
634
636
|
};
|
|
637
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
638
|
+
0 && (module.exports = {});
|