@umijs/plugins 4.0.6 → 4.0.7
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 +22 -2
- package/dist/locale.js +1 -1
- package/dist/request.js +7 -2
- package/libs/locale/SelectLang.tpl +1 -1
- package/libs/qiankun/slave/lifecycles.ts +6 -0
- package/package.json +3 -3
package/dist/layout.js
CHANGED
|
@@ -137,6 +137,26 @@ const filterRoutes = (routes: IRoute[], filterFn: (route: IRoute) => boolean) =>
|
|
|
137
137
|
return newRoutes;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
// 格式化路由 处理因 wrapper 导致的 菜单 path 不一致
|
|
141
|
+
const mapRoutes = (routes: IRoute[]) => {
|
|
142
|
+
if (routes.length === 0) {
|
|
143
|
+
return []
|
|
144
|
+
}
|
|
145
|
+
return routes.map(route => {
|
|
146
|
+
// 需要 copy 一份, 否则会污染原始数据
|
|
147
|
+
const newRoute = {...route}
|
|
148
|
+
if (route.originPath) {
|
|
149
|
+
newRoute.path = route.originPath
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (Array.isArray(route.routes)) {
|
|
153
|
+
newRoute.routes = mapRoutes(route.routes);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return newRoute
|
|
157
|
+
})
|
|
158
|
+
}
|
|
159
|
+
|
|
140
160
|
export default (props: any) => {
|
|
141
161
|
const location = useLocation();
|
|
142
162
|
const navigate = useNavigate();
|
|
@@ -163,9 +183,9 @@ const { formatMessage } = useIntl();
|
|
|
163
183
|
|
|
164
184
|
const matchedRoute = useMemo(() => matchRoutes(clientRoutes, location.pathname).pop()?.route, [location.pathname]);
|
|
165
185
|
const newRoutes = filterRoutes(clientRoutes.filter(route => route.id === 'ant-design-pro-layout'), (route) => {
|
|
166
|
-
return !!route.isLayout && route.id !== 'ant-design-pro-layout';
|
|
186
|
+
return (!!route.isLayout && route.id !== 'ant-design-pro-layout') || !!route.isWrapper;
|
|
167
187
|
})
|
|
168
|
-
const [route] = useAccessMarkedRoutes(newRoutes);
|
|
188
|
+
const [route] = useAccessMarkedRoutes(mapRoutes(newRoutes));
|
|
169
189
|
|
|
170
190
|
return (
|
|
171
191
|
<ProLayout
|
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, getIntl, useIntl, injectIntl, formatMessage, FormattedMessage, getAllLocales } from './localeExports.ts';
|
|
185
|
+
export { addLocale, setLocale, getLocale, getIntl, useIntl, injectIntl, formatMessage, FormattedMessage, getAllLocales } from './localeExports.ts';
|
|
186
186
|
export { SelectLang } from './SelectLang.tsx';
|
|
187
187
|
`,
|
|
188
188
|
});
|
package/dist/request.js
CHANGED
|
@@ -23,6 +23,7 @@ import axios, {
|
|
|
23
23
|
type AxiosInstance,
|
|
24
24
|
type AxiosRequestConfig,
|
|
25
25
|
type AxiosResponse,
|
|
26
|
+
type AxiosError,
|
|
26
27
|
} from '{{{axiosPath}}}';
|
|
27
28
|
import useUmiRequest, { UseRequestProvider } from '{{{umiRequestPath}}}';
|
|
28
29
|
import { ApplyPluginsType } from 'umi';
|
|
@@ -123,6 +124,8 @@ interface IRequest{
|
|
|
123
124
|
<T = any>(url: string): Promise<T>; // 不提供 opts 时,默认使用 'GET' method,并且默认返回 data
|
|
124
125
|
}
|
|
125
126
|
|
|
127
|
+
type RequestError = AxiosError | Error
|
|
128
|
+
|
|
126
129
|
interface IErrorHandler {
|
|
127
130
|
(error: RequestError, opts: IRequestOptions): void;
|
|
128
131
|
}
|
|
@@ -134,10 +137,10 @@ type IResponseInterceptor = <T = any>(response : AxiosResponse<T>) => AxiosRespo
|
|
|
134
137
|
type IRequestInterceptorTuple = [IRequestInterceptor , IErrorInterceptor] | [ IRequestInterceptor ] | IRequestInterceptor
|
|
135
138
|
type IResponseInterceptorTuple = [IResponseInterceptor, IErrorInterceptor] | [IResponseInterceptor] | IResponseInterceptor
|
|
136
139
|
|
|
137
|
-
export interface RequestConfig extends AxiosRequestConfig {
|
|
140
|
+
export interface RequestConfig<T = any> extends AxiosRequestConfig {
|
|
138
141
|
errorConfig?: {
|
|
139
142
|
errorHandler?: IErrorHandler;
|
|
140
|
-
errorThrower?:
|
|
143
|
+
errorThrower?: ( res: T ) => void
|
|
141
144
|
};
|
|
142
145
|
requestInterceptors?: IRequestInterceptorTuple[];
|
|
143
146
|
responseInterceptors?: IResponseInterceptorTuple[];
|
|
@@ -302,6 +305,8 @@ export type {
|
|
|
302
305
|
AxiosInstance,
|
|
303
306
|
AxiosRequestConfig,
|
|
304
307
|
AxiosResponse,
|
|
308
|
+
AxiosError,
|
|
309
|
+
RequestError,
|
|
305
310
|
ResponseInterceptor } from './request';
|
|
306
311
|
`,
|
|
307
312
|
});
|
|
@@ -73,6 +73,8 @@ export function genMount(mountElementId: string) {
|
|
|
73
73
|
await slaveRuntime.mount(props);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
const { type, ...historyOpts } = props?.history;
|
|
77
|
+
|
|
76
78
|
// 更新 clientRender 配置
|
|
77
79
|
const clientRenderOpts = {
|
|
78
80
|
// 默认开启
|
|
@@ -95,6 +97,10 @@ export function genMount(mountElementId: string) {
|
|
|
95
97
|
|
|
96
98
|
basename: props.base,
|
|
97
99
|
|
|
100
|
+
// 支持 MicroAppWithMemoHistory 需要
|
|
101
|
+
historyType: type,
|
|
102
|
+
historyOpts: historyOpts,
|
|
103
|
+
|
|
98
104
|
// 当存在同一个 umi 子应用在同一个页面被多实例渲染的场景时(比如一个页面里,同时展示了这个子应用的多个路由页面)
|
|
99
105
|
// mount 钩子会被调用多次,但是具体什么时候对应的实例开始 render 则是不定的,即它调用 applyPlugins('modifyClientRenderOpts') 的时机是不确定的
|
|
100
106
|
// 为了保证每次 applyPlugins('modifyClientRenderOpts') 调用是生成正确的 history,我们需要这里通过闭包上下文维持 mount 调用时的一些配置信息
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/plugins",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.7",
|
|
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",
|
|
@@ -25,7 +25,7 @@
|
|
|
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.
|
|
28
|
+
"@umijs/bundler-utils": "4.0.7",
|
|
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.
|
|
47
|
+
"umi": "4.0.7"
|
|
48
48
|
},
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public"
|