@umijs/plugins 4.0.0-beta.9 → 4.0.0-rc.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.
- package/README.md +4 -1
- package/dist/access.js +73 -1
- package/dist/{sass.d.ts → analytics.d.ts} +0 -0
- package/dist/analytics.js +67 -0
- package/dist/antd.js +89 -145
- package/dist/dva.d.ts +3 -0
- package/dist/dva.js +168 -4
- package/dist/initial-state.js +112 -1
- package/dist/layout.js +479 -1
- package/dist/locale.d.ts +1 -0
- package/dist/locale.js +199 -1
- package/dist/model.js +112 -1
- package/dist/moment2dayjs.d.ts +3 -0
- package/dist/moment2dayjs.js +96 -0
- package/dist/qiankun/constants.d.ts +5 -0
- package/dist/qiankun/constants.js +8 -0
- package/dist/qiankun/master.d.ts +6 -0
- package/dist/qiankun/master.js +114 -0
- package/dist/qiankun/slave.d.ts +3 -0
- package/dist/qiankun/slave.js +141 -0
- package/dist/qiankun.js +15 -1
- package/dist/request.js +300 -1
- package/dist/tailwindcss.d.ts +3 -0
- package/dist/tailwindcss.js +38 -0
- package/dist/unocss.d.ts +3 -0
- package/dist/unocss.js +57 -0
- package/dist/utils/astUtils.d.ts +3 -0
- package/dist/utils/astUtils.js +34 -0
- package/dist/utils/localeUtils.d.ts +33 -0
- package/dist/utils/localeUtils.js +135 -0
- package/dist/utils/modelUtils.d.ts +35 -0
- package/dist/utils/modelUtils.js +145 -0
- package/dist/utils/resolveProjectDep.d.ts +5 -0
- package/dist/utils/resolveProjectDep.js +15 -0
- package/dist/utils/withTmpPath.d.ts +6 -0
- package/dist/utils/withTmpPath.js +11 -0
- package/libs/dva.ts +10 -0
- package/libs/locale/SelectLang.tpl +478 -0
- package/libs/locale/locale.tpl +82 -0
- package/libs/locale/localeExports.tpl +271 -0
- package/libs/locale/runtime.tpl +33 -0
- package/libs/model.tsx +140 -0
- package/libs/qiankun/master/AntdErrorBoundary.tsx +34 -0
- package/libs/qiankun/master/AntdLoader.tsx +15 -0
- package/libs/qiankun/master/ErrorBoundary.tsx +7 -0
- package/libs/qiankun/master/MicroApp.tsx +262 -0
- package/libs/qiankun/master/MicroAppWithMemoHistory.tsx +43 -0
- package/libs/qiankun/master/common.ts +133 -0
- package/libs/qiankun/master/constants.ts +7 -0
- package/libs/qiankun/master/getMicroAppRouteComponent.tsx.tpl +45 -0
- package/libs/qiankun/master/masterRuntimePlugin.tsx +130 -0
- package/libs/qiankun/master/types.ts +44 -0
- package/libs/qiankun/slave/connectMaster.tsx +15 -0
- package/libs/qiankun/slave/lifecycles.ts +149 -0
- package/libs/qiankun/slave/qiankunModel.ts +19 -0
- package/libs/qiankun/slave/slaveRuntimePlugin.ts +21 -0
- package/package.json +21 -5
- package/dist/sass.js +0 -5
package/dist/initial-state.js
CHANGED
|
@@ -1,5 +1,116 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const withTmpPath_1 = require("./utils/withTmpPath");
|
|
3
4
|
exports.default = (api) => {
|
|
4
|
-
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>loading</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 innerProvider(container) {
|
|
111
|
+
return <Provider>{ container }</Provider>;
|
|
112
|
+
}
|
|
113
|
+
`,
|
|
114
|
+
});
|
|
115
|
+
});
|
|
5
116
|
};
|
package/dist/layout.js
CHANGED
|
@@ -1,5 +1,483 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
2
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
const allIcons = __importStar(require("@ant-design/icons"));
|
|
26
|
+
const assert_1 = __importDefault(require("assert"));
|
|
27
|
+
const path_1 = require("path");
|
|
28
|
+
const plugin_utils_1 = require("umi/plugin-utils");
|
|
29
|
+
const resolveProjectDep_1 = require("./utils/resolveProjectDep");
|
|
30
|
+
const withTmpPath_1 = require("./utils/withTmpPath");
|
|
3
31
|
exports.default = (api) => {
|
|
4
|
-
api
|
|
32
|
+
api.describe({
|
|
33
|
+
key: 'layout',
|
|
34
|
+
config: {
|
|
35
|
+
schema(joi) {
|
|
36
|
+
return joi.object();
|
|
37
|
+
},
|
|
38
|
+
onChange: api.ConfigChangeType.regenerateTmpFiles,
|
|
39
|
+
},
|
|
40
|
+
enableBy: api.EnableBy.config,
|
|
41
|
+
});
|
|
42
|
+
const pkgPath = (0, resolveProjectDep_1.resolveProjectDep)({
|
|
43
|
+
pkg: api.pkg,
|
|
44
|
+
cwd: api.cwd,
|
|
45
|
+
dep: '@ant-design/pro-layout',
|
|
46
|
+
}) || (0, path_1.dirname)(require.resolve('@ant-design/pro-layout/package.json'));
|
|
47
|
+
api.modifyAppData((memo) => {
|
|
48
|
+
const version = require(`${pkgPath}/package.json`).version;
|
|
49
|
+
memo.pluginLayout = {
|
|
50
|
+
pkgPath,
|
|
51
|
+
version,
|
|
52
|
+
};
|
|
53
|
+
return memo;
|
|
54
|
+
});
|
|
55
|
+
api.modifyConfig((memo) => {
|
|
56
|
+
// import from @ant-design/pro-layout
|
|
57
|
+
memo.alias['@ant-design/pro-layout'] = pkgPath;
|
|
58
|
+
return memo;
|
|
59
|
+
});
|
|
60
|
+
api.onGenerateFiles(() => {
|
|
61
|
+
const hasInitialStatePlugin = api.config.initialState;
|
|
62
|
+
// Layout.tsx
|
|
63
|
+
api.writeTmpFile({
|
|
64
|
+
path: 'Layout.tsx',
|
|
65
|
+
content: `
|
|
66
|
+
import { Link, useLocation, useNavigate, Outlet, useAppData, useRouteContext } from 'umi';
|
|
67
|
+
import ProLayout, {
|
|
68
|
+
PageLoading,
|
|
69
|
+
} from '@ant-design/pro-layout';
|
|
70
|
+
import './Layout.less';
|
|
71
|
+
import Logo from './Logo';
|
|
72
|
+
import { getRightRenderContent } from './rightRender';
|
|
73
|
+
${hasInitialStatePlugin
|
|
74
|
+
? `import { useModel } from '@@/plugin-model';`
|
|
75
|
+
: 'const useModel = null;'}
|
|
76
|
+
|
|
77
|
+
${api.config.locale
|
|
78
|
+
? `
|
|
79
|
+
import { useIntl } from '@@/plugin-locale';
|
|
80
|
+
`.trim()
|
|
81
|
+
: ''}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
export default () => {
|
|
85
|
+
const location = useLocation();
|
|
86
|
+
const navigate = useNavigate();
|
|
87
|
+
const { clientRoutes, pluginManager } = useAppData();
|
|
88
|
+
const initialInfo = (useModel && useModel('@@initialState')) || {
|
|
89
|
+
initialState: undefined,
|
|
90
|
+
loading: false,
|
|
91
|
+
setInitialState: null,
|
|
92
|
+
};
|
|
93
|
+
const { initialState, loading, setInitialState } = initialInfo;
|
|
94
|
+
const userConfig = ${JSON.stringify(api.config.layout, null, 2)};
|
|
95
|
+
${api.config.locale
|
|
96
|
+
? `
|
|
97
|
+
const { formatMessage } = useIntl();
|
|
98
|
+
`.trim()
|
|
99
|
+
: 'const formatMessage = undefined;'}
|
|
100
|
+
const runtimeConfig = pluginManager.applyPlugins({
|
|
101
|
+
key: 'layout',
|
|
102
|
+
type: 'modify',
|
|
103
|
+
initialValue: {
|
|
104
|
+
...initialInfo
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
const route = clientRoutes.filter(r => {
|
|
108
|
+
return r.id === 'ant-design-pro-layout';
|
|
109
|
+
})[0];
|
|
110
|
+
return (
|
|
111
|
+
<ProLayout
|
|
112
|
+
route={route}
|
|
113
|
+
location={location}
|
|
114
|
+
title={userConfig.title || 'plugin-layout'}
|
|
115
|
+
navTheme="dark"
|
|
116
|
+
siderWidth={256}
|
|
117
|
+
onMenuHeaderClick={(e) => {
|
|
118
|
+
e.stopPropagation();
|
|
119
|
+
e.preventDefault();
|
|
120
|
+
navigate('/');
|
|
121
|
+
}}
|
|
122
|
+
formatMessage={userConfig.formatMessage || formatMessage}
|
|
123
|
+
menu={{ locale: userConfig.locale }}
|
|
124
|
+
logo={Logo}
|
|
125
|
+
menuItemRender={(menuItemProps, defaultDom) => {
|
|
126
|
+
if (menuItemProps.isUrl || menuItemProps.children) {
|
|
127
|
+
return defaultDom;
|
|
128
|
+
}
|
|
129
|
+
if (menuItemProps.path && location.pathname !== menuItemProps.path) {
|
|
130
|
+
return (
|
|
131
|
+
<Link to={menuItemProps.path} target={menuItemProps.target}>
|
|
132
|
+
{defaultDom}
|
|
133
|
+
</Link>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
return defaultDom;
|
|
137
|
+
}}
|
|
138
|
+
disableContentMargin
|
|
139
|
+
fixSiderbar
|
|
140
|
+
fixedHeader
|
|
141
|
+
{...runtimeConfig}
|
|
142
|
+
rightContentRender={
|
|
143
|
+
runtimeConfig.rightContentRender !== false &&
|
|
144
|
+
((layoutProps) => {
|
|
145
|
+
const dom = getRightRenderContent({
|
|
146
|
+
runtimeConfig,
|
|
147
|
+
loading,
|
|
148
|
+
initialState,
|
|
149
|
+
setInitialState,
|
|
150
|
+
});
|
|
151
|
+
if (runtimeConfig.rightContentRender) {
|
|
152
|
+
return runtimeConfig.rightContentRender(layoutProps, dom, {
|
|
153
|
+
// BREAK CHANGE userConfig > runtimeConfig
|
|
154
|
+
userConfig,
|
|
155
|
+
runtimeConfig,
|
|
156
|
+
loading,
|
|
157
|
+
initialState,
|
|
158
|
+
setInitialState,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
return dom;
|
|
162
|
+
})
|
|
163
|
+
}
|
|
164
|
+
>
|
|
165
|
+
<Outlet />
|
|
166
|
+
</ProLayout>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
`,
|
|
170
|
+
});
|
|
171
|
+
const iconsMap = Object.keys(api.appData.routes).reduce((memo, id) => {
|
|
172
|
+
const { icon } = api.appData.routes[id];
|
|
173
|
+
if (icon) {
|
|
174
|
+
const upperIcon = plugin_utils_1.lodash.upperFirst(plugin_utils_1.lodash.camelCase(icon));
|
|
175
|
+
(0, assert_1.default)(
|
|
176
|
+
// @ts-ignore
|
|
177
|
+
allIcons[upperIcon] || allIcons[`${upperIcon}Outlined`], `Icon ${upperIcon} is not found`);
|
|
178
|
+
// @ts-ignore
|
|
179
|
+
if (allIcons[upperIcon]) {
|
|
180
|
+
memo[upperIcon] = true;
|
|
181
|
+
}
|
|
182
|
+
// @ts-ignore
|
|
183
|
+
if (allIcons[`${upperIcon}Outlined`]) {
|
|
184
|
+
memo[`${upperIcon}Outlined`] = true;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return memo;
|
|
188
|
+
}, {});
|
|
189
|
+
const icons = Object.keys(iconsMap);
|
|
190
|
+
const antIconsPath = (0, path_1.dirname)(require.resolve('@ant-design/icons/package'));
|
|
191
|
+
api.writeTmpFile({
|
|
192
|
+
path: 'icons.tsx',
|
|
193
|
+
content: `
|
|
194
|
+
${icons
|
|
195
|
+
.map((icon) => {
|
|
196
|
+
return `import ${icon} from '${antIconsPath}/es/icons/${icon}';`;
|
|
197
|
+
})
|
|
198
|
+
.join('\n')}
|
|
199
|
+
export default { ${icons.join(', ')} };
|
|
200
|
+
`,
|
|
201
|
+
});
|
|
202
|
+
// runtime.tsx
|
|
203
|
+
api.writeTmpFile({
|
|
204
|
+
path: 'runtime.tsx',
|
|
205
|
+
content: `
|
|
206
|
+
import React from 'react';
|
|
207
|
+
import icons from './icons';
|
|
208
|
+
|
|
209
|
+
function formatIcon(name: string) {
|
|
210
|
+
return name
|
|
211
|
+
.replace(name[0], name[0].toUpperCase())
|
|
212
|
+
.replace(/-(\w)/g, function(all, letter) {
|
|
213
|
+
return letter.toUpperCase();
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export function patchRoutes({ routes }) {
|
|
218
|
+
Object.keys(routes).forEach(key => {
|
|
219
|
+
const { icon } = routes[key];
|
|
220
|
+
if (icon && typeof icon === 'string') {
|
|
221
|
+
const upperIcon = formatIcon(icon);
|
|
222
|
+
routes[key].icon = React.createElement(icons[upperIcon] || icons[upperIcon + 'Outlined']);
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
`,
|
|
227
|
+
});
|
|
228
|
+
const rightRenderContent = `
|
|
229
|
+
import React from 'react';
|
|
230
|
+
import { Avatar, Dropdown, Menu, Spin } from 'antd';
|
|
231
|
+
import { LogoutOutlined } from '@ant-design/icons';
|
|
232
|
+
{{#Locale}}
|
|
233
|
+
import { SelectLang } from '@@/plugin-locale';
|
|
234
|
+
{{/Locale}}
|
|
235
|
+
|
|
236
|
+
export function getRightRenderContent (opts: {
|
|
237
|
+
runtimeConfig: any,
|
|
238
|
+
loading: boolean,
|
|
239
|
+
initialState: any,
|
|
240
|
+
setInitialState: any,
|
|
241
|
+
}) {
|
|
242
|
+
if (opts.runtimeConfig.rightRender) {
|
|
243
|
+
return opts.runtimeConfig.rightRender(
|
|
244
|
+
opts.initialState,
|
|
245
|
+
opts.setInitialState,
|
|
246
|
+
opts.runtimeConfig,
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const menu = (
|
|
251
|
+
<Menu className="umi-plugin-layout-menu">
|
|
252
|
+
<Menu.Item
|
|
253
|
+
key="logout"
|
|
254
|
+
onClick={() =>
|
|
255
|
+
opts.runtimeConfig.logout && opts.runtimeConfig?.logout(opts.initialState)
|
|
256
|
+
}
|
|
257
|
+
>
|
|
258
|
+
<LogoutOutlined />
|
|
259
|
+
退出登录
|
|
260
|
+
</Menu.Item>
|
|
261
|
+
</Menu>
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
const avatar = (
|
|
265
|
+
<span className="umi-plugin-layout-action">
|
|
266
|
+
<Avatar
|
|
267
|
+
size="small"
|
|
268
|
+
className="umi-plugin-layout-avatar"
|
|
269
|
+
src={
|
|
270
|
+
opts.initialState?.avatar ||
|
|
271
|
+
'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png'
|
|
272
|
+
}
|
|
273
|
+
alt="avatar"
|
|
274
|
+
/>
|
|
275
|
+
<span className="umi-plugin-layout-name">{opts.initialState?.name}</span>
|
|
276
|
+
</span>
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
if (opts.loading) {
|
|
280
|
+
return (
|
|
281
|
+
<div className="umi-plugin-layout-right">
|
|
282
|
+
<Spin size="small" style={ { marginLeft: 8, marginRight: 8 } } />
|
|
283
|
+
</div>
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return (
|
|
288
|
+
<div className="umi-plugin-layout-right anticon">
|
|
289
|
+
{opts.runtimeConfig.logout ? (
|
|
290
|
+
<Dropdown overlay={menu} overlayClassName="umi-plugin-layout-container">
|
|
291
|
+
{avatar}
|
|
292
|
+
</Dropdown>
|
|
293
|
+
) : (
|
|
294
|
+
avatar
|
|
295
|
+
)}
|
|
296
|
+
{{#Locale}}
|
|
297
|
+
<SelectLang />
|
|
298
|
+
{{/Locale}}
|
|
299
|
+
</div>
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
`;
|
|
303
|
+
const Locale = api.isPluginEnable('locale');
|
|
304
|
+
// rightRender.tsx
|
|
305
|
+
api.writeTmpFile({
|
|
306
|
+
path: 'rightRender.tsx',
|
|
307
|
+
content: plugin_utils_1.Mustache.render(rightRenderContent, {
|
|
308
|
+
Locale,
|
|
309
|
+
}),
|
|
310
|
+
});
|
|
311
|
+
// Layout.less
|
|
312
|
+
api.writeTmpFile({
|
|
313
|
+
path: 'Layout.less',
|
|
314
|
+
content: `
|
|
315
|
+
@import '~antd/es/style/themes/default.less';
|
|
316
|
+
@pro-header-hover-bg: rgba(0, 0, 0, 0.025);
|
|
317
|
+
@media screen and (max-width: @screen-xs) {
|
|
318
|
+
// 在小屏幕的时候可以有更好的体验
|
|
319
|
+
.umi-plugin-layout-container {
|
|
320
|
+
width: 100% !important;
|
|
321
|
+
}
|
|
322
|
+
.umi-plugin-layout-container > * {
|
|
323
|
+
border-radius: 0 !important;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
.umi-plugin-layout-menu {
|
|
327
|
+
.anticon {
|
|
328
|
+
margin-right: 8px;
|
|
329
|
+
}
|
|
330
|
+
.ant-dropdown-menu-item {
|
|
331
|
+
min-width: 160px;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
.umi-plugin-layout-right {
|
|
335
|
+
display: flex !important;
|
|
336
|
+
float: right;
|
|
337
|
+
height: 100%;
|
|
338
|
+
margin-left: auto;
|
|
339
|
+
overflow: hidden;
|
|
340
|
+
.umi-plugin-layout-action {
|
|
341
|
+
display: flex;
|
|
342
|
+
align-items: center;
|
|
343
|
+
height: 100%;
|
|
344
|
+
padding: 0 12px;
|
|
345
|
+
cursor: pointer;
|
|
346
|
+
transition: all 0.3s;
|
|
347
|
+
> i {
|
|
348
|
+
color: @text-color;
|
|
349
|
+
vertical-align: middle;
|
|
350
|
+
}
|
|
351
|
+
&:hover {
|
|
352
|
+
background: @pro-header-hover-bg;
|
|
353
|
+
}
|
|
354
|
+
&:global(.opened) {
|
|
355
|
+
background: @pro-header-hover-bg;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
.umi-plugin-layout-search {
|
|
359
|
+
padding: 0 12px;
|
|
360
|
+
&:hover {
|
|
361
|
+
background: transparent;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
.umi-plugin-layout-name {
|
|
366
|
+
margin-left: 8px;
|
|
367
|
+
}
|
|
368
|
+
`,
|
|
369
|
+
});
|
|
370
|
+
// Logo.tsx
|
|
371
|
+
api.writeTmpFile({
|
|
372
|
+
path: 'Logo.tsx',
|
|
373
|
+
content: `
|
|
374
|
+
import React from 'react';
|
|
375
|
+
|
|
376
|
+
const LogoIcon: React.FC = () => {
|
|
377
|
+
return (
|
|
378
|
+
<svg
|
|
379
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
380
|
+
width="32"
|
|
381
|
+
height="32"
|
|
382
|
+
viewBox="0 0 200 200"
|
|
383
|
+
>
|
|
384
|
+
<defs>
|
|
385
|
+
<linearGradient
|
|
386
|
+
id="linearGradient-1"
|
|
387
|
+
x1="62.102%"
|
|
388
|
+
x2="108.197%"
|
|
389
|
+
y1="0%"
|
|
390
|
+
y2="37.864%"
|
|
391
|
+
>
|
|
392
|
+
<stop offset="0%" stopColor="#4285EB"></stop>
|
|
393
|
+
<stop offset="100%" stopColor="#2EC7FF"></stop>
|
|
394
|
+
</linearGradient>
|
|
395
|
+
<linearGradient
|
|
396
|
+
id="linearGradient-2"
|
|
397
|
+
x1="69.644%"
|
|
398
|
+
x2="54.043%"
|
|
399
|
+
y1="0%"
|
|
400
|
+
y2="108.457%"
|
|
401
|
+
>
|
|
402
|
+
<stop offset="0%" stopColor="#29CDFF"></stop>
|
|
403
|
+
<stop offset="37.86%" stopColor="#148EFF"></stop>
|
|
404
|
+
<stop offset="100%" stopColor="#0A60FF"></stop>
|
|
405
|
+
</linearGradient>
|
|
406
|
+
<linearGradient
|
|
407
|
+
id="linearGradient-3"
|
|
408
|
+
x1="69.691%"
|
|
409
|
+
x2="16.723%"
|
|
410
|
+
y1="-12.974%"
|
|
411
|
+
y2="117.391%"
|
|
412
|
+
>
|
|
413
|
+
<stop offset="0%" stopColor="#FA816E"></stop>
|
|
414
|
+
<stop offset="41.473%" stopColor="#F74A5C"></stop>
|
|
415
|
+
<stop offset="100%" stopColor="#F51D2C"></stop>
|
|
416
|
+
</linearGradient>
|
|
417
|
+
<linearGradient
|
|
418
|
+
id="linearGradient-4"
|
|
419
|
+
x1="68.128%"
|
|
420
|
+
x2="30.44%"
|
|
421
|
+
y1="-35.691%"
|
|
422
|
+
y2="114.943%"
|
|
423
|
+
>
|
|
424
|
+
<stop offset="0%" stopColor="#FA8E7D"></stop>
|
|
425
|
+
<stop offset="51.264%" stopColor="#F74A5C"></stop>
|
|
426
|
+
<stop offset="100%" stopColor="#F51D2C"></stop>
|
|
427
|
+
</linearGradient>
|
|
428
|
+
</defs>
|
|
429
|
+
<g fill="none" fillRule="evenodd" stroke="none" strokeWidth="1">
|
|
430
|
+
<g transform="translate(-20 -20)">
|
|
431
|
+
<g transform="translate(20 20)">
|
|
432
|
+
<g>
|
|
433
|
+
<g fillRule="nonzero">
|
|
434
|
+
<g>
|
|
435
|
+
<path
|
|
436
|
+
fill="url(#linearGradient-1)"
|
|
437
|
+
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"
|
|
438
|
+
></path>
|
|
439
|
+
<path
|
|
440
|
+
fill="url(#linearGradient-2)"
|
|
441
|
+
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"
|
|
442
|
+
></path>
|
|
443
|
+
</g>
|
|
444
|
+
<path
|
|
445
|
+
fill="url(#linearGradient-3)"
|
|
446
|
+
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"
|
|
447
|
+
></path>
|
|
448
|
+
</g>
|
|
449
|
+
<ellipse
|
|
450
|
+
cx="100.519"
|
|
451
|
+
cy="100.437"
|
|
452
|
+
fill="url(#linearGradient-4)"
|
|
453
|
+
rx="23.6"
|
|
454
|
+
ry="23.581"
|
|
455
|
+
></ellipse>
|
|
456
|
+
</g>
|
|
457
|
+
</g>
|
|
458
|
+
</g>
|
|
459
|
+
</g>
|
|
460
|
+
</svg>
|
|
461
|
+
);
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
export default LogoIcon;
|
|
465
|
+
`,
|
|
466
|
+
});
|
|
467
|
+
});
|
|
468
|
+
api.addLayouts(() => {
|
|
469
|
+
return [
|
|
470
|
+
{
|
|
471
|
+
id: 'ant-design-pro-layout',
|
|
472
|
+
file: (0, withTmpPath_1.withTmpPath)({ api, path: 'Layout.tsx' }),
|
|
473
|
+
test: (route) => {
|
|
474
|
+
return route.layout !== false;
|
|
475
|
+
},
|
|
476
|
+
},
|
|
477
|
+
];
|
|
478
|
+
});
|
|
479
|
+
api.addRuntimePluginKey(() => ['layout']);
|
|
480
|
+
api.addRuntimePlugin(() => {
|
|
481
|
+
return [(0, withTmpPath_1.withTmpPath)({ api, path: 'runtime.tsx' })];
|
|
482
|
+
});
|
|
5
483
|
};
|
package/dist/locale.d.ts
CHANGED