@umijs/plugins 4.0.0-canary.20220428.2 → 4.0.0-canary.20220429.3

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 (45) hide show
  1. package/package.json +3 -3
  2. package/dist/access.d.ts +0 -3
  3. package/dist/access.js +0 -148
  4. package/dist/analytics.d.ts +0 -3
  5. package/dist/analytics.js +0 -67
  6. package/dist/antd.d.ts +0 -3
  7. package/dist/antd.js +0 -131
  8. package/dist/dva.d.ts +0 -6
  9. package/dist/dva.js +0 -198
  10. package/dist/icons.d.ts +0 -3
  11. package/dist/icons.js +0 -5
  12. package/dist/initial-state.d.ts +0 -3
  13. package/dist/initial-state.js +0 -116
  14. package/dist/layout.d.ts +0 -3
  15. package/dist/layout.js +0 -538
  16. package/dist/locale.d.ts +0 -4
  17. package/dist/locale.js +0 -201
  18. package/dist/model.d.ts +0 -3
  19. package/dist/model.js +0 -120
  20. package/dist/moment2dayjs.d.ts +0 -3
  21. package/dist/moment2dayjs.js +0 -96
  22. package/dist/qiankun/constants.d.ts +0 -5
  23. package/dist/qiankun/constants.js +0 -8
  24. package/dist/qiankun/master.d.ts +0 -6
  25. package/dist/qiankun/master.js +0 -120
  26. package/dist/qiankun/slave.d.ts +0 -3
  27. package/dist/qiankun/slave.js +0 -145
  28. package/dist/qiankun.d.ts +0 -3
  29. package/dist/qiankun.js +0 -19
  30. package/dist/request.d.ts +0 -3
  31. package/dist/request.js +0 -309
  32. package/dist/tailwindcss.d.ts +0 -3
  33. package/dist/tailwindcss.js +0 -40
  34. package/dist/unocss.d.ts +0 -3
  35. package/dist/unocss.js +0 -39
  36. package/dist/utils/astUtils.d.ts +0 -3
  37. package/dist/utils/astUtils.js +0 -38
  38. package/dist/utils/localeUtils.d.ts +0 -33
  39. package/dist/utils/localeUtils.js +0 -135
  40. package/dist/utils/modelUtils.d.ts +0 -35
  41. package/dist/utils/modelUtils.js +0 -149
  42. package/dist/utils/resolveProjectDep.d.ts +0 -5
  43. package/dist/utils/resolveProjectDep.js +0 -15
  44. package/dist/utils/withTmpPath.d.ts +0 -6
  45. package/dist/utils/withTmpPath.js +0 -11
@@ -1,116 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const withTmpPath_1 = require("./utils/withTmpPath");
4
- exports.default = (api) => {
5
- api.describe({
6
- config: {
7
- schema(Joi) {
8
- return Joi.object({
9
- loading: Joi.string(),
10
- });
11
- },
12
- },
13
- enableBy: api.EnableBy.config,
14
- });
15
- api.register({
16
- key: 'addExtraModels',
17
- fn: () => [(0, withTmpPath_1.withTmpPath)({ api, path: '@@initialState.ts' })],
18
- });
19
- api.addRuntimePluginKey(() => ['getInitialState']);
20
- api.addRuntimePlugin(() => {
21
- return [(0, withTmpPath_1.withTmpPath)({ api, path: 'runtime.tsx' })];
22
- });
23
- api.onGenerateFiles(() => {
24
- var _a;
25
- const { loading } = api.config.initialState;
26
- // Provider.tsx
27
- api.writeTmpFile({
28
- path: 'Provider.tsx',
29
- content: `
30
- import React from 'react';
31
- import { useModel } from '@@/plugin-model';
32
- ${loading
33
- ? `import Loading from '${loading}'`
34
- : `function Loading() { return <div />; }`}
35
- export default function InitialStateProvider(props: any) {
36
- const appLoaded = React.useRef(false);
37
- const { loading = false } = useModel("@@initialState") || {};
38
- React.useEffect(() => {
39
- if (!loading) {
40
- appLoaded.current = true;
41
- }
42
- }, [loading]);
43
- if (loading && !appLoaded.current) {
44
- return <Loading />;
45
- }
46
- return props.children;
47
- }
48
- `,
49
- });
50
- // @@initialState.ts
51
- api.writeTmpFile({
52
- path: '@@initialState.ts',
53
- content: ((_a = api.appData.appJS) === null || _a === void 0 ? void 0 : _a.exports.includes('getInitialState'))
54
- ? `
55
- import { useState, useEffect, useCallback } from 'react';
56
- import { getInitialState } from '@/app';
57
-
58
- const initState = {
59
- initialState: undefined,
60
- loading: true,
61
- error: undefined,
62
- };
63
-
64
- export default () => {
65
- const [state, setState] = useState(initState);
66
- const refresh = useCallback(async () => {
67
- setState((s) => ({ ...s, loading: true, error: undefined }));
68
- try {
69
- const ret = await getInitialState();
70
- setState((s) => ({ ...s, initialState: ret, loading: false }));
71
- } catch (e) {
72
- setState((s) => ({ ...s, error: e, loading: false }));
73
- }
74
- // [?]
75
- // await sleep(10);
76
- }, []);
77
-
78
- const setInitialState = useCallback(async (initialState) => {
79
- setState((s) => {
80
- if (typeof initialState === 'function') {
81
- return { ...s, initialState: initialState(s.initialState), loading: false };
82
- }
83
- return { ...s, initialState, loading: false };
84
- });
85
- // [?]
86
- // await sleep(10)
87
- }, []);
88
-
89
- useEffect(() => {
90
- refresh();
91
- }, []);
92
-
93
- return {
94
- ...state,
95
- refresh,
96
- setInitialState,
97
- };
98
- }
99
- `
100
- : `
101
- export default () => ({ loading: false, refresh: () => {} })
102
- `,
103
- });
104
- // runtime.tsx
105
- api.writeTmpFile({
106
- path: 'runtime.tsx',
107
- content: `
108
- import React from 'react';
109
- import Provider from './Provider';
110
- export function dataflowProvider(container) {
111
- return <Provider>{ container }</Provider>;
112
- }
113
- `,
114
- });
115
- });
116
- };
package/dist/layout.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { IApi } from 'umi';
2
- declare const _default: (api: IApi) => void;
3
- export default _default;
package/dist/layout.js DELETED
@@ -1,538 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
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;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const allIcons = __importStar(require("@ant-design/icons"));
30
- const assert_1 = __importDefault(require("assert"));
31
- const path_1 = require("path");
32
- const plugin_utils_1 = require("umi/plugin-utils");
33
- const resolveProjectDep_1 = require("./utils/resolveProjectDep");
34
- const withTmpPath_1 = require("./utils/withTmpPath");
35
- exports.default = (api) => {
36
- api.describe({
37
- key: 'layout',
38
- config: {
39
- schema(joi) {
40
- return joi.object();
41
- },
42
- // onChange: api.ConfigChangeType.regenerateTmpFiles,
43
- },
44
- enableBy: api.EnableBy.config,
45
- });
46
- const pkgPath = (0, resolveProjectDep_1.resolveProjectDep)({
47
- pkg: api.pkg,
48
- cwd: api.cwd,
49
- dep: '@ant-design/pro-layout',
50
- }) || (0, path_1.dirname)(require.resolve('@ant-design/pro-layout/package.json'));
51
- api.modifyAppData((memo) => {
52
- const version = require(`${pkgPath}/package.json`).version;
53
- memo.pluginLayout = {
54
- pkgPath,
55
- version,
56
- };
57
- return memo;
58
- });
59
- api.modifyConfig((memo) => {
60
- // import from @ant-design/pro-layout
61
- memo.alias['@ant-design/pro-layout'] = pkgPath;
62
- return memo;
63
- });
64
- api.onGenerateFiles(() => {
65
- const hasInitialStatePlugin = api.config.initialState;
66
- // Layout.tsx
67
- api.writeTmpFile({
68
- path: 'Layout.tsx',
69
- content: `
70
- import { Link, useLocation, useNavigate, Outlet, useAppData, useRouteData, matchRoutes } from 'umi';
71
- import { useMemo } from 'react';
72
- import ProLayout, {
73
- PageLoading,
74
- } from '@ant-design/pro-layout';
75
- import './Layout.less';
76
- import Logo from './Logo';
77
- import Exception from './Exception';
78
- import { getRightRenderContent } from './rightRender';
79
- ${hasInitialStatePlugin
80
- ? `import { useModel } from '@@/plugin-model';`
81
- : 'const useModel = null;'}
82
- ${api.config.access
83
- ? `
84
- import { useAccessMarkedRoutes } from '@@/plugin-access';
85
- `.trim()
86
- : 'const useAccessMarkedRoutes = (r) => r;'}
87
- ${api.config.locale
88
- ? `
89
- import { useIntl } from '@@/plugin-locale';
90
- `.trim()
91
- : ''}
92
-
93
-
94
- export default (props: any) => {
95
- const location = useLocation();
96
- const navigate = useNavigate();
97
- const { clientRoutes, pluginManager } = useAppData();
98
- const initialInfo = (useModel && useModel('@@initialState')) || {
99
- initialState: undefined,
100
- loading: false,
101
- setInitialState: null,
102
- };
103
- const { initialState, loading, setInitialState } = initialInfo;
104
- const userConfig = ${JSON.stringify(api.config.layout, null, 2)};
105
- ${api.config.locale
106
- ? `
107
- const { formatMessage } = useIntl();
108
- `.trim()
109
- : 'const formatMessage = undefined;'}
110
- const runtimeConfig = pluginManager.applyPlugins({
111
- key: 'layout',
112
- type: 'modify',
113
- initialValue: {
114
- ...initialInfo
115
- },
116
- });
117
- const matchedRoute = useMemo(() => matchRoutes(clientRoutes, location.pathname).pop()?.route, [location.pathname]);
118
- const [route] = useAccessMarkedRoutes(clientRoutes.filter(({ id }) => id === 'ant-design-pro-layout'));
119
- return (
120
- <ProLayout
121
- route={route}
122
- location={location}
123
- title={userConfig.title || 'plugin-layout'}
124
- navTheme="dark"
125
- siderWidth={256}
126
- onMenuHeaderClick={(e) => {
127
- e.stopPropagation();
128
- e.preventDefault();
129
- navigate('/');
130
- }}
131
- formatMessage={userConfig.formatMessage || formatMessage}
132
- menu={{ locale: userConfig.locale }}
133
- logo={Logo}
134
- menuItemRender={(menuItemProps, defaultDom) => {
135
- if (menuItemProps.isUrl || menuItemProps.children) {
136
- return defaultDom;
137
- }
138
- if (menuItemProps.path && location.pathname !== menuItemProps.path) {
139
- return (
140
- <Link to={menuItemProps.path} target={menuItemProps.target}>
141
- {defaultDom}
142
- </Link>
143
- );
144
- }
145
- return defaultDom;
146
- }}
147
- disableContentMargin
148
- fixSiderbar
149
- fixedHeader
150
- {...runtimeConfig}
151
- rightContentRender={
152
- runtimeConfig.rightContentRender !== false &&
153
- ((layoutProps) => {
154
- const dom = getRightRenderContent({
155
- runtimeConfig,
156
- loading,
157
- initialState,
158
- setInitialState,
159
- });
160
- if (runtimeConfig.rightContentRender) {
161
- return runtimeConfig.rightContentRender(layoutProps, dom, {
162
- // BREAK CHANGE userConfig > runtimeConfig
163
- userConfig,
164
- runtimeConfig,
165
- loading,
166
- initialState,
167
- setInitialState,
168
- });
169
- }
170
- return dom;
171
- })
172
- }
173
- >
174
- <Exception
175
- route={matchedRoute}
176
- notFound={runtimeConfig.notFound}
177
- noAccessible={runtimeConfig.noAccessible}
178
- >
179
- {runtimeConfig.childrenRender
180
- ? runtimeConfig.childrenRender(<Outlet />, props)
181
- : <Outlet />
182
- }
183
- </Exception>
184
- </ProLayout>
185
- );
186
- }
187
- `,
188
- });
189
- const iconsMap = Object.keys(api.appData.routes).reduce((memo, id) => {
190
- const { icon } = api.appData.routes[id];
191
- if (icon) {
192
- const upperIcon = plugin_utils_1.lodash.upperFirst(plugin_utils_1.lodash.camelCase(icon));
193
- (0, assert_1.default)(
194
- // @ts-ignore
195
- allIcons[upperIcon] || allIcons[`${upperIcon}Outlined`], `Icon ${upperIcon} is not found`);
196
- // @ts-ignore
197
- if (allIcons[upperIcon]) {
198
- memo[upperIcon] = true;
199
- }
200
- // @ts-ignore
201
- if (allIcons[`${upperIcon}Outlined`]) {
202
- memo[`${upperIcon}Outlined`] = true;
203
- }
204
- }
205
- return memo;
206
- }, {});
207
- const icons = Object.keys(iconsMap);
208
- const antIconsPath = (0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('@ant-design/icons/package')));
209
- api.writeTmpFile({
210
- path: 'icons.tsx',
211
- content: `
212
- ${icons
213
- .map((icon) => {
214
- return `import ${icon} from '${antIconsPath}/es/icons/${icon}';`;
215
- })
216
- .join('\n')}
217
- export default { ${icons.join(', ')} };
218
- `,
219
- });
220
- // runtime.tsx
221
- api.writeTmpFile({
222
- path: 'runtime.tsx',
223
- content: `
224
- import React from 'react';
225
- import icons from './icons';
226
-
227
- function formatIcon(name: string) {
228
- return name
229
- .replace(name[0], name[0].toUpperCase())
230
- .replace(/-(\w)/g, function(all, letter) {
231
- return letter.toUpperCase();
232
- });
233
- }
234
-
235
- export function patchRoutes({ routes }) {
236
- Object.keys(routes).forEach(key => {
237
- const { icon } = routes[key];
238
- if (icon && typeof icon === 'string') {
239
- const upperIcon = formatIcon(icon);
240
- routes[key].icon = React.createElement(icons[upperIcon] || icons[upperIcon + 'Outlined']);
241
- }
242
- });
243
- }
244
- `,
245
- });
246
- const rightRenderContent = `
247
- import React from 'react';
248
- import { Avatar, Dropdown, Menu, Spin } from 'antd';
249
- import { LogoutOutlined } from '@ant-design/icons';
250
- {{#Locale}}
251
- import { SelectLang } from '@@/plugin-locale';
252
- {{/Locale}}
253
-
254
- export function getRightRenderContent (opts: {
255
- runtimeConfig: any,
256
- loading: boolean,
257
- initialState: any,
258
- setInitialState: any,
259
- }) {
260
- if (opts.runtimeConfig.rightRender) {
261
- return opts.runtimeConfig.rightRender(
262
- opts.initialState,
263
- opts.setInitialState,
264
- opts.runtimeConfig,
265
- );
266
- }
267
-
268
- const menu = (
269
- <Menu className="umi-plugin-layout-menu">
270
- <Menu.Item
271
- key="logout"
272
- onClick={() =>
273
- opts.runtimeConfig.logout && opts.runtimeConfig?.logout(opts.initialState)
274
- }
275
- >
276
- <LogoutOutlined />
277
- 退出登录
278
- </Menu.Item>
279
- </Menu>
280
- );
281
-
282
- const avatar = (
283
- <span className="umi-plugin-layout-action">
284
- <Avatar
285
- size="small"
286
- className="umi-plugin-layout-avatar"
287
- src={
288
- opts.initialState?.avatar ||
289
- 'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png'
290
- }
291
- alt="avatar"
292
- />
293
- <span className="umi-plugin-layout-name">{opts.initialState?.name}</span>
294
- </span>
295
- );
296
-
297
- if (opts.loading) {
298
- return (
299
- <div className="umi-plugin-layout-right">
300
- <Spin size="small" style={ { marginLeft: 8, marginRight: 8 } } />
301
- </div>
302
- );
303
- }
304
-
305
- return (
306
- <div className="umi-plugin-layout-right anticon">
307
- {opts.runtimeConfig.logout ? (
308
- <Dropdown overlay={menu} overlayClassName="umi-plugin-layout-container">
309
- {avatar}
310
- </Dropdown>
311
- ) : (
312
- avatar
313
- )}
314
- {{#Locale}}
315
- <SelectLang />
316
- {{/Locale}}
317
- </div>
318
- );
319
- }
320
- `;
321
- const Locale = api.isPluginEnable('locale');
322
- // rightRender.tsx
323
- api.writeTmpFile({
324
- path: 'rightRender.tsx',
325
- content: plugin_utils_1.Mustache.render(rightRenderContent, {
326
- Locale,
327
- }),
328
- });
329
- // Layout.less
330
- api.writeTmpFile({
331
- path: 'Layout.less',
332
- content: `
333
- @import '~antd/es/style/themes/default.less';
334
- @pro-header-hover-bg: rgba(0, 0, 0, 0.025);
335
- @media screen and (max-width: @screen-xs) {
336
- // 在小屏幕的时候可以有更好的体验
337
- .umi-plugin-layout-container {
338
- width: 100% !important;
339
- }
340
- .umi-plugin-layout-container > * {
341
- border-radius: 0 !important;
342
- }
343
- }
344
- .umi-plugin-layout-menu {
345
- .anticon {
346
- margin-right: 8px;
347
- }
348
- .ant-dropdown-menu-item {
349
- min-width: 160px;
350
- }
351
- }
352
- .umi-plugin-layout-right {
353
- display: flex !important;
354
- float: right;
355
- height: 100%;
356
- margin-left: auto;
357
- overflow: hidden;
358
- .umi-plugin-layout-action {
359
- display: flex;
360
- align-items: center;
361
- height: 100%;
362
- padding: 0 12px;
363
- cursor: pointer;
364
- transition: all 0.3s;
365
- > i {
366
- color: @text-color;
367
- vertical-align: middle;
368
- }
369
- &:hover {
370
- background: @pro-header-hover-bg;
371
- }
372
- &:global(.opened) {
373
- background: @pro-header-hover-bg;
374
- }
375
- }
376
- .umi-plugin-layout-search {
377
- padding: 0 12px;
378
- &:hover {
379
- background: transparent;
380
- }
381
- }
382
- }
383
- .umi-plugin-layout-name {
384
- margin-left: 8px;
385
- }
386
- `,
387
- });
388
- // Logo.tsx
389
- api.writeTmpFile({
390
- path: 'Logo.tsx',
391
- content: `
392
- import React from 'react';
393
-
394
- const LogoIcon: React.FC = () => {
395
- return (
396
- <svg
397
- xmlns="http://www.w3.org/2000/svg"
398
- width="32"
399
- height="32"
400
- viewBox="0 0 200 200"
401
- >
402
- <defs>
403
- <linearGradient
404
- id="linearGradient-1"
405
- x1="62.102%"
406
- x2="108.197%"
407
- y1="0%"
408
- y2="37.864%"
409
- >
410
- <stop offset="0%" stopColor="#4285EB"></stop>
411
- <stop offset="100%" stopColor="#2EC7FF"></stop>
412
- </linearGradient>
413
- <linearGradient
414
- id="linearGradient-2"
415
- x1="69.644%"
416
- x2="54.043%"
417
- y1="0%"
418
- y2="108.457%"
419
- >
420
- <stop offset="0%" stopColor="#29CDFF"></stop>
421
- <stop offset="37.86%" stopColor="#148EFF"></stop>
422
- <stop offset="100%" stopColor="#0A60FF"></stop>
423
- </linearGradient>
424
- <linearGradient
425
- id="linearGradient-3"
426
- x1="69.691%"
427
- x2="16.723%"
428
- y1="-12.974%"
429
- y2="117.391%"
430
- >
431
- <stop offset="0%" stopColor="#FA816E"></stop>
432
- <stop offset="41.473%" stopColor="#F74A5C"></stop>
433
- <stop offset="100%" stopColor="#F51D2C"></stop>
434
- </linearGradient>
435
- <linearGradient
436
- id="linearGradient-4"
437
- x1="68.128%"
438
- x2="30.44%"
439
- y1="-35.691%"
440
- y2="114.943%"
441
- >
442
- <stop offset="0%" stopColor="#FA8E7D"></stop>
443
- <stop offset="51.264%" stopColor="#F74A5C"></stop>
444
- <stop offset="100%" stopColor="#F51D2C"></stop>
445
- </linearGradient>
446
- </defs>
447
- <g fill="none" fillRule="evenodd" stroke="none" strokeWidth="1">
448
- <g transform="translate(-20 -20)">
449
- <g transform="translate(20 20)">
450
- <g>
451
- <g fillRule="nonzero">
452
- <g>
453
- <path
454
- fill="url(#linearGradient-1)"
455
- d="M91.588 4.177L4.18 91.513a11.981 11.981 0 000 16.974l87.408 87.336a12.005 12.005 0 0016.989 0l36.648-36.618c4.209-4.205 4.209-11.023 0-15.228-4.208-4.205-11.031-4.205-15.24 0l-27.783 27.76c-1.17 1.169-2.945 1.169-4.114 0l-69.802-69.744c-1.17-1.169-1.17-2.942 0-4.11l69.802-69.745c1.17-1.169 2.944-1.169 4.114 0l27.783 27.76c4.209 4.205 11.032 4.205 15.24 0 4.209-4.205 4.209-11.022 0-15.227L108.581 4.056c-4.719-4.594-12.312-4.557-16.993.12z"
456
- ></path>
457
- <path
458
- fill="url(#linearGradient-2)"
459
- d="M91.588 4.177L4.18 91.513a11.981 11.981 0 000 16.974l87.408 87.336a12.005 12.005 0 0016.989 0l36.648-36.618c4.209-4.205 4.209-11.023 0-15.228-4.208-4.205-11.031-4.205-15.24 0l-27.783 27.76c-1.17 1.169-2.945 1.169-4.114 0l-69.802-69.744c-1.17-1.169-1.17-2.942 0-4.11l69.802-69.745c2.912-2.51 7.664-7.596 14.642-8.786 5.186-.883 10.855 1.062 17.009 5.837L108.58 4.056c-4.719-4.594-12.312-4.557-16.993.12z"
460
- ></path>
461
- </g>
462
- <path
463
- fill="url(#linearGradient-3)"
464
- d="M153.686 135.855c4.208 4.205 11.031 4.205 15.24 0l27.034-27.012c4.7-4.696 4.7-12.28 0-16.974l-27.27-27.15c-4.218-4.2-11.043-4.195-15.254.013-4.209 4.205-4.209 11.022 0 15.227l18.418 18.403c1.17 1.169 1.17 2.943 0 4.111l-18.168 18.154c-4.209 4.205-4.209 11.023 0 15.228z"
465
- ></path>
466
- </g>
467
- <ellipse
468
- cx="100.519"
469
- cy="100.437"
470
- fill="url(#linearGradient-4)"
471
- rx="23.6"
472
- ry="23.581"
473
- ></ellipse>
474
- </g>
475
- </g>
476
- </g>
477
- </g>
478
- </svg>
479
- );
480
- };
481
-
482
- export default LogoIcon;
483
- `,
484
- });
485
- api.writeTmpFile({
486
- path: 'Exception.tsx',
487
- content: `
488
- import React from 'react';
489
- import { history, type IRoute } from 'umi';
490
- import { Result, Button } from 'antd';
491
-
492
- const Exception: React.FC<{
493
- children: React.ReactNode;
494
- route?: IRoute;
495
- notFound?: React.ReactNode;
496
- noAccessible?: React.ReactNode;
497
- }> = (props) => (
498
- // render custom 404
499
- (!props.route && props.notFound) ||
500
- // render custom 403
501
- (props.route.unaccessible && props.noAccessible) ||
502
- // render default exception
503
- ((!props.route || props.route.unaccessible) && (
504
- <Result
505
- status={props.route ? '403' : '404'}
506
- title={props.route ? '403' : '404'}
507
- subTitle={props.route ? '抱歉,你无权访问该页面' : '抱歉,你访问的页面不存在'}
508
- extra={
509
- <Button type="primary" onClick={() => history.push('/')}>
510
- 返回首页
511
- </Button>
512
- }
513
- />
514
- )) ||
515
- // normal render
516
- props.children
517
- );
518
-
519
- export default Exception;
520
- `,
521
- });
522
- });
523
- api.addLayouts(() => {
524
- return [
525
- {
526
- id: 'ant-design-pro-layout',
527
- file: (0, withTmpPath_1.withTmpPath)({ api, path: 'Layout.tsx' }),
528
- test: (route) => {
529
- return route.layout !== false;
530
- },
531
- },
532
- ];
533
- });
534
- api.addRuntimePluginKey(() => ['layout']);
535
- api.addRuntimePlugin(() => {
536
- return [(0, withTmpPath_1.withTmpPath)({ api, path: 'runtime.tsx' })];
537
- });
538
- };
package/dist/locale.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import { IApi } from 'umi';
2
- export declare const packageNormalize: (packageName: string) => string;
3
- declare const _default: (api: IApi) => void;
4
- export default _default;