@umijs/plugins 4.0.0-canary.20220707.1 → 4.0.0-canary.20220713.1
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/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
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/plugins",
|
|
3
|
-
"version": "4.0.0-canary.
|
|
3
|
+
"version": "4.0.0-canary.20220713.1",
|
|
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.0-canary.
|
|
28
|
+
"@umijs/bundler-utils": "4.0.0-canary.20220713.1",
|
|
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.0-canary.
|
|
47
|
+
"umi": "4.0.0-canary.20220713.1"
|
|
48
48
|
},
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public"
|