module-menu 0.3.26 → 0.3.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/config/config.js +3 -3
- package/package.json +1 -1
- package/src/.umi/.cache/babel-loader/00e686d9a9b52074d267c6c52238b773.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/0127a51a5419eb2e27c73aa088e69579.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/015fac2a75b744cc2159af7c26c21951.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/02255b2cf26f46683dee316d9345ec21.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/0428496446fb6c72cd57973c32e3811f.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/04b6caeb8c13675aa936771b82af2673.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/063d0666d554d0959adfc81c349cb83d.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/0673dd27f6e49f68739e9e4234717375.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/07612394a0a7d1cc3c8339cfeb9d9543.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/0bb421449911a6500d97130aa4bc6ab6.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/0e9227fe8deaaf9f92d607ebeddf2e7b.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/1075b73a6f294d9d839c54f5cf84c161.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/16656b2e25391c0d6961398e0b33438c.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/16c17249e992d0434dafaf1d4560a186.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/1746c639b45c30c5d8a78c07946d0b74.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/1aa2f2dde13c2e4f69c6d37745031eb7.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/1b71aa693473e9e8829aaaa28d422113.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/21f22e40241373502bfd7571e04fea2e.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/2cc003b4c1b0e279f69b8e132455a3d9.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/2dcd9f9ba91dfc9f38b2d0c978eee907.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/300a1be5241e31b486b141f651537a10.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/3012d9cdc7b6a235cf21f278c4ec7835.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/302198f4003d0d34b9556c19fa948900.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/35c4f67c72de39cfd076dbced4e079f4.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/38e47d65a5bf8cd9e77bd73aa5c290c0.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/3ac7df69254de4a22cbbf9f0f7b6a9a9.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/3b238bd1abbc45411c6a16fc7cce8eae.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/3f72b02a946dc8d01529f81e7bfc8f42.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/403268faeaec6e83fd0ea2d4120ebc51.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/405a6b386665537a9bf08a7edfd33332.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/4111c41fa143cbfaed56fc37c6466644.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/4179da9a8ab3bb04f30e0b06f9cc11ee.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/41b814b3d99119d46d63f63e1e3d10b2.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/41c023e02893c720f735e572cde94c38.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/42acb49276aee8bd58d5b0737999d835.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/437c5fe890ddcf411d4f887be40edec9.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/471ec8ced192fe840acc156049f26ca9.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/4a5cf648ae229a86e6b2a82d6f24e12c.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/4f9ac7c1b1b2147c44b469f178716189.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/508ae8dcf50046bd4d2bc60f88792614.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/539bd44ead73051b12bd1c842e5fb6d3.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/6011e581b95164060eef44796c798516.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/60aed7f90838268a2fa7fb1c1c6dc8cf.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/622748bb2b90b0add233840025966a66.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/637cd17e6bc06a7f5ece19af75fb17cd.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/66079e0bbb4bc3ff4669cde8c628648f.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/6904e512c40cfbaccaad703dba436d1f.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/6937c76f72a59be0a5d52eb9c9510d0c.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/6999aefb22402ec82755d06654ace0d9.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/6bd40652daf7c4a57f9872c14a88eb2c.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/7245725a3cd95dcc0b4d7d2cbdcaaa11.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/77bdd0610bbd64c3871a972069bdddff.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/77cb5dd1ece8cc1b4ca6a5be3ec16ea2.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/783d7fd96d1b122385119d6958f8adfd.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/7a0e9a71bd8b7c34b4d8b3067dea4344.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/7c6a72e92451d4c0b6fdd566af660aa0.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/8340f0fb1da8d4309b06ed640a132cd7.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/84cfa40923943ec61595a989adb93219.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/8640041a103122935a4d661c4ef72956.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/8701c50caac6fbedde09900c67fea93d.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/8875a1d14a82c56052f7eb66cbeff01b.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/89c9e8aff6aa19b508fcff8e465e38f1.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/8a457c2917364ef3d6073254327a7116.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/8b2f2e8aba549655e38edc8283db0856.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/8b7a1c45337a405be6a367a7f7bd5231.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/8cd10524226ebe1f82e6cdeeeff89025.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/8d49604c6d4e330f69d9c0e0401604fc.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/8e7597b563230a311ee35e06c49cce78.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/8e908f1298693111a8809261795a975e.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/90d13cd0b57dbf314fce1f3910748bf7.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/95869a797109c7929fad325445407a88.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/96356521717bd98f94bf570498e2bdac.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/96af6ac3ba3e55f503b92bc83ac79b69.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/9d9bd458b2f4acbe847d60a442b36aa7.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/9e27938b109e3215119a9b2e11aafa77.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/9e6993204322f47827edc4298b3ef726.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/a0f315da8305900e0ad315b3643f91b3.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/a68ea6147e3c31fee728549451ae37f6.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/a75815991eaf176d718a0206dce41d4b.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/a7d4f4188cc1eaefa7de230ac685608c.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/a9b737f8216dc68191aa6fa2277205fa.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/aad567af42c39a958d8f91f66f849622.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/abb05534e4a467eae54d2e4d5aa8303c.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/ac73a889c509078f990bf0170dd0dd87.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/ac990b48d75cbd7996a56c81c635d151.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/ae97fdde4bcafc1ee12d3075a20315ed.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/afb2fe1a2b1d00dfad1d76c1eccc4305.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/b4841357e4d27452308979cfdbf1b7b8.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/b4a261ea2e90f4d433d42478a87118cf.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/b9f7c307e9576b1852ea0bb693af1394.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/ba98ff71bfd35d178465c8ace5dcb41f.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/bb195aa468d79e16f3596168c6ff424b.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/be3434c9c19c0b9ef3ff78ba4b9ec6f7.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/c00ffa8322a3fe88202dcd5073c0098d.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/c0df5a1f4b445c57c061d0017fb21b98.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/c56b0fe9c1ec620656b1b06fce26af2b.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/c74bf94dcaa301c8dc622d7ec79f7646.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/c7778ab39b27fa3e82c950c7436eadd3.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/ca3ee27a3dff18c1a2965d4beccec775.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/cd2ebb1f4ba05e8e5fb647389dd8809a.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/d427ef7f69d22902e40305ffb1df3f8d.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/d54081283a3ae9bd2d253bda2d98698d.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/d70e71e96ae16c0b6e2d810577e88e29.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/d9591ac5d4089029997c94bb178eed0e.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/d99f7c0e0ec7c0fe0ca974b925cf0310.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/dc6c744e93600cd81106dd6887d83caf.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/dfbf5a676dad168763561972b5fc729f.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/e0391f77820c95fb17b31ade3a997c50.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/e169629c75b12e1df75e1634e9280d00.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/e2162900b1048fcdcfdf9271f2f8afe3.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/e26571fca7759e10133524b84b83e979.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/e50bfb371c1694e6a3e3f736aa15ed17.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/e5f754595c3e79bac8d252dbe3c34b09.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/e74145422288c07e567aaad5f1705dbe.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/ec0ed12c3cdcfbc55ae90755517ea781.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/ec8d9e5802ab7a65a66ff2781e5f8ba4.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/eebeadc188fd0fd39be73ad0bd3e08d3.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/efae2f878897f192d48765ac41995275.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/f42098039755e3b66b94facca3360fb2.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/f567f85114ddf11b4a128cd461dad643.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/f69a1d64f0ed9c67f924517c67005601.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/f756541b483e7fc07ad1c8c15fe9b95d.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/fb30c0b07249302d3e0985c5d51ca3e7.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/feb60241cc84825b304ba829169c5f79.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/ff5d37e28c04ae8014d2951d468cac13.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/ff8b1b74c174f08c9bfff5953aa46174.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/ffabba4a0fb3f0ca3e93fd96d3aa308a.json.gz +0 -0
- package/src/.umi/core/devScripts.ts +53 -0
- package/src/.umi/core/history.ts +21 -0
- package/src/.umi/core/plugin.ts +8 -0
- package/src/.umi/core/pluginConfig.d.ts +304 -0
- package/src/.umi/core/pluginRegister.ts +15 -0
- package/src/.umi/core/polyfill.ts +4 -0
- package/src/.umi/core/routes.ts +24 -0
- package/src/.umi/core/umiExports.ts +7 -0
- package/src/.umi/plugin-helmet/exports.ts +3 -0
- package/src/.umi/plugin-initial-state/Provider.tsx +37 -0
- package/src/.umi/plugin-initial-state/exports.ts +7 -0
- package/src/.umi/plugin-initial-state/models/initialState.ts +2 -0
- package/src/.umi/plugin-initial-state/runtime.tsx +13 -0
- package/src/.umi/plugin-model/Provider.tsx +39 -0
- package/src/.umi/plugin-model/helpers/constant.tsx +4 -0
- package/src/.umi/plugin-model/helpers/dispatcher.tsx +19 -0
- package/src/.umi/plugin-model/helpers/executor.tsx +83 -0
- package/src/.umi/plugin-model/runtime.tsx +12 -0
- package/src/.umi/plugin-model/useModel.tsx +71 -0
- package/src/.umi/plugin-request/request.ts +278 -0
- package/src/.umi/umi.ts +58 -0
- package/src/pages/ModuleUser/index.jsx +29 -2
- package/src/pages/util/axios.js +1 -1
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* Base on https://github.com/umijs//Users/huarui/work/module-menu/node_modules/umi-request
|
|
4
|
+
*/
|
|
5
|
+
import {
|
|
6
|
+
extend,
|
|
7
|
+
Context,
|
|
8
|
+
RequestOptionsInit,
|
|
9
|
+
OnionMiddleware,
|
|
10
|
+
RequestOptionsWithoutResponse,
|
|
11
|
+
RequestMethod,
|
|
12
|
+
RequestOptionsWithResponse,
|
|
13
|
+
RequestResponse,
|
|
14
|
+
RequestInterceptor,
|
|
15
|
+
ResponseInterceptor,
|
|
16
|
+
} from '/Users/huarui/work/module-menu/node_modules/umi-request';
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
|
|
19
|
+
import { ApplyPluginsType } from 'umi';
|
|
20
|
+
import { history, plugin } from '../core/umiExports';
|
|
21
|
+
|
|
22
|
+
// decoupling with antd UI library, you can using `alias` modify the ui methods
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
import { message, notification } from '@umijs/plugin-request/lib/ui';
|
|
25
|
+
import useUmiRequest, { UseRequestProvider } from '/Users/huarui/work/module-menu/node_modules/@ahooksjs/use-request';
|
|
26
|
+
import {
|
|
27
|
+
BaseOptions,
|
|
28
|
+
BasePaginatedOptions,
|
|
29
|
+
BaseResult,
|
|
30
|
+
CombineService,
|
|
31
|
+
LoadMoreFormatReturn,
|
|
32
|
+
LoadMoreOptions,
|
|
33
|
+
LoadMoreOptionsWithFormat,
|
|
34
|
+
LoadMoreParams,
|
|
35
|
+
LoadMoreResult,
|
|
36
|
+
OptionsWithFormat,
|
|
37
|
+
PaginatedFormatReturn,
|
|
38
|
+
PaginatedOptionsWithFormat,
|
|
39
|
+
PaginatedParams,
|
|
40
|
+
PaginatedResult,
|
|
41
|
+
} from '/Users/huarui/work/module-menu/node_modules/@ahooksjs/use-request/lib/types';
|
|
42
|
+
|
|
43
|
+
type ResultWithData<T = any> = { data?: T; [key: string]: any };
|
|
44
|
+
|
|
45
|
+
function useRequest<
|
|
46
|
+
R = any,
|
|
47
|
+
P extends any[] = any,
|
|
48
|
+
U = any,
|
|
49
|
+
UU extends U = any,
|
|
50
|
+
>(
|
|
51
|
+
service: CombineService<R, P>,
|
|
52
|
+
options: OptionsWithFormat<R, P, U, UU>,
|
|
53
|
+
): BaseResult<U, P>;
|
|
54
|
+
function useRequest<R extends ResultWithData = any, P extends any[] = any>(
|
|
55
|
+
service: CombineService<R, P>,
|
|
56
|
+
options?: BaseOptions<R['data'], P>,
|
|
57
|
+
): BaseResult<R['data'], P>;
|
|
58
|
+
function useRequest<R extends LoadMoreFormatReturn = any, RR = any>(
|
|
59
|
+
service: CombineService<RR, LoadMoreParams<R>>,
|
|
60
|
+
options: LoadMoreOptionsWithFormat<R, RR>,
|
|
61
|
+
): LoadMoreResult<R>;
|
|
62
|
+
function useRequest<
|
|
63
|
+
R extends ResultWithData<LoadMoreFormatReturn | any> = any,
|
|
64
|
+
RR extends R = any,
|
|
65
|
+
>(
|
|
66
|
+
service: CombineService<R, LoadMoreParams<R['data']>>,
|
|
67
|
+
options: LoadMoreOptions<RR['data']>,
|
|
68
|
+
): LoadMoreResult<R['data']>;
|
|
69
|
+
|
|
70
|
+
function useRequest<R = any, Item = any, U extends Item = any>(
|
|
71
|
+
service: CombineService<R, PaginatedParams>,
|
|
72
|
+
options: PaginatedOptionsWithFormat<R, Item, U>,
|
|
73
|
+
): PaginatedResult<Item>;
|
|
74
|
+
function useRequest<Item = any, U extends Item = any>(
|
|
75
|
+
service: CombineService<
|
|
76
|
+
ResultWithData<PaginatedFormatReturn<Item>>,
|
|
77
|
+
PaginatedParams
|
|
78
|
+
>,
|
|
79
|
+
options: BasePaginatedOptions<U>,
|
|
80
|
+
): PaginatedResult<Item>;
|
|
81
|
+
function useRequest(service: any, options: any = {}) {
|
|
82
|
+
return useUmiRequest(service, {
|
|
83
|
+
formatResult: result => result?.data,
|
|
84
|
+
requestMethod: (requestOptions: any) => {
|
|
85
|
+
if (typeof requestOptions === 'string') {
|
|
86
|
+
return request(requestOptions);
|
|
87
|
+
}
|
|
88
|
+
if (typeof requestOptions === 'object') {
|
|
89
|
+
const { url, ...rest } = requestOptions;
|
|
90
|
+
return request(url, rest);
|
|
91
|
+
}
|
|
92
|
+
throw new Error('request options error');
|
|
93
|
+
},
|
|
94
|
+
...options,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface RequestConfig extends RequestOptionsInit {
|
|
99
|
+
errorConfig?: {
|
|
100
|
+
errorPage?: string;
|
|
101
|
+
adaptor?: (resData: any, ctx: Context) => ErrorInfoStructure;
|
|
102
|
+
};
|
|
103
|
+
middlewares?: OnionMiddleware[];
|
|
104
|
+
requestInterceptors?: RequestInterceptor[];
|
|
105
|
+
responseInterceptors?: ResponseInterceptor[];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export enum ErrorShowType {
|
|
109
|
+
SILENT = 0,
|
|
110
|
+
WARN_MESSAGE = 1,
|
|
111
|
+
ERROR_MESSAGE = 2,
|
|
112
|
+
NOTIFICATION = 4,
|
|
113
|
+
REDIRECT = 9,
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
interface ErrorInfoStructure {
|
|
117
|
+
success: boolean;
|
|
118
|
+
data?: any;
|
|
119
|
+
errorCode?: string;
|
|
120
|
+
errorMessage?: string;
|
|
121
|
+
showType?: ErrorShowType;
|
|
122
|
+
traceId?: string;
|
|
123
|
+
host?: string;
|
|
124
|
+
[key: string]: any;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
interface RequestError extends Error {
|
|
128
|
+
data?: any;
|
|
129
|
+
info?: ErrorInfoStructure;
|
|
130
|
+
request?: Context['req'];
|
|
131
|
+
response?: Context['res'];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const DEFAULT_ERROR_PAGE = '/exception';
|
|
135
|
+
|
|
136
|
+
let requestMethodInstance: RequestMethod;
|
|
137
|
+
const getRequestMethod = () => {
|
|
138
|
+
if (requestMethodInstance) {
|
|
139
|
+
// request method 已经示例化
|
|
140
|
+
return requestMethodInstance;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// runtime 配置可能应为依赖顺序的问题在模块初始化的时候无法获取,所以需要封装一层在异步调用后初始化相关方法
|
|
144
|
+
// 当用户的 app.ts 中依赖了该文件的情况下就该模块的初始化时间就会被提前,无法获取到运行时配置
|
|
145
|
+
const requestConfig: RequestConfig = plugin.applyPlugins({
|
|
146
|
+
key: 'request',
|
|
147
|
+
type: ApplyPluginsType.modify,
|
|
148
|
+
initialValue: {},
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
const errorAdaptor =
|
|
152
|
+
requestConfig.errorConfig?.adaptor || ((resData) => resData);
|
|
153
|
+
|
|
154
|
+
requestMethodInstance = extend({
|
|
155
|
+
errorHandler: (error: RequestError) => {
|
|
156
|
+
// @ts-ignore
|
|
157
|
+
if (error?.request?.options?.skipErrorHandler) {
|
|
158
|
+
throw error;
|
|
159
|
+
}
|
|
160
|
+
let errorInfo: ErrorInfoStructure | undefined;
|
|
161
|
+
if (error.name === 'ResponseError' && error.data && error.request) {
|
|
162
|
+
const ctx: Context = {
|
|
163
|
+
req: error.request,
|
|
164
|
+
res: error.response,
|
|
165
|
+
};
|
|
166
|
+
errorInfo = errorAdaptor(error.data, ctx);
|
|
167
|
+
error.message = errorInfo?.errorMessage || error.message;
|
|
168
|
+
error.data = error.data;
|
|
169
|
+
error.info = errorInfo;
|
|
170
|
+
}
|
|
171
|
+
errorInfo = error.info;
|
|
172
|
+
|
|
173
|
+
if (errorInfo) {
|
|
174
|
+
const errorMessage = errorInfo?.errorMessage;
|
|
175
|
+
const errorCode = errorInfo?.errorCode;
|
|
176
|
+
const errorPage =
|
|
177
|
+
requestConfig.errorConfig?.errorPage || DEFAULT_ERROR_PAGE;
|
|
178
|
+
|
|
179
|
+
switch (errorInfo?.showType) {
|
|
180
|
+
case ErrorShowType.SILENT:
|
|
181
|
+
// do nothing
|
|
182
|
+
break;
|
|
183
|
+
case ErrorShowType.WARN_MESSAGE:
|
|
184
|
+
message.warn(errorMessage);
|
|
185
|
+
break;
|
|
186
|
+
case ErrorShowType.ERROR_MESSAGE:
|
|
187
|
+
message.error(errorMessage);
|
|
188
|
+
break;
|
|
189
|
+
case ErrorShowType.NOTIFICATION:
|
|
190
|
+
notification.open({
|
|
191
|
+
description: errorMessage,
|
|
192
|
+
message: errorCode,
|
|
193
|
+
});
|
|
194
|
+
break;
|
|
195
|
+
case ErrorShowType.REDIRECT:
|
|
196
|
+
// @ts-ignore
|
|
197
|
+
history.push({
|
|
198
|
+
pathname: errorPage,
|
|
199
|
+
query: { errorCode, errorMessage },
|
|
200
|
+
});
|
|
201
|
+
// redirect to error page
|
|
202
|
+
break;
|
|
203
|
+
default:
|
|
204
|
+
message.error(errorMessage);
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
} else {
|
|
208
|
+
message.error(error.message || 'Request error, please retry.');
|
|
209
|
+
}
|
|
210
|
+
throw error;
|
|
211
|
+
},
|
|
212
|
+
...requestConfig,
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// 中间件统一错误处理
|
|
216
|
+
// 后端返回格式 { success: boolean, data: any }
|
|
217
|
+
// 按照项目具体情况修改该部分逻辑
|
|
218
|
+
requestMethodInstance.use(async (ctx, next) => {
|
|
219
|
+
await next();
|
|
220
|
+
const { req, res } = ctx;
|
|
221
|
+
// @ts-ignore
|
|
222
|
+
if (req.options?.skipErrorHandler) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
const { options } = req;
|
|
226
|
+
const { getResponse } = options;
|
|
227
|
+
const resData = getResponse ? res.data : res;
|
|
228
|
+
const errorInfo = errorAdaptor(resData, ctx);
|
|
229
|
+
if (errorInfo.success === false) {
|
|
230
|
+
// 抛出错误到 errorHandler 中处理
|
|
231
|
+
const error: RequestError = new Error(errorInfo.errorMessage);
|
|
232
|
+
error.name = 'BizError';
|
|
233
|
+
error.data = resData;
|
|
234
|
+
error.info = errorInfo;
|
|
235
|
+
error.response = res;
|
|
236
|
+
throw error;
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
// Add user custom middlewares
|
|
241
|
+
const customMiddlewares = requestConfig.middlewares || [];
|
|
242
|
+
customMiddlewares.forEach((mw) => {
|
|
243
|
+
requestMethodInstance.use(mw);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
// Add user custom interceptors
|
|
247
|
+
const requestInterceptors = requestConfig.requestInterceptors || [];
|
|
248
|
+
const responseInterceptors = requestConfig.responseInterceptors || [];
|
|
249
|
+
requestInterceptors.map((ri) => {
|
|
250
|
+
requestMethodInstance.interceptors.request.use(ri);
|
|
251
|
+
});
|
|
252
|
+
responseInterceptors.map((ri) => {
|
|
253
|
+
requestMethodInstance.interceptors.response.use(ri);
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
return requestMethodInstance;
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
interface RequestMethodInUmi<R = false> {
|
|
260
|
+
<T = any>(
|
|
261
|
+
url: string,
|
|
262
|
+
options: RequestOptionsWithResponse & { skipErrorHandler?: boolean },
|
|
263
|
+
): Promise<RequestResponse<T>>;
|
|
264
|
+
<T = any>(
|
|
265
|
+
url: string,
|
|
266
|
+
options: RequestOptionsWithoutResponse & { skipErrorHandler?: boolean },
|
|
267
|
+
): Promise<T>;
|
|
268
|
+
<T = any>(
|
|
269
|
+
url: string,
|
|
270
|
+
options?: RequestOptionsInit & { skipErrorHandler?: boolean },
|
|
271
|
+
): R extends true ? Promise<RequestResponse<T>> : Promise<T>;
|
|
272
|
+
}
|
|
273
|
+
const request: RequestMethodInUmi = (url: any, options: any) => {
|
|
274
|
+
const requestMethod = getRequestMethod();
|
|
275
|
+
return requestMethod(url, options);
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
export { request, useRequest, UseRequestProvider };
|
package/src/.umi/umi.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import './core/polyfill';
|
|
3
|
+
import '@@/core/devScripts';
|
|
4
|
+
import { plugin } from './core/plugin';
|
|
5
|
+
import './core/pluginRegister';
|
|
6
|
+
import { createHistory } from './core/history';
|
|
7
|
+
import { ApplyPluginsType } from '/Users/huarui/work/module-menu/node_modules/@umijs/runtime';
|
|
8
|
+
import { renderClient } from '/Users/huarui/work/module-menu/node_modules/@umijs/renderer-react/dist/index.js';
|
|
9
|
+
import { getRoutes } from './core/routes';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
const getClientRender = (args: { hot?: boolean; routes?: any[] } = {}) => plugin.applyPlugins({
|
|
15
|
+
key: 'render',
|
|
16
|
+
type: ApplyPluginsType.compose,
|
|
17
|
+
initialValue: () => {
|
|
18
|
+
const opts = plugin.applyPlugins({
|
|
19
|
+
key: 'modifyClientRenderOpts',
|
|
20
|
+
type: ApplyPluginsType.modify,
|
|
21
|
+
initialValue: {
|
|
22
|
+
routes: args.routes || getRoutes(),
|
|
23
|
+
plugin,
|
|
24
|
+
history: createHistory(args.hot),
|
|
25
|
+
isServer: process.env.__IS_SERVER,
|
|
26
|
+
rootElement: 'root',
|
|
27
|
+
defaultTitle: ``,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
return renderClient(opts);
|
|
31
|
+
},
|
|
32
|
+
args,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const clientRender = getClientRender();
|
|
36
|
+
export default clientRender();
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
window.g_umi = {
|
|
40
|
+
version: '3.5.43',
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
// hot module replacement
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
if (module.hot) {
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
module.hot.accept('./core/routes', () => {
|
|
49
|
+
const ret = require('./core/routes');
|
|
50
|
+
if (ret.then) {
|
|
51
|
+
ret.then(({ getRoutes }) => {
|
|
52
|
+
getClientRender({ hot: true, routes: getRoutes() })();
|
|
53
|
+
});
|
|
54
|
+
} else {
|
|
55
|
+
getClientRender({ hot: true, routes: ret.getRoutes() })();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
@@ -19,11 +19,13 @@ import userLogo1 from '../../assets/userLogo1.png';
|
|
|
19
19
|
const ModuleUser = ({ stash = '', isBigDataFoundationPlatform = false }) => {
|
|
20
20
|
const [tenantList, setTenantList] = useState([]);
|
|
21
21
|
const [haveAppSystemPermission, setHaveAppSystemPermission] = useState(false);
|
|
22
|
+
const [getSystemPermission, setGetSystemPermission] = useState(false);
|
|
22
23
|
useEffect(() => {
|
|
23
24
|
localStorage.setItem('stash', stash)
|
|
24
25
|
if (['integration', 'LNRD', 'HBJK'].includes(stash)) {
|
|
25
26
|
getTenantList();
|
|
26
27
|
allSystemList();
|
|
28
|
+
getMenuList();
|
|
27
29
|
}
|
|
28
30
|
}, []);
|
|
29
31
|
const handleClickmenu = (url) => {
|
|
@@ -54,8 +56,8 @@ const ModuleUser = ({ stash = '', isBigDataFoundationPlatform = false }) => {
|
|
|
54
56
|
AppSystemSrc,
|
|
55
57
|
} = userMenuIcon;
|
|
56
58
|
|
|
57
|
-
const isHaveSystemManagementPermission = (['
|
|
58
|
-
? true
|
|
59
|
+
const isHaveSystemManagementPermission = (['LNRD', 'HBJK'].includes(stash))
|
|
60
|
+
? true : stash === 'integration' ? getSystemPermission
|
|
59
61
|
: getStore({ name: 'isHaveSystemManagementPermission' });
|
|
60
62
|
const DEFAULT_LOGOUT_URL = (['integration', 'LNRD', 'HBJK'].includes(stash)) ? '/admin-ui/login' : (stash === 'GZW'? '/data-platform/#/login' : '/#/login');
|
|
61
63
|
|
|
@@ -113,6 +115,31 @@ const ModuleUser = ({ stash = '', isBigDataFoundationPlatform = false }) => {
|
|
|
113
115
|
.catch((e) => console.log('e', e));
|
|
114
116
|
};
|
|
115
117
|
|
|
118
|
+
const hasSystemManageMenu = (menuList) => {
|
|
119
|
+
for (const item of menuList) {
|
|
120
|
+
if (item.name === '系统管理') {
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
if (item.children && item.children.length > 0) {
|
|
124
|
+
if (hasSystemManageMenu(item.children)) {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return false;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const getMenuList = () => {
|
|
133
|
+
Axios('get', '/admin-api/system/auth/list-menus', '')
|
|
134
|
+
.then((res) => {
|
|
135
|
+
if (res.data.code === 0) {
|
|
136
|
+
const hasPermission = hasSystemManageMenu(res.data.data);
|
|
137
|
+
setGetSystemPermission(hasPermission);
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
.catch((e) => console.log('e', e));
|
|
141
|
+
}
|
|
142
|
+
|
|
116
143
|
// 退出登录
|
|
117
144
|
const logout = () => {
|
|
118
145
|
const logoutUrl = (['integration', 'LNRD', 'HBJK'].includes(stash))
|
package/src/pages/util/axios.js
CHANGED
|
@@ -5,7 +5,7 @@ import getStore from './userInfo';
|
|
|
5
5
|
import { checkToken } from './permessionUtils';
|
|
6
6
|
import CONSTANT from './constant';
|
|
7
7
|
|
|
8
|
-
let tokenValue = '
|
|
8
|
+
let tokenValue = '4f4862b5fe06405a894323a8f95ea2c7';
|
|
9
9
|
// 轻量级tokenInSessionStor存在(GZW跳/data-platform/#/login,否则/#/login),一体化tokenInSessionStor不存在
|
|
10
10
|
const tokenInSessionStor = window.sessionStorage.getItem(
|
|
11
11
|
'bigdata-access_token',
|