@umijs/plugins 4.0.0-rc.6 → 4.0.0-rc.9
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 +58 -1
- package/dist/antd.js +21 -5
- package/dist/dva.js +13 -0
- package/dist/layout.js +58 -7
- package/dist/locale.js +23 -25
- package/dist/request.js +1 -0
- package/dist/tailwindcss.js +2 -2
- package/dist/unocss.js +14 -36
- package/package.json +9 -6
package/dist/access.js
CHANGED
|
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
const path_1 = require("path");
|
|
13
13
|
const withTmpPath_1 = require("./utils/withTmpPath");
|
|
14
14
|
exports.default = (api) => {
|
|
15
|
-
// TODO: route access
|
|
16
15
|
api.describe({
|
|
17
16
|
config: {
|
|
18
17
|
schema(joi) {
|
|
@@ -52,10 +51,68 @@ export function accessProvider(container) {
|
|
|
52
51
|
content: `
|
|
53
52
|
import React from 'react';
|
|
54
53
|
import { AccessContext } from './context';
|
|
54
|
+
import type { IRoute } from 'umi';
|
|
55
55
|
|
|
56
56
|
export const useAccess = () => {
|
|
57
57
|
return React.useContext(AccessContext);
|
|
58
58
|
};
|
|
59
|
+
|
|
60
|
+
export interface AccessProps {
|
|
61
|
+
accessible: boolean;
|
|
62
|
+
fallback?: React.ReactNode;
|
|
63
|
+
}
|
|
64
|
+
export const Access: React.FC<AccessProps> = (props) => {
|
|
65
|
+
if (process.env.NODE_ENV === 'development' && typeof props.accessible !== 'boolean') {
|
|
66
|
+
throw new Error('[access] the \`accessible\` property on <Access /> should be a boolean');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return props.accessible ? props.children : props.fallback;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const useAccessMarkedRoutes = (routes: IRoute[]) => {
|
|
73
|
+
const access = useAccess();
|
|
74
|
+
const markdedRoutes: IRoute[] = React.useMemo(() => {
|
|
75
|
+
const process = (route, parentAccessCode) => {
|
|
76
|
+
const accessCode = route.access || parentAccessCode;
|
|
77
|
+
|
|
78
|
+
// set default status
|
|
79
|
+
route.unaccessible = ${api.config.access.strictMode ? 'true' : 'false'};
|
|
80
|
+
|
|
81
|
+
// check access code
|
|
82
|
+
if (typeof accessCode === 'string') {
|
|
83
|
+
const detector = access[route.access];
|
|
84
|
+
|
|
85
|
+
if (typeof detector === 'function') {
|
|
86
|
+
route.unaccessible = !detector(route);
|
|
87
|
+
} else if (typeof detector === 'boolean') {
|
|
88
|
+
route.unaccessible = !detector;
|
|
89
|
+
} else if (typeof detector === 'undefined') {
|
|
90
|
+
route.unaccessible = true;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// check children access code
|
|
95
|
+
if (route.routes) {
|
|
96
|
+
const isNoAccessibleChild = !route.routes.reduce((hasAccessibleChild, child) => {
|
|
97
|
+
process(child, accessCode);
|
|
98
|
+
|
|
99
|
+
return hasAccessibleChild || !child.unaccessible;
|
|
100
|
+
}, false);
|
|
101
|
+
|
|
102
|
+
// make sure parent route is unaccessible if all children are unaccessible
|
|
103
|
+
if (isNoAccessibleChild) {
|
|
104
|
+
route.unaccessible = true;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return route;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return routes.map(route => process(route));
|
|
112
|
+
}, [routes.length]);
|
|
113
|
+
|
|
114
|
+
return markdedRoutes;
|
|
115
|
+
}
|
|
59
116
|
`,
|
|
60
117
|
});
|
|
61
118
|
// context.ts
|
package/dist/antd.js
CHANGED
|
@@ -5,11 +5,16 @@ const plugin_utils_1 = require("umi/plugin-utils");
|
|
|
5
5
|
const resolveProjectDep_1 = require("./utils/resolveProjectDep");
|
|
6
6
|
const withTmpPath_1 = require("./utils/withTmpPath");
|
|
7
7
|
exports.default = (api) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
let pkgPath;
|
|
9
|
+
try {
|
|
10
|
+
pkgPath =
|
|
11
|
+
(0, resolveProjectDep_1.resolveProjectDep)({
|
|
12
|
+
pkg: api.pkg,
|
|
13
|
+
cwd: api.cwd,
|
|
14
|
+
dep: 'antd',
|
|
15
|
+
}) || (0, path_1.dirname)(require.resolve('antd/package.json'));
|
|
16
|
+
}
|
|
17
|
+
catch (e) { }
|
|
13
18
|
api.describe({
|
|
14
19
|
config: {
|
|
15
20
|
schema(Joi) {
|
|
@@ -27,7 +32,13 @@ exports.default = (api) => {
|
|
|
27
32
|
},
|
|
28
33
|
enableBy: api.EnableBy.config,
|
|
29
34
|
});
|
|
35
|
+
function checkPkgPath() {
|
|
36
|
+
if (!pkgPath) {
|
|
37
|
+
throw new Error(`Can't find antd package. Please install antd first.`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
30
40
|
api.modifyAppData((memo) => {
|
|
41
|
+
checkPkgPath();
|
|
31
42
|
const version = require(`${pkgPath}/package.json`).version;
|
|
32
43
|
memo.antd = {
|
|
33
44
|
pkgPath,
|
|
@@ -36,6 +47,7 @@ exports.default = (api) => {
|
|
|
36
47
|
return memo;
|
|
37
48
|
});
|
|
38
49
|
api.modifyConfig((memo) => {
|
|
50
|
+
checkPkgPath();
|
|
39
51
|
// antd import
|
|
40
52
|
memo.alias.antd = pkgPath;
|
|
41
53
|
// moment > dayjs
|
|
@@ -49,6 +61,10 @@ exports.default = (api) => {
|
|
|
49
61
|
}
|
|
50
62
|
return memo;
|
|
51
63
|
});
|
|
64
|
+
api.modifyConfig((memo) => {
|
|
65
|
+
memo.theme = Object.assign({ 'root-entry-name': 'default' }, memo.theme);
|
|
66
|
+
return memo;
|
|
67
|
+
});
|
|
52
68
|
// babel-plugin-import
|
|
53
69
|
api.addExtraBabelPlugins(() => {
|
|
54
70
|
const style = api.config.antd.style || 'less';
|
package/dist/dva.js
CHANGED
|
@@ -29,6 +29,7 @@ const path_1 = require("path");
|
|
|
29
29
|
const plugin_utils_1 = require("umi/plugin-utils");
|
|
30
30
|
const modelUtils_1 = require("./utils/modelUtils");
|
|
31
31
|
const withTmpPath_1 = require("./utils/withTmpPath");
|
|
32
|
+
const utils_1 = require("@umijs/utils");
|
|
32
33
|
exports.default = (api) => {
|
|
33
34
|
const pkgPath = (0, path_1.join)(__dirname, '../libs/dva.ts');
|
|
34
35
|
api.describe({
|
|
@@ -36,6 +37,7 @@ exports.default = (api) => {
|
|
|
36
37
|
schema(Joi) {
|
|
37
38
|
return Joi.object({
|
|
38
39
|
extraModels: Joi.array().items(Joi.string()),
|
|
40
|
+
immer: Joi.object(),
|
|
39
41
|
});
|
|
40
42
|
},
|
|
41
43
|
},
|
|
@@ -55,6 +57,7 @@ exports.default = (api) => {
|
|
|
55
57
|
return memo;
|
|
56
58
|
});
|
|
57
59
|
api.onGenerateFiles((args) => {
|
|
60
|
+
var _a, _b, _c, _d, _e, _f;
|
|
58
61
|
const models = args.isFirstTime
|
|
59
62
|
? api.appData.pluginDva.models
|
|
60
63
|
: getAllModels(api);
|
|
@@ -70,6 +73,12 @@ exports.default = (api) => {
|
|
|
70
73
|
// It's faked dva
|
|
71
74
|
// aliased to @umijs/plugins/templates/dva
|
|
72
75
|
import { create, Provider } from 'dva';
|
|
76
|
+
import createLoading from '${(0, utils_1.winPath)(require.resolve('dva-loading'))}';
|
|
77
|
+
${((_a = api.config.dva) === null || _a === void 0 ? void 0 : _a.immer)
|
|
78
|
+
? `
|
|
79
|
+
import dvaImmer, { enableES5, enableAllPlugins } from '${(0, utils_1.winPath)(require.resolve('dva-immer'))}';
|
|
80
|
+
`
|
|
81
|
+
: ''}
|
|
73
82
|
import React, { useRef } from 'react';
|
|
74
83
|
import { history } from 'umi';
|
|
75
84
|
import { models } from './models';
|
|
@@ -91,6 +100,10 @@ export function RootContainer(props: any) {
|
|
|
91
100
|
},
|
|
92
101
|
},
|
|
93
102
|
);
|
|
103
|
+
app.current.use(createLoading());
|
|
104
|
+
${((_b = api.config.dva) === null || _b === void 0 ? void 0 : _b.immer) ? `app.current.use(dvaImmer());` : ''}
|
|
105
|
+
${((_d = (_c = api.config.dva) === null || _c === void 0 ? void 0 : _c.immer) === null || _d === void 0 ? void 0 : _d.enableES5) ? `enableES5();` : ''}
|
|
106
|
+
${((_f = (_e = api.config.dva) === null || _e === void 0 ? void 0 : _e.immer) === null || _f === void 0 ? void 0 : _f.enableAllPlugins) ? `enableAllPlugins();` : ''}
|
|
94
107
|
for (const id of Object.keys(models)) {
|
|
95
108
|
app.current.model(models[id].model);
|
|
96
109
|
}
|
package/dist/layout.js
CHANGED
|
@@ -67,17 +67,23 @@ exports.default = (api) => {
|
|
|
67
67
|
api.writeTmpFile({
|
|
68
68
|
path: 'Layout.tsx',
|
|
69
69
|
content: `
|
|
70
|
-
import { Link, useLocation, useNavigate, Outlet, useAppData,
|
|
70
|
+
import { Link, useLocation, useNavigate, Outlet, useAppData, useRouteData, matchRoutes } from 'umi';
|
|
71
|
+
import { useMemo } from 'react';
|
|
71
72
|
import ProLayout, {
|
|
72
73
|
PageLoading,
|
|
73
74
|
} from '@ant-design/pro-layout';
|
|
74
75
|
import './Layout.less';
|
|
75
76
|
import Logo from './Logo';
|
|
77
|
+
import Exception from './Exception';
|
|
76
78
|
import { getRightRenderContent } from './rightRender';
|
|
77
79
|
${hasInitialStatePlugin
|
|
78
80
|
? `import { useModel } from '@@/plugin-model';`
|
|
79
81
|
: 'const useModel = null;'}
|
|
80
|
-
|
|
82
|
+
${api.config.access
|
|
83
|
+
? `
|
|
84
|
+
import { useAccessMarkedRoutes } from '@@/plugin-access';
|
|
85
|
+
`.trim()
|
|
86
|
+
: 'const useAccessMarkedRoutes = (r) => r;'}
|
|
81
87
|
${api.config.locale
|
|
82
88
|
? `
|
|
83
89
|
import { useIntl } from '@@/plugin-locale';
|
|
@@ -85,7 +91,7 @@ import { useIntl } from '@@/plugin-locale';
|
|
|
85
91
|
: ''}
|
|
86
92
|
|
|
87
93
|
|
|
88
|
-
export default () => {
|
|
94
|
+
export default (props: any) => {
|
|
89
95
|
const location = useLocation();
|
|
90
96
|
const navigate = useNavigate();
|
|
91
97
|
const { clientRoutes, pluginManager } = useAppData();
|
|
@@ -108,9 +114,8 @@ const { formatMessage } = useIntl();
|
|
|
108
114
|
...initialInfo
|
|
109
115
|
},
|
|
110
116
|
});
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
})[0];
|
|
117
|
+
const matchedRoute = useMemo(() => matchRoutes(clientRoutes, location.pathname).pop()?.route, [location.pathname]);
|
|
118
|
+
const [route] = useAccessMarkedRoutes(clientRoutes.filter(({ id }) => id === 'ant-design-pro-layout'));
|
|
114
119
|
return (
|
|
115
120
|
<ProLayout
|
|
116
121
|
route={route}
|
|
@@ -166,7 +171,16 @@ const { formatMessage } = useIntl();
|
|
|
166
171
|
})
|
|
167
172
|
}
|
|
168
173
|
>
|
|
169
|
-
<
|
|
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>
|
|
170
184
|
</ProLayout>
|
|
171
185
|
);
|
|
172
186
|
}
|
|
@@ -468,6 +482,43 @@ const LogoIcon: React.FC = () => {
|
|
|
468
482
|
export default LogoIcon;
|
|
469
483
|
`,
|
|
470
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
|
+
});
|
|
471
522
|
});
|
|
472
523
|
api.addLayouts(() => {
|
|
473
524
|
return [
|
package/dist/locale.js
CHANGED
|
@@ -19,7 +19,6 @@ const packageNormalize = (packageName) => packageName.replace(/[@\/\-.]/g, '_');
|
|
|
19
19
|
exports.packageNormalize = packageNormalize;
|
|
20
20
|
// TODO: runtime plugin
|
|
21
21
|
exports.default = (api) => {
|
|
22
|
-
var _a;
|
|
23
22
|
// TODO: antd 的校验考虑 antd 插件
|
|
24
23
|
let hasAntd = false;
|
|
25
24
|
try {
|
|
@@ -28,15 +27,15 @@ exports.default = (api) => {
|
|
|
28
27
|
catch (e) {
|
|
29
28
|
api.logger.warn('antd is not installed. <SelecLang /> unavailable');
|
|
30
29
|
}
|
|
30
|
+
const defaultConfig = {
|
|
31
|
+
baseNavigator: true,
|
|
32
|
+
useLocalStorage: true,
|
|
33
|
+
baseSeparator: '-',
|
|
34
|
+
antd: hasAntd,
|
|
35
|
+
};
|
|
31
36
|
api.describe({
|
|
32
37
|
key: 'locale',
|
|
33
38
|
config: {
|
|
34
|
-
default: {
|
|
35
|
-
baseNavigator: true,
|
|
36
|
-
useLocalStorage: true,
|
|
37
|
-
baseSeparator: '-',
|
|
38
|
-
antd: hasAntd,
|
|
39
|
-
},
|
|
40
39
|
schema(joi) {
|
|
41
40
|
return joi.object({
|
|
42
41
|
default: joi.string(),
|
|
@@ -52,30 +51,30 @@ exports.default = (api) => {
|
|
|
52
51
|
});
|
|
53
52
|
const reactIntlPkgPath = (0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('react-intl/package')));
|
|
54
53
|
// polyfill
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
api.addEntryImportsAhead(() => (0, localeUtils_1.isNeedPolyfill)(api.config.targets || {})
|
|
55
|
+
? [
|
|
57
56
|
{
|
|
58
57
|
source: require.resolve('intl'),
|
|
59
58
|
},
|
|
60
|
-
]
|
|
61
|
-
|
|
59
|
+
]
|
|
60
|
+
: []);
|
|
62
61
|
const addAntdLocales = (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
-
var
|
|
62
|
+
var _a;
|
|
64
63
|
return yield api.applyPlugins({
|
|
65
64
|
key: 'addAntdLocales',
|
|
66
65
|
type: api.ApplyPluginsType.add,
|
|
67
66
|
initialValue: [
|
|
68
|
-
`antd/${((
|
|
67
|
+
`antd/${((_a = api.config) === null || _a === void 0 ? void 0 : _a.ssr) ? 'lib' : 'es'}/locale/${(0, localeUtils_1.getAntdLocale)(args.lang, args.country)}`,
|
|
69
68
|
],
|
|
70
69
|
args,
|
|
71
70
|
});
|
|
72
71
|
});
|
|
73
72
|
const getList = (resolveKey) => __awaiter(void 0, void 0, void 0, function* () {
|
|
74
|
-
var
|
|
73
|
+
var _b;
|
|
75
74
|
const { paths } = api;
|
|
76
75
|
return (0, localeUtils_1.getLocaleList)({
|
|
77
|
-
localeFolder:
|
|
78
|
-
separator: (
|
|
76
|
+
localeFolder: 'locales',
|
|
77
|
+
separator: (_b = api.config.locale) === null || _b === void 0 ? void 0 : _b.baseSeparator,
|
|
79
78
|
absSrcPath: paths.absSrcPath,
|
|
80
79
|
absPagesPath: paths.absPagesPath,
|
|
81
80
|
addAntdLocales,
|
|
@@ -83,15 +82,14 @@ exports.default = (api) => {
|
|
|
83
82
|
});
|
|
84
83
|
});
|
|
85
84
|
api.onGenerateFiles(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
86
|
-
var
|
|
85
|
+
var _c, _d, _e, _f;
|
|
87
86
|
const localeTpl = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../libs/locale/locale.tpl'), 'utf-8');
|
|
88
87
|
// moment2dayjs
|
|
89
88
|
const resolveKey = api.config.moment2dayjs ? 'dayjs' : 'moment';
|
|
90
89
|
const momentPkgPath = (0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve(`${resolveKey}/package.json`)));
|
|
91
90
|
const EventEmitterPkg = (0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('event-emitter/package')));
|
|
92
|
-
const { baseSeparator, baseNavigator, antd, title, useLocalStorage } = api
|
|
93
|
-
|
|
94
|
-
const defaultLocale = ((_e = api.config.locale) === null || _e === void 0 ? void 0 : _e.default) || `zh${baseSeparator}CN`;
|
|
91
|
+
const { baseSeparator, baseNavigator, antd, title, useLocalStorage } = Object.assign(Object.assign({}, defaultConfig), api.config.locale);
|
|
92
|
+
const defaultLocale = ((_c = api.config.locale) === null || _c === void 0 ? void 0 : _c.default) || `zh${baseSeparator}CN`;
|
|
95
93
|
const localeList = yield getList(resolveKey);
|
|
96
94
|
const momentLocales = localeList
|
|
97
95
|
.map(({ momentLocale }) => momentLocale)
|
|
@@ -102,7 +100,7 @@ exports.default = (api) => {
|
|
|
102
100
|
let MomentLocales = momentLocales;
|
|
103
101
|
let DefaultMomentLocale = '';
|
|
104
102
|
// set moment default accounding to locale.default
|
|
105
|
-
if (!MomentLocales.length && ((
|
|
103
|
+
if (!MomentLocales.length && ((_d = api.config.locale) === null || _d === void 0 ? void 0 : _d.default)) {
|
|
106
104
|
const [lang, country = ''] = defaultLocale.split(baseSeparator);
|
|
107
105
|
const { momentLocale } = (0, localeUtils_1.getMomentLocale)(lang, country, resolveKey);
|
|
108
106
|
if (momentLocale) {
|
|
@@ -112,7 +110,7 @@ exports.default = (api) => {
|
|
|
112
110
|
}
|
|
113
111
|
let DefaultAntdLocales = [];
|
|
114
112
|
// set antd default locale
|
|
115
|
-
if (!antdLocales.length && ((
|
|
113
|
+
if (!antdLocales.length && ((_e = api.config.locale) === null || _e === void 0 ? void 0 : _e.antd)) {
|
|
116
114
|
const [lang, country = ''] = defaultLocale.split(baseSeparator);
|
|
117
115
|
DefaultAntdLocales = plugin_utils_1.lodash.uniq(yield addAntdLocales({
|
|
118
116
|
lang,
|
|
@@ -139,7 +137,7 @@ exports.default = (api) => {
|
|
|
139
137
|
path: 'locale.tsx',
|
|
140
138
|
});
|
|
141
139
|
const localeExportsTpl = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../libs/locale/localeExports.tpl'), 'utf-8');
|
|
142
|
-
const localeDirName =
|
|
140
|
+
const localeDirName = 'locales';
|
|
143
141
|
const localeDirPath = (0, path_1.join)(api.paths.absSrcPath, localeDirName);
|
|
144
142
|
api.writeTmpFile({
|
|
145
143
|
path: 'localeExports.ts',
|
|
@@ -179,14 +177,14 @@ exports.default = (api) => {
|
|
|
179
177
|
Antd: !!antd,
|
|
180
178
|
LocaleList: localeList,
|
|
181
179
|
ShowSelectLang: localeList.length > 1 && !!antd,
|
|
182
|
-
antdFiles: ((
|
|
180
|
+
antdFiles: ((_f = api.config) === null || _f === void 0 ? void 0 : _f.ssr) ? 'lib' : 'es',
|
|
183
181
|
}),
|
|
184
182
|
});
|
|
185
183
|
// index.ts
|
|
186
184
|
api.writeTmpFile({
|
|
187
185
|
path: 'index.ts',
|
|
188
186
|
content: `
|
|
189
|
-
export { useIntl, formatMessage, FormattedMessage } from './localeExports.ts';
|
|
187
|
+
export { setLocale, getLocale, useIntl, formatMessage, FormattedMessage } from './localeExports.ts';
|
|
190
188
|
export { SelectLang } from './SelectLang.tsx';
|
|
191
189
|
`,
|
|
192
190
|
});
|
package/dist/request.js
CHANGED
package/dist/tailwindcss.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const plugin_utils_1 = require("umi/plugin-utils");
|
|
4
3
|
const path_1 = require("path");
|
|
4
|
+
const plugin_utils_1 = require("umi/plugin-utils");
|
|
5
5
|
exports.default = (api) => {
|
|
6
6
|
api.describe({
|
|
7
7
|
key: 'tailwindcss',
|
|
@@ -14,7 +14,7 @@ exports.default = (api) => {
|
|
|
14
14
|
});
|
|
15
15
|
let tailwind = null;
|
|
16
16
|
const outputPath = 'plugin-tailwindcss/tailwind.css';
|
|
17
|
-
api.
|
|
17
|
+
api.onBeforeCompiler(() => {
|
|
18
18
|
const inputPath = (0, path_1.join)(api.cwd, 'tailwind.css');
|
|
19
19
|
const generatedPath = (0, path_1.join)(api.paths.absTmpPath, outputPath);
|
|
20
20
|
const binPath = (0, path_1.join)(api.cwd, 'node_modules/.bin/tailwind');
|
package/dist/unocss.js
CHANGED
|
@@ -1,34 +1,8 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
3
|
const child_process_1 = require("child_process");
|
|
30
|
-
const
|
|
31
|
-
const path_1 =
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
32
6
|
const plugin_utils_1 = require("umi/plugin-utils");
|
|
33
7
|
exports.default = (api) => {
|
|
34
8
|
api.describe({
|
|
@@ -42,20 +16,24 @@ exports.default = (api) => {
|
|
|
42
16
|
},
|
|
43
17
|
enableBy: api.EnableBy.config,
|
|
44
18
|
});
|
|
45
|
-
|
|
19
|
+
const outputPath = 'uno.css';
|
|
20
|
+
api.onBeforeCompiler(() => {
|
|
46
21
|
/** 由于 @unocss/cli 对设置文件进行了检查,因此加入需要 unocss.config.ts 设置的提示
|
|
47
22
|
* https://github.com/antfu/unocss/blob/main/packages/cli/src/index.ts#L93 */
|
|
48
|
-
if (!
|
|
49
|
-
|
|
50
|
-
const generatedPath = path_1.
|
|
51
|
-
const binPath = path_1.
|
|
23
|
+
if (!(0, fs_1.existsSync)((0, path_1.join)(api.paths.cwd, 'unocss.config.ts')))
|
|
24
|
+
api.logger.warn('请在项目目录中添加 unocss.config.ts 文件,并配置需要的 unocss presets,否则插件将没有效果!');
|
|
25
|
+
const generatedPath = (0, path_1.join)(api.paths.absTmpPath, outputPath);
|
|
26
|
+
const binPath = (0, path_1.join)(api.cwd, 'node_modules/.bin/unocss');
|
|
52
27
|
const watchDirs = api.config.unocss.watch;
|
|
53
28
|
/** 透过子进程建立 unocss 服务,将生成的 css 写入 generatedPath */
|
|
54
|
-
const unocss = (0, child_process_1.exec)(`${binPath} ${watchDirs.join(' ')} --out-file ${generatedPath} --watch`, { cwd: api.cwd });
|
|
29
|
+
const unocss = (0, child_process_1.exec)(`${binPath} ${watchDirs.join(' ')} --out-file ${generatedPath} ${api.env === 'development' ? '--watch' : ''}`, { cwd: api.cwd });
|
|
55
30
|
unocss.on('error', (m) => {
|
|
56
31
|
api.logger.error('unocss service encounter an error: ' + m);
|
|
57
32
|
});
|
|
58
|
-
|
|
59
|
-
|
|
33
|
+
});
|
|
34
|
+
/** 将生成的 css 文件加入到 import 中 */
|
|
35
|
+
api.addEntryImports(() => {
|
|
36
|
+
const generatedPath = (0, plugin_utils_1.winPath)((0, path_1.join)(api.paths.absTmpPath, outputPath));
|
|
37
|
+
return [{ source: generatedPath }];
|
|
60
38
|
});
|
|
61
39
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/plugins",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.9",
|
|
4
4
|
"description": "@umijs/plugins",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi-next/tree/master/packages/plugins#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi-next/issues",
|
|
@@ -18,18 +18,21 @@
|
|
|
18
18
|
"scripts": {
|
|
19
19
|
"build": "pnpm tsc",
|
|
20
20
|
"build:deps": "pnpm esno ../../scripts/bundleDeps.ts",
|
|
21
|
-
"dev": "pnpm build -- --watch"
|
|
21
|
+
"dev": "pnpm build -- --watch",
|
|
22
|
+
"test": "jest -c ../../jest.turbo.config.ts"
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
24
25
|
"@ahooksjs/use-request": "^2.0.0",
|
|
25
26
|
"@ant-design/icons": "^4.7.0",
|
|
26
|
-
"@ant-design/pro-layout": "^
|
|
27
|
-
"@umijs/bundler-utils": "4.0.0-rc.
|
|
27
|
+
"@ant-design/pro-layout": "^6.34.6",
|
|
28
|
+
"@umijs/bundler-utils": "4.0.0-rc.9",
|
|
28
29
|
"antd-dayjs-webpack-plugin": "^1.0.6",
|
|
29
30
|
"axios": "^0.26.1",
|
|
30
31
|
"babel-plugin-import": "^1.13.3",
|
|
31
|
-
"dayjs": "^1.
|
|
32
|
+
"dayjs": "^1.11.0",
|
|
32
33
|
"dva-core": "^2.0.4",
|
|
34
|
+
"dva-immer": "^1.0.0",
|
|
35
|
+
"dva-loading": "^3.0.22",
|
|
33
36
|
"event-emitter": "~0.3.5",
|
|
34
37
|
"fast-deep-equal": "3.1.3",
|
|
35
38
|
"lodash": "^4.17.21",
|
|
@@ -41,7 +44,7 @@
|
|
|
41
44
|
"warning": "^4.0.3"
|
|
42
45
|
},
|
|
43
46
|
"devDependencies": {
|
|
44
|
-
"umi": "4.0.0-rc.
|
|
47
|
+
"umi": "4.0.0-rc.9"
|
|
45
48
|
},
|
|
46
49
|
"publishConfig": {
|
|
47
50
|
"access": "public"
|