@umijs/plugins 4.0.25 → 4.0.27

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 CHANGED
@@ -131,6 +131,20 @@ export const useAccessMarkedRoutes = (routes: IRoute[]) => {
131
131
  }
132
132
  }
133
133
 
134
+ // check children access code
135
+ if (route.routes?.length) {
136
+ const isNoAccessibleChild = !route.routes.reduce((hasAccessibleChild, child) => {
137
+ process(child, accessCode, route);
138
+
139
+ return hasAccessibleChild || !child.unaccessible;
140
+ }, false);
141
+
142
+ // make sure parent route is unaccessible if all children are unaccessible
143
+ if (isNoAccessibleChild) {
144
+ route.unaccessible = true;
145
+ }
146
+ }
147
+
134
148
  return route;
135
149
  }
136
150
 
package/dist/layout.js CHANGED
@@ -123,15 +123,17 @@ const filterRoutes = (routes: IRoute[], filterFn: (route: IRoute) => boolean) =>
123
123
 
124
124
  let newRoutes = []
125
125
  for (const route of routes) {
126
+ const newRoute = {...route };
126
127
  if (filterFn(route)) {
127
- if (Array.isArray(route.routes)) {
128
- newRoutes.push(...filterRoutes(route.routes, filterFn))
128
+ if (Array.isArray(newRoute.routes)) {
129
+ newRoutes.push(...filterRoutes(newRoute.routes, filterFn))
129
130
  }
130
131
  } else {
131
- newRoutes.push(route);
132
- if (Array.isArray(route.routes)) {
133
- route.routes = filterRoutes(route.routes, filterFn);
132
+ if (Array.isArray(newRoute.children)) {
133
+ newRoute.children = filterRoutes(newRoute.children, filterFn);
134
+ newRoute.routes = newRoute.children;
134
135
  }
136
+ newRoutes.push(newRoute);
135
137
  }
136
138
  }
137
139
 
@@ -154,6 +156,10 @@ const mapRoutes = (routes: IRoute[]) => {
154
156
  newRoute.routes = mapRoutes(route.routes);
155
157
  }
156
158
 
159
+ if (Array.isArray(route.children)) {
160
+ newRoute.children = mapRoutes(route.children);
161
+ }
162
+
157
163
  return newRoute
158
164
  })
159
165
  }
@@ -180,12 +186,14 @@ const { formatMessage } = useIntl();
180
186
  },
181
187
  });
182
188
 
183
- const matchedRoute = useMemo(() => matchRoutes(clientRoutes, location.pathname).pop()?.route, [location.pathname]);
189
+
184
190
  // \u73B0\u5728\u7684 layout \u53CA wrapper \u5B9E\u73B0\u662F\u901A\u8FC7\u7236\u8DEF\u7531\u7684\u5F62\u5F0F\u5B9E\u73B0\u7684, \u4F1A\u5BFC\u81F4\u8DEF\u7531\u6570\u636E\u591A\u4E86\u5197\u4F59\u5C42\u7EA7, proLayout \u6D88\u8D39\u65F6, \u65E0\u6CD5\u6B63\u786E\u5C55\u793A\u83DC\u5355, \u8FD9\u91CC\u5BF9\u5197\u4F59\u6570\u636E\u8FDB\u884C\u8FC7\u6EE4\u64CD\u4F5C
185
191
  const newRoutes = filterRoutes(clientRoutes.filter(route => route.id === 'ant-design-pro-layout'), (route) => {
186
192
  return (!!route.isLayout && route.id !== 'ant-design-pro-layout') || !!route.isWrapper;
187
193
  })
188
194
  const [route] = useAccessMarkedRoutes(mapRoutes(newRoutes));
195
+
196
+ const matchedRoute = useMemo(() => matchRoutes(route.children, location.pathname)?.pop?.()?.route, [location.pathname]);
189
197
 
190
198
  return (
191
199
  <ProLayout
@@ -41,6 +41,9 @@ var tailwindcss_default = (api) => {
41
41
  const generatedPath = (0, import_path.join)(api.paths.absTmpPath, outputPath);
42
42
  const binPath = getTailwindBinPath({ cwd: api.cwd });
43
43
  const configPath = (0, import_path.join)(process.env.APP_ROOT || api.cwd, "tailwind.config.js");
44
+ if (process.env.IS_UMI_BUILD_WORKER) {
45
+ return;
46
+ }
44
47
  return new Promise((resolve) => {
45
48
  tailwind = (0, import_plugin_utils.crossSpawn)(`${binPath}`, [
46
49
  "-c",
package/dist/unocss.js CHANGED
@@ -40,6 +40,8 @@ var unocss_default = (api) => {
40
40
  });
41
41
  const outputPath = "uno.css";
42
42
  api.onBeforeCompiler(() => {
43
+ if (process.env.IS_UMI_BUILD_WORKER)
44
+ return;
43
45
  if (!(0, import_fs.existsSync)((0, import_path.join)(api.paths.cwd, "unocss.config.ts")))
44
46
  api.logger.warn("\u8BF7\u5728\u9879\u76EE\u76EE\u5F55\u4E2D\u6DFB\u52A0 unocss.config.ts \u6587\u4EF6\uFF0C\u5E76\u914D\u7F6E\u9700\u8981\u7684 unocss presets\uFF0C\u5426\u5219\u63D2\u4EF6\u5C06\u6CA1\u6709\u6548\u679C\uFF01");
45
47
  const generatedPath = (0, import_path.join)(api.paths.absTmpPath, outputPath);
@@ -16,6 +16,7 @@ export function patchRoutes({ routes }) {
16
16
  Object.keys(routes).forEach((key) => {
17
17
  const route = routes[key];
18
18
  if (route.title) {
19
+ route.locale = route.title;
19
20
  const newTitle = intl.messages[route.title] ? intl.formatMessage({ id: route.title }, {}) : route.title;
20
21
  route.name = intl.messages[route.title] ? intl.formatMessage({ id: route.title }, {}) : route.name;
21
22
  route.title = newTitle;
@@ -23,8 +24,8 @@ export function patchRoutes({ routes }) {
23
24
  if (route.routes) {
24
25
  traverseRoute(route.routes);
25
26
  }
26
- if (route.routes) {
27
- traverseRoute(route.routes);
27
+ if (route.children) {
28
+ traverseRoute(route.children);
28
29
  }
29
30
  })
30
31
  }
@@ -74,6 +74,7 @@ export const MicroApp = forwardRef(
74
74
  lifeCycles: globalLifeCycles,
75
75
  prefetch = true,
76
76
  appNameKeyAlias = 'name',
77
+ prefetchThreshold = 5,
77
78
  ...globalSettings
78
79
  } = getMasterOptions() as MasterOptions;
79
80
 
@@ -184,9 +185,10 @@ export const MicroApp = forwardRef(
184
185
  );
185
186
  prefetchApps(specialPrefetchApps, configuration);
186
187
  } else {
188
+ // 不能无脑全量 prefetch,需要有一个阈值
187
189
  const otherNotMountedApps = apps.filter(
188
190
  (app) => !isCurrentApp(app),
189
- );
191
+ ).slice(0, prefetchThreshold);
190
192
  prefetchApps(otherNotMountedApps, configuration);
191
193
  }
192
194
  noneMounted = false;
@@ -12,7 +12,7 @@ export function getMicroAppRouteComponent(opts: {
12
12
  const { base, masterHistoryType, appName, routeProps, routePath } = opts;
13
13
  const RouteComponent = () => {
14
14
  const match = useMatch(routePath);
15
- const url = match.pathnameBase;
15
+ const url = match ? match.pathnameBase : '';
16
16
  // 默认取静态配置的 base
17
17
  let umiConfigBase = base === '/' ? '' : base;
18
18
 
@@ -33,6 +33,8 @@ export type MasterOptions = {
33
33
  exportComponentAlias?: string;
34
34
  // MicroApp 寻址时使用的应用名唯一键,默认是 name
35
35
  appNameKeyAlias?: string;
36
+ // 预加载应用阈值
37
+ prefetchThreshold?: number;
36
38
  } & FrameworkConfiguration;
37
39
 
38
40
  export type SlaveOptions = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/plugins",
3
- "version": "4.0.25",
3
+ "version": "4.0.27",
4
4
  "description": "@umijs/plugins",
5
5
  "homepage": "https://github.com/umijs/umi/tree/master/packages/plugins#readme",
6
6
  "bugs": "https://github.com/umijs/umi/issues",
@@ -27,7 +27,7 @@
27
27
  "@ant-design/antd-theme-variable": "^1.0.0",
28
28
  "@ant-design/icons": "^4.7.0",
29
29
  "@ant-design/pro-components": "^2.0.1",
30
- "@umijs/bundler-utils": "4.0.25",
30
+ "@umijs/bundler-utils": "4.0.27",
31
31
  "@umijs/valtio": "^1.0.0",
32
32
  "antd-dayjs-webpack-plugin": "^1.0.6",
33
33
  "axios": "^0.27.2",
@@ -38,6 +38,7 @@
38
38
  "dva-loading": "^3.0.22",
39
39
  "event-emitter": "~0.3.5",
40
40
  "fast-deep-equal": "3.1.3",
41
+ "intl": "1.2.5",
41
42
  "lodash": "^4.17.21",
42
43
  "moment": "^2.29.3",
43
44
  "qiankun": "^2.7.0",
@@ -47,7 +48,7 @@
47
48
  "warning": "^4.0.3"
48
49
  },
49
50
  "devDependencies": {
50
- "umi": "4.0.25"
51
+ "umi": "4.0.27"
51
52
  },
52
53
  "publishConfig": {
53
54
  "access": "public"