@umijs/plugins 4.0.0-beta.15 → 4.0.0-beta.16

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/layout.js CHANGED
@@ -74,6 +74,13 @@ ${hasInitialStatePlugin
74
74
  ? `import { useModel } from '@@/plugin-model';`
75
75
  : 'const useModel = null;'}
76
76
 
77
+ ${api.config.locale
78
+ ? `
79
+ import { useIntl } from '@@/plugin-locale';
80
+ `.trim()
81
+ : ''}
82
+
83
+
77
84
  export default () => {
78
85
  const location = useLocation();
79
86
  const navigate = useNavigate();
@@ -85,14 +92,24 @@ export default () => {
85
92
  };
86
93
  const { initialState, loading, setInitialState } = initialInfo;
87
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;'}
88
100
  const runtimeConfig = pluginManager.applyPlugins({
89
101
  key: 'layout',
90
102
  type: 'modify',
91
- initialValue: {},
103
+ initialValue: {
104
+ ...initialInfo
105
+ },
92
106
  });
107
+ const route = clientRoutes.filter(r => {
108
+ return r.id === 'ant-design-pro-layout';
109
+ })[0];
93
110
  return (
94
111
  <ProLayout
95
- route={clientRoutes[0]}
112
+ route={route}
96
113
  location={location}
97
114
  title={userConfig.name || 'plugin-layout'}
98
115
  navTheme="dark"
@@ -102,6 +119,7 @@ export default () => {
102
119
  e.preventDefault();
103
120
  navigate('/');
104
121
  }}
122
+ formatMessage={userConfig.formatMessage || formatMessage}
105
123
  menu={{ locale: userConfig.locale }}
106
124
  logo={Logo}
107
125
  menuItemRender={(menuItemProps, defaultDom) => {
@@ -452,6 +470,9 @@ export default LogoIcon;
452
470
  {
453
471
  id: 'ant-design-pro-layout',
454
472
  file: (0, withTmpPath_1.withTmpPath)({ api, path: 'Layout.tsx' }),
473
+ test: (route) => {
474
+ return route.layout !== false;
475
+ },
455
476
  },
456
477
  ];
457
478
  });
package/dist/locale.js CHANGED
@@ -186,8 +186,8 @@ exports.default = (api) => {
186
186
  api.writeTmpFile({
187
187
  path: 'index.ts',
188
188
  content: `
189
- export * from './localeExports.ts';
190
- export * from './SelectLang.tsx';
189
+ export { useIntl, formatMessage, FormattedMessage } from './localeExports.ts';
190
+ export { SelectLang } from './SelectLang.tsx';
191
191
  `,
192
192
  });
193
193
  }));
@@ -22,9 +22,7 @@ exports.default = (api) => {
22
22
  api.addRuntimePlugin(() => {
23
23
  return [(0, withTmpPath_1.withTmpPath)({ api, path: 'masterRuntimePlugin.tsx' })];
24
24
  });
25
- api.modifyDefaultConfig((config) => (Object.assign(Object.assign({}, config), {
26
- // TODO: support mountElementId
27
- mountElementId: constants_1.defaultMasterRootId, qiankun: Object.assign(Object.assign({}, config.qiankun), { master: Object.assign(Object.assign({}, JSON.parse(process.env.INITIAL_QIANKUN_MASTER_OPTIONS || '{}')), (config.qiankun || {}).master) }) })));
25
+ api.modifyDefaultConfig((config) => (Object.assign(Object.assign({}, config), { mountElementId: constants_1.defaultMasterRootId, qiankun: Object.assign(Object.assign({}, config.qiankun), { master: Object.assign(Object.assign({}, JSON.parse(process.env.INITIAL_QIANKUN_MASTER_OPTIONS || '{}')), (config.qiankun || {}).master) }) })));
28
26
  // TODO: modify routes
29
27
  api.modifyRoutes((memo) => {
30
28
  Object.keys(memo).forEach((id) => {
@@ -50,7 +48,7 @@ exports.default = (api) => {
50
48
  api.register({
51
49
  key: 'addExtraModels',
52
50
  fn() {
53
- const [path, exports] = api.appData.appJS || [];
51
+ const { path, exports } = api.appData.appJS || {};
54
52
  return path && exports.includes(constants_1.MODEL_EXPORT_NAME)
55
53
  ? [
56
54
  `${path}#{"namespace":"${constants_1.qiankunStateForSlaveModelNamespace}","exportName":"${constants_1.MODEL_EXPORT_NAME}"}`,
@@ -38,7 +38,6 @@ exports.default = (api) => {
38
38
  const initialSlaveOptions = Object.assign(Object.assign({ devSourceMap: true }, JSON.parse(process.env.INITIAL_QIANKUN_SLAVE_OPTIONS || '{}')), (memo.qiankun || {}).slave);
39
39
  const modifiedDefaultConfig = Object.assign(Object.assign({}, memo), {
40
40
  // 默认开启 runtimePublicPath,避免出现 dynamic import 场景子应用资源地址出问题
41
- // TODO: runtimePublicPath
42
41
  runtimePublicPath: true,
43
42
  // TODO: runtimeHistory
44
43
  runtimeHistory: {}, qiankun: Object.assign(Object.assign({}, memo.qiankun), { slave: initialSlaveOptions }) });
@@ -84,8 +83,8 @@ exports.default = (api) => {
84
83
  $('script').each((_, el) => {
85
84
  var _a;
86
85
  const scriptEl = $(el);
87
- const umiEntryJs = /\/?umi(\.\w+)?\.js$/g;
88
- if (umiEntryJs.test((_a = scriptEl.attr('src')) !== null && _a !== void 0 ? _a : '')) {
86
+ const umiEntry = /\/?umi(\.\w+)?\.js$/g;
87
+ if (umiEntry.test((_a = scriptEl.attr('src')) !== null && _a !== void 0 ? _a : '')) {
89
88
  scriptEl.attr('entry', '');
90
89
  }
91
90
  });
package/dist/request.js CHANGED
@@ -15,9 +15,9 @@ exports.default = (api) => {
15
15
  api.addRuntimePluginKey(() => ['request']);
16
16
  const requestTpl = `
17
17
  import axios, {
18
- AxiosInstance,
19
- AxiosRequestConfig,
20
- AxiosResponse,
18
+ type AxiosInstance,
19
+ type AxiosRequestConfig,
20
+ type AxiosResponse,
21
21
  } from '{{{axiosPath}}}';
22
22
  import useUmiRequest, { UseRequestProvider } from '{{{umiRequestPath}}}';
23
23
  import { message, notification } from '{{{antdPkg}}}';
@@ -39,7 +39,7 @@ import {
39
39
  PaginatedOptionsWithFormat,
40
40
  PaginatedParams,
41
41
  PaginatedResult,
42
- } from '{{{umiRequestPath}}}/lib/types';
42
+ } from '{{{umiRequestPath}}}/es/types';
43
43
 
44
44
  type ResultWithData< T = any > = { data?: T; [key: string]: any };
45
45
 
@@ -290,7 +290,11 @@ export {
290
290
  api.writeTmpFile({
291
291
  path: 'index.ts',
292
292
  content: `
293
- export * from './request';
293
+ export {
294
+ useRequest,
295
+ UseRequestProvider,
296
+ request,
297
+ } from './request';
294
298
  `,
295
299
  });
296
300
  });
@@ -46,10 +46,7 @@ function patchMicroAppRouteComponent(routes: any[]) {
46
46
  if (rootRoutes) {
47
47
  const { routeBindingAlias, base, masterHistoryType } =
48
48
  getMasterOptions() as MasterOptions;
49
- const microAppAttachedRoutes = microAppRuntimeRoutes.filter(
50
- (r) => !r.insert,
51
- );
52
- microAppAttachedRoutes.reverse().forEach((microAppRoute) => {
49
+ microAppRuntimeRoutes.reverse().forEach((microAppRoute) => {
53
50
  const patchRoute = (route: any) => {
54
51
  patchMicroAppRoute(route, getMicroAppRouteComponent, {
55
52
  base,
@@ -62,7 +59,7 @@ function patchMicroAppRouteComponent(routes: any[]) {
62
59
  };
63
60
 
64
61
  patchRoute(microAppRoute);
65
- rootRoutes.unshift(microAppRoute);
62
+ !microAppRoute.insert && rootRoutes.unshift(microAppRoute);
66
63
  });
67
64
  }
68
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/plugins",
3
- "version": "4.0.0-beta.15",
3
+ "version": "4.0.0-beta.16",
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",
@@ -24,7 +24,7 @@
24
24
  "@ahooksjs/use-request": "^2.0.0",
25
25
  "@ant-design/icons": "^4.7.0",
26
26
  "@ant-design/pro-layout": "^6.31.7",
27
- "@umijs/bundler-utils": "4.0.0-beta.15",
27
+ "@umijs/bundler-utils": "4.0.0-beta.16",
28
28
  "antd": "^4.17.3",
29
29
  "antd-dayjs-webpack-plugin": "^1.0.6",
30
30
  "axios": "^0.24.0",
@@ -42,7 +42,7 @@
42
42
  "warning": "^4.0.3"
43
43
  },
44
44
  "devDependencies": {
45
- "umi": "4.0.0-beta.15"
45
+ "umi": "4.0.0-beta.16"
46
46
  },
47
47
  "publishConfig": {
48
48
  "access": "public"