module-menu 0.0.6 → 0.0.8

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.
Files changed (69) hide show
  1. package/.editorconfig +16 -0
  2. package/.prettierignore +8 -0
  3. package/.prettierrc +11 -0
  4. package/.umirc.js +11 -0
  5. package/README.md +10 -65
  6. package/dist/index.html +22 -0
  7. package/dist/static/childIcon.797194d8.svg +10 -0
  8. package/dist/static/home.c9f8fbce.svg +12 -0
  9. package/dist/static/menuIcon.a281e69f.svg +1 -0
  10. package/dist/static/module.287d1998.svg +12 -0
  11. package/dist/umi.css +1 -0
  12. package/dist/umi.js +1 -0
  13. package/mock/.gitkeep +0 -0
  14. package/package.json +29 -31
  15. package/src/.umi/.cache/babel-loader/006cd391c2d71e6cf49cff32a7d7e7ea.json.gz +0 -0
  16. package/src/.umi/.cache/babel-loader/0338b3888dd146dd07b8a2dadae22515.json.gz +0 -0
  17. package/src/.umi/.cache/babel-loader/046a6f14bf358d879b171cc3fd01a7f1.json.gz +0 -0
  18. package/src/.umi/.cache/babel-loader/06653d4063f1fa0a78dbe664c4d942a2.json.gz +0 -0
  19. package/src/.umi/.cache/babel-loader/07946a12d045541a6da81e832a157386.json.gz +0 -0
  20. package/src/.umi/.cache/babel-loader/098a5cfe0e14aa583144c71244bbaf0d.json.gz +0 -0
  21. package/src/.umi/.cache/babel-loader/0bd5919b2a2a3a6672ace3392d7b54c7.json.gz +0 -0
  22. package/src/.umi/.cache/babel-loader/0e803b5601d075064d8a5641f3170e96.json.gz +0 -0
  23. package/src/.umi/.cache/babel-loader/2cd50d901ae2e761fb8b68217d063338.json.gz +0 -0
  24. package/src/.umi/.cache/babel-loader/31ec5214ed0e837a88908074a704a9f2.json.gz +0 -0
  25. package/src/.umi/.cache/babel-loader/3516c56d068efdb601a4ab92380d0d8d.json.gz +0 -0
  26. package/src/.umi/.cache/babel-loader/38fe4fe93f78903424446b2670dd881a.json.gz +0 -0
  27. package/src/.umi/.cache/babel-loader/3f4c30e441ca71253594a5f549c83e5d.json.gz +0 -0
  28. package/src/.umi/.cache/babel-loader/43a5d580c6a2da6134a17edcf7b87084.json.gz +0 -0
  29. package/src/.umi/.cache/babel-loader/61996ca5ddd9a40ea57e9b8e8208c140.json.gz +0 -0
  30. package/src/.umi/.cache/babel-loader/6432db849c9ee59480c90f5c482cd5b2.json.gz +0 -0
  31. package/src/.umi/.cache/babel-loader/77b6cd8f61f66fa2458792503a65eb37.json.gz +0 -0
  32. package/src/.umi/.cache/babel-loader/7944475811983ddaa4b770f627624e0d.json.gz +0 -0
  33. package/src/.umi/.cache/babel-loader/7b4983c7428750b20c354ecb1cc6226f.json.gz +0 -0
  34. package/src/.umi/.cache/babel-loader/c1e4065a5c16bb60e0dad17fd17e4d21.json.gz +0 -0
  35. package/src/.umi/.cache/babel-loader/c5f25455f80accb4389a63e966193658.json.gz +0 -0
  36. package/src/.umi/.cache/babel-loader/d5cec1443884c84dea19b626dff4a130.json.gz +0 -0
  37. package/src/.umi/.cache/babel-loader/d7d65bbebb7d2a6933b8994ed54ba1f4.json.gz +0 -0
  38. package/src/.umi/.cache/babel-loader/d8e03990d8e0f543ddd2c8b7c1986b6e.json.gz +0 -0
  39. package/src/.umi/.cache/babel-loader/d94d2cccf8876adaf96c9792ae1604d7.json.gz +0 -0
  40. package/src/.umi/.cache/babel-loader/e76ddc963361774c561993f62f13cd1c.json.gz +0 -0
  41. package/src/.umi/core/devScripts.ts +53 -0
  42. package/src/.umi/core/history.ts +21 -0
  43. package/src/.umi/core/plugin.ts +8 -0
  44. package/src/.umi/core/pluginConfig.d.ts +304 -0
  45. package/src/.umi/core/pluginRegister.ts +15 -0
  46. package/src/.umi/core/polyfill.ts +4 -0
  47. package/src/.umi/core/routes.ts +24 -0
  48. package/src/.umi/core/umiExports.ts +7 -0
  49. package/src/.umi/plugin-helmet/exports.ts +3 -0
  50. package/src/.umi/plugin-initial-state/Provider.tsx +37 -0
  51. package/src/.umi/plugin-initial-state/exports.ts +7 -0
  52. package/src/.umi/plugin-initial-state/models/initialState.ts +2 -0
  53. package/src/.umi/plugin-initial-state/runtime.tsx +13 -0
  54. package/src/.umi/plugin-model/Provider.tsx +39 -0
  55. package/src/.umi/plugin-model/helpers/constant.tsx +4 -0
  56. package/src/.umi/plugin-model/helpers/dispatcher.tsx +19 -0
  57. package/src/.umi/plugin-model/helpers/executor.tsx +83 -0
  58. package/src/.umi/plugin-model/runtime.tsx +12 -0
  59. package/src/.umi/plugin-model/useModel.tsx +71 -0
  60. package/src/.umi/plugin-request/request.ts +278 -0
  61. package/src/.umi/umi.ts +58 -0
  62. package/src/{App.js → pages/index.jsx} +15 -17
  63. package/src/{App.css → pages/index.less} +68 -68
  64. package/tsconfig.json +37 -0
  65. package/typings.d.ts +10 -0
  66. package/package-lock.json +0 -30410
  67. package/public/index.html +0 -14
  68. package/public/robots.txt +0 -3
  69. package/src/index.js +0 -11
@@ -0,0 +1,39 @@
1
+ // @ts-nocheck
2
+ import React from 'react';
3
+ import initialState from 'D:/NewGitPro/module-menu/src/.umi/plugin-initial-state/models/initialState';
4
+
5
+ // @ts-ignore
6
+ import Dispatcher from './helpers/dispatcher';
7
+ // @ts-ignore
8
+ import Executor from './helpers/executor';
9
+ // @ts-ignore
10
+ import { UmiContext } from './helpers/constant';
11
+
12
+ export const models = { '@@initialState': initialState, };
13
+
14
+ export type Model<T extends keyof typeof models> = {
15
+ [key in keyof typeof models]: ReturnType<typeof models[T]>;
16
+ };
17
+
18
+ export type Models<T extends keyof typeof models> = Model<T>[T]
19
+
20
+ const dispatcher = new Dispatcher!();
21
+ const Exe = Executor!;
22
+
23
+ export default ({ children }: { children: React.ReactNode }) => {
24
+
25
+ return (
26
+ <UmiContext.Provider value={dispatcher}>
27
+ {
28
+ Object.entries(models).map(pair => (
29
+ <Exe key={pair[0]} namespace={pair[0]} hook={pair[1] as any} onUpdate={(val: any) => {
30
+ const [ns] = pair as [keyof typeof models, any];
31
+ dispatcher.data[ns] = val;
32
+ dispatcher.update(ns);
33
+ }} />
34
+ ))
35
+ }
36
+ {children}
37
+ </UmiContext.Provider>
38
+ )
39
+ }
@@ -0,0 +1,4 @@
1
+ // @ts-nocheck
2
+ import React from 'react';
3
+
4
+ export const UmiContext = React.createContext({});
@@ -0,0 +1,19 @@
1
+ // @ts-nocheck
2
+ export default class Dispatcher {
3
+ callbacks = {};
4
+
5
+ data = {};
6
+
7
+ update = (namespace: string) => {
8
+ (this.callbacks[namespace] || []).forEach(
9
+ (callback: (val: any) => void) => {
10
+ try {
11
+ const data = this.data[namespace];
12
+ callback(data);
13
+ } catch (e) {
14
+ callback(undefined);
15
+ }
16
+ },
17
+ );
18
+ };
19
+ }
@@ -0,0 +1,83 @@
1
+ // @ts-nocheck
2
+ import React, { useEffect, useRef, useMemo } from 'react';
3
+
4
+ interface ExecutorProps {
5
+ hook: () => any;
6
+ onUpdate: (val: any) => void;
7
+ namespace: string;
8
+ }
9
+
10
+ export default (props: ExecutorProps) => {
11
+ const { hook, onUpdate, namespace } = props;
12
+
13
+ const updateRef = useRef(onUpdate);
14
+ updateRef.current = onUpdate;
15
+ const initialLoad = useRef(false);
16
+
17
+ let data: any;
18
+ try {
19
+ data = hook();
20
+ if (
21
+ process.env.NODE_ENV === 'development' &&
22
+ typeof document !== 'undefined'
23
+ ) {
24
+ try {
25
+ let count = Object.keys(
26
+ ((window as any)._umi_useModel_dev_tool_log || {})[namespace] || {},
27
+ ).length;
28
+ (window as any)._umi_useModel_dev_tool = Object.assign(
29
+ (window as any)._umi_useModel_dev_tool || {},
30
+ {
31
+ [namespace]: data,
32
+ },
33
+ );
34
+ (window as any)._umi_useModel_dev_tool_log = Object.assign(
35
+ (window as any)._umi_useModel_dev_tool_log || {},
36
+ {
37
+ [namespace]: Object.assign(
38
+ ((window as any)._umi_useModel_dev_tool_log || {})[namespace] ||
39
+ {},
40
+ {
41
+ [count]: data,
42
+ },
43
+ ),
44
+ },
45
+ );
46
+ window.dispatchEvent(
47
+ new CustomEvent('_umi_useModel_update', {
48
+ detail: {
49
+ namespace,
50
+ time: Date.now(),
51
+ data,
52
+ index: count,
53
+ },
54
+ }),
55
+ );
56
+ } catch (e) {
57
+ // dev tool 记录失败、可能是低版本浏览器,忽略
58
+ }
59
+ }
60
+ } catch (e) {
61
+ console.error(
62
+ `plugin-model: Invoking '${namespace || 'unknown'}' model failed:`,
63
+ e,
64
+ );
65
+ }
66
+
67
+ // 首次执行时立刻返回初始值
68
+ useMemo(() => {
69
+ updateRef.current(data);
70
+ initialLoad.current = false;
71
+ }, []);
72
+
73
+ // React 16.13 后 update 函数用 useEffect 包裹
74
+ useEffect(() => {
75
+ if (initialLoad.current) {
76
+ updateRef.current(data);
77
+ } else {
78
+ initialLoad.current = true;
79
+ }
80
+ });
81
+
82
+ return <></>;
83
+ };
@@ -0,0 +1,12 @@
1
+ // @ts-nocheck
2
+ /* eslint-disable import/no-dynamic-require */
3
+ import React from 'react';
4
+ import Provider from './Provider';
5
+
6
+ export function rootContainer(container: React.ReactNode) {
7
+ return React.createElement(
8
+ Provider,
9
+ null,
10
+ container,
11
+ );
12
+ }
@@ -0,0 +1,71 @@
1
+ // @ts-nocheck
2
+ import { useState, useEffect, useContext, useRef } from 'react';
3
+ // @ts-ignore
4
+ import isEqual from 'D:/NewGitPro/module-menu/node_modules/@umijs/plugin-model/node_modules/fast-deep-equal/index.js';
5
+ // @ts-ignore
6
+ import { UmiContext } from './helpers/constant';
7
+ import { Model, models } from './Provider';
8
+
9
+ export type Models<T extends keyof typeof models> = Model<T>[T]
10
+
11
+ export function useModel<T extends keyof Model<T>>(model: T): Model<T>[T]
12
+ export function useModel<T extends keyof Model<T>, U>(model: T, selector: (model: Model<T>[T]) => U): U
13
+
14
+ export function useModel<T extends keyof Model<T>, U>(
15
+ namespace: T,
16
+ updater?: (model: Model<T>[T]) => U
17
+ ) : typeof updater extends undefined ? Model<T>[T] : ReturnType<NonNullable<typeof updater>>{
18
+
19
+ type RetState = typeof updater extends undefined ? Model<T>[T] : ReturnType<NonNullable<typeof updater>>
20
+ const dispatcher = useContext<any>(UmiContext);
21
+ const updaterRef = useRef(updater);
22
+ updaterRef.current = updater;
23
+ const [state, setState] = useState<RetState>(
24
+ () => updaterRef.current ? updaterRef.current(dispatcher.data![namespace]) : dispatcher.data![namespace]
25
+ );
26
+ const stateRef = useRef<any>(state);
27
+ stateRef.current = state;
28
+
29
+ const isMount = useRef(false);
30
+ useEffect(() => {
31
+ isMount.current = true;
32
+ return () => {
33
+ isMount.current = false;
34
+ }
35
+ }, [])
36
+
37
+ useEffect(() => {
38
+ const handler = (e: any) => {
39
+ if(!isMount.current) {
40
+ // 如果 handler 执行过程中,组件被卸载了,则强制更新全局 data
41
+ setTimeout(() => {
42
+ dispatcher.data![namespace] = e;
43
+ dispatcher.update(namespace);
44
+ });
45
+ } else {
46
+ if(updater && updaterRef.current){
47
+ const currentState = updaterRef.current(e);
48
+ const previousState = stateRef.current
49
+ if(!isEqual(currentState, previousState)){
50
+ setState(currentState);
51
+ }
52
+ } else {
53
+ setState(e);
54
+ }
55
+ }
56
+ }
57
+ try {
58
+ dispatcher.callbacks![namespace]!.add(handler);
59
+ dispatcher.update(namespace);
60
+ } catch (e) {
61
+ dispatcher.callbacks![namespace] = new Set();
62
+ dispatcher.callbacks![namespace]!.add(handler);
63
+ dispatcher.update(namespace);
64
+ }
65
+ return () => {
66
+ dispatcher.callbacks![namespace]!.delete(handler);
67
+ }
68
+ }, [namespace]);
69
+
70
+ return state;
71
+ };
@@ -0,0 +1,278 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * Base on https://github.com/umijs/D:/NewGitPro/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 'D:/NewGitPro/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 'D:/NewGitPro/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 'D:/NewGitPro/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 };
@@ -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 'D:/NewGitPro/module-menu/node_modules/umi/node_modules/@umijs/runtime';
8
+ import { renderClient } from 'D:/NewGitPro/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.41',
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
+ }
@@ -1,10 +1,6 @@
1
1
  import React, { Component } from 'react';
2
2
  import { Popconfirm, message } from 'antd';
3
- import homeIcon from './assets/home.svg'
4
- import moduleIcon from './assets/module.svg'
5
- import menuIcon from './assets/menuIcon.svg'
6
- import childIcon from './assets/childIcon.svg'
7
- import './App.css'
3
+ import './index.less'
8
4
  class ModuleMenu extends Component {
9
5
  constructor(props) {
10
6
  super(props);
@@ -12,19 +8,19 @@ class ModuleMenu extends Component {
12
8
  showMenu: false,
13
9
  menuList: [{
14
10
  name: '首页',
15
- url: homeIcon,
11
+ url: require('../assets/home.svg'),
16
12
  children: []
17
13
  },
18
14
  {
19
15
  name: '数据汇聚',
20
- url: moduleIcon,
16
+ url: require('../assets/module.svg'),
21
17
  children: [{
22
18
  childName: '数据集成平台'
23
19
  }]
24
20
  },
25
21
  {
26
22
  name: '数据治理',
27
- url: moduleIcon,
23
+ url: require('../assets/module.svg'),
28
24
  children: [{
29
25
  childName: '数据治理平台'
30
26
  },
@@ -40,7 +36,7 @@ class ModuleMenu extends Component {
40
36
  },
41
37
  {
42
38
  name: '数据开发',
43
- url: moduleIcon,
39
+ url: require('../assets/module.svg'),
44
40
  children: [{
45
41
  childName: '离线开发平台'
46
42
  },
@@ -50,7 +46,7 @@ class ModuleMenu extends Component {
50
46
  },
51
47
  {
52
48
  name: '数据开放',
53
- url: moduleIcon,
49
+ url: require('../assets/module.svg'),
54
50
  children: [{
55
51
  childName: '数据服务'
56
52
  },
@@ -60,7 +56,7 @@ class ModuleMenu extends Component {
60
56
  },
61
57
  {
62
58
  name: '数据应用',
63
- url: moduleIcon,
59
+ url: require('../assets/module.svg'),
64
60
  children: [{
65
61
  childName: '标签管理系统'
66
62
  },
@@ -125,6 +121,7 @@ class ModuleMenu extends Component {
125
121
  // 跳转各个模块
126
122
  toModulePage (nameStr) {
127
123
  if (!this.state.sessionMenu || this.state.sessionMenu.length === 0) {
124
+ message.destroy()
128
125
  message.warning("没有获取到菜单列表,请联系管理员添加权限");
129
126
  return;
130
127
  }
@@ -181,6 +178,7 @@ class ModuleMenu extends Component {
181
178
  thirdPartyServiceRootMenuPath
182
179
  )
183
180
  ) {
181
+ message.destroy()
184
182
  message.warning("您没有权限,请联系管理员添加权限。");
185
183
  return
186
184
  }
@@ -199,17 +197,17 @@ class ModuleMenu extends Component {
199
197
  return (
200
198
  <div key={item.name} className="cardLine" style={{height: index === 2 ? '90px' : ''}}>
201
199
  <div className='leftMenu'>
202
- <img src={item.url} className="middle" alt=""/>
200
+ <img src={item.url} className="middle"/>
203
201
  <span className="middle textPad" onClick={() => {this.toHomePage(index)}}>{item.name}</span>
204
202
  </div>
205
203
  <div className='rightMenu' style={{height: index === 2 ? '90px' : '', borderBottom: index === 5 ? '0px' : '1px solid #E9E9E9'}}>
206
204
  {
207
205
  item.children.map((child, idx) => {
208
206
  return (
209
- <span key={idx}>
210
- <img src={childIcon} className="middle iconPad" alt=""/>
211
- <span className='childMenu textPad middle' onClick={() => {this.toModulePage(child.childName)}}>{child.childName}</span>
212
- </span>
207
+ <>
208
+ <img src={require('../assets/childIcon.svg')} className="middle iconPad"/>
209
+ <span className='childMenu textPad middle' key={child.childName} onClick={() => {this.toModulePage(child.childName)}}>{child.childName}</span>
210
+ </>
213
211
  )
214
212
  })
215
213
  }
@@ -229,7 +227,7 @@ class ModuleMenu extends Component {
229
227
  showCancel = {false}
230
228
  >
231
229
  <span className='menuIcon'>
232
- <img src={menuIcon} alt=""/>
230
+ <img src={require('../assets/menuIcon.svg')}/>
233
231
  </span>
234
232
  </Popconfirm>
235
233
  </>