@umijs/plugins 4.0.1 → 4.0.4

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
@@ -91,6 +91,7 @@ exports.default = (api) => {
91
91
  path: 'Layout.tsx',
92
92
  content: `
93
93
  import { Link, useLocation, useNavigate, Outlet, useAppData, useRouteData, matchRoutes } from 'umi';
94
+ import type { IRoute } from 'umi';
94
95
  import React, { useMemo } from 'react';
95
96
  import {
96
97
  ProLayout,
@@ -113,6 +114,28 @@ import { useIntl } from '@@/plugin-locale';
113
114
  `.trim()
114
115
  : ''}
115
116
 
117
+ // 过滤出需要显示的路由, 这里的filterFn 指 不希望显示的层级
118
+ const filterRoutes = (routes: IRoute[], filterFn: (route: IRoute) => boolean) => {
119
+ if (routes.length === 0) {
120
+ return []
121
+ }
122
+
123
+ let newRoutes = []
124
+ for (const route of routes) {
125
+ if (filterFn(route)) {
126
+ if (Array.isArray(route.routes)) {
127
+ newRoutes.push(...filterRoutes(route.routes, filterFn))
128
+ }
129
+ } else {
130
+ newRoutes.push(route);
131
+ if (Array.isArray(route.routes)) {
132
+ route.routes = filterRoutes(route.routes, filterFn);
133
+ }
134
+ }
135
+ }
136
+
137
+ return newRoutes;
138
+ }
116
139
 
117
140
  export default (props: any) => {
118
141
  const location = useLocation();
@@ -137,8 +160,13 @@ const { formatMessage } = useIntl();
137
160
  ...initialInfo
138
161
  },
139
162
  });
163
+
140
164
  const matchedRoute = useMemo(() => matchRoutes(clientRoutes, location.pathname).pop()?.route, [location.pathname]);
141
- const [route] = useAccessMarkedRoutes(clientRoutes.filter(({ id }) => id === 'ant-design-pro-layout'));
165
+ const newRoutes = filterRoutes(clientRoutes.filter(route => route.id === 'ant-design-pro-layout'), (route) => {
166
+ return !!route.isLayout && route.id !== 'ant-design-pro-layout';
167
+ })
168
+ const [route] = useAccessMarkedRoutes(newRoutes);
169
+
142
170
  return (
143
171
  <ProLayout
144
172
  route={route}
package/dist/locale.js CHANGED
@@ -182,7 +182,7 @@ exports.default = (api) => {
182
182
  api.writeTmpFile({
183
183
  path: 'index.ts',
184
184
  content: `
185
- export { setLocale, getLocale, useIntl, injectIntl, formatMessage, FormattedMessage } from './localeExports.ts';
185
+ export { setLocale, getLocale, getIntl, useIntl, injectIntl, formatMessage, FormattedMessage } from './localeExports.ts';
186
186
  export { SelectLang } from './SelectLang.tsx';
187
187
  `,
188
188
  });
@@ -97,6 +97,7 @@ export const setMasterOptions = (newOpts) => options = ({ ...options, ...newOpts
97
97
  'getMicroAppRouteComponent.tsx.tpl',
98
98
  'ErrorBoundary.tsx',
99
99
  'MicroApp.tsx',
100
+ 'MicroAppWithMemoHistory.tsx',
100
101
  ].forEach((file) => {
101
102
  if (file.endsWith('.tpl')) {
102
103
  api.writeTmpFile({
@@ -129,6 +130,7 @@ export const setMasterOptions = (newOpts) => options = ({ ...options, ...newOpts
129
130
  path: 'index.ts',
130
131
  content: `
131
132
  export { MicroApp } from './MicroApp';
133
+ export { MicroAppWithMemoHistory } from './MicroAppWithMemoHistory';
132
134
  `,
133
135
  });
134
136
  });
@@ -18,18 +18,30 @@ exports.default = (api) => {
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');
21
- /** 透过子进程建立 tailwindcss 服务,将生成的 css 写入 generatedPath */
22
- tailwind = (0, plugin_utils_1.crossSpawn)(`${binPath}`, [
23
- '-i',
24
- inputPath,
25
- '-o',
26
- generatedPath,
27
- api.env === 'development' ? '--watch' : '',
28
- ], {
29
- stdio: 'inherit',
30
- });
31
- tailwind.on('error', (m) => {
32
- api.logger.error('tailwindcss service encounter an error: ' + m);
21
+ return new Promise((resolve) => {
22
+ /** 透过子进程建立 tailwindcss 服务,将生成的 css 写入 generatedPath */
23
+ tailwind = (0, plugin_utils_1.crossSpawn)(`${binPath}`, [
24
+ '-i',
25
+ inputPath,
26
+ '-o',
27
+ generatedPath,
28
+ api.env === 'development' ? '--watch' : '',
29
+ ], {
30
+ stdio: 'inherit',
31
+ });
32
+ tailwind.on('error', (m) => {
33
+ api.logger.error('tailwindcss service encounter an error: ' + m);
34
+ });
35
+ if (api.env === 'production') {
36
+ tailwind.on('exit', () => {
37
+ api.logger.info('tailwindcss service exited');
38
+ resolve();
39
+ });
40
+ }
41
+ else {
42
+ api.logger.info('tailwindcss service started');
43
+ resolve();
44
+ }
33
45
  });
34
46
  });
35
47
  /** 将生成的 css 文件加入到 import 中 */
@@ -128,7 +128,7 @@ class ModelUtils {
128
128
  // check duplicate
129
129
  const namespaces = models.map((model) => model.namespace);
130
130
  if (new Set(namespaces).size !== namespaces.length) {
131
- throw new Error(`Duplicate namespace in models: ${namespaces.join(', ')}`);
131
+ throw new Error(`Duplicate namespace in models: ${namespaces.sort().join(', ')}`);
132
132
  }
133
133
  // sort models by deps
134
134
  if (opts.sort) {
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@umijs/plugins",
3
- "version": "4.0.1",
3
+ "version": "4.0.4",
4
4
  "description": "@umijs/plugins",
5
- "homepage": "https://github.com/umijs/umi-next/tree/master/packages/plugins#readme",
6
- "bugs": "https://github.com/umijs/umi-next/issues",
5
+ "homepage": "https://github.com/umijs/umi/tree/master/packages/plugins#readme",
6
+ "bugs": "https://github.com/umijs/umi/issues",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "https://github.com/umijs/umi-next"
9
+ "url": "https://github.com/umijs/umi"
10
10
  },
11
11
  "license": "MIT",
12
12
  "main": "dist/index.js",
@@ -18,14 +18,14 @@
18
18
  "scripts": {
19
19
  "build": "pnpm tsc",
20
20
  "build:deps": "umi-scripts bundleDeps",
21
- "dev": "pnpm build -- --watch",
21
+ "dev": "pnpm build --watch",
22
22
  "test": "umi-scripts jest-turbo"
23
23
  },
24
24
  "dependencies": {
25
25
  "@ahooksjs/use-request": "^2.0.0",
26
26
  "@ant-design/icons": "^4.7.0",
27
27
  "@ant-design/pro-layout": "^7.0.1-beta.20",
28
- "@umijs/bundler-utils": "4.0.1",
28
+ "@umijs/bundler-utils": "4.0.4",
29
29
  "antd-dayjs-webpack-plugin": "^1.0.6",
30
30
  "axios": "^0.27.2",
31
31
  "babel-plugin-import": "^1.13.5",
@@ -44,7 +44,7 @@
44
44
  "warning": "^4.0.3"
45
45
  },
46
46
  "devDependencies": {
47
- "umi": "4.0.1"
47
+ "umi": "4.0.4"
48
48
  },
49
49
  "publishConfig": {
50
50
  "access": "public"