react-base-client 1.0.151 → 1.1.0

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 (33) hide show
  1. package/package.json +2 -3
  2. package/src/.umi/core/EmptyRoute.tsx +9 -0
  3. package/src/.umi/core/defineApp.ts +18 -0
  4. package/src/.umi/core/history.ts +64 -0
  5. package/src/.umi/core/plugin.ts +52 -0
  6. package/src/.umi/core/pluginConfig.d.ts +327 -0
  7. package/src/.umi/core/polyfill.ts +163 -0
  8. package/src/.umi/core/route.tsx +13 -0
  9. package/src/.umi/core/terminal.ts +38 -0
  10. package/src/.umi/exports.ts +19 -0
  11. package/src/.umi/plugin-access/context.ts +5 -0
  12. package/src/.umi/plugin-access/index.tsx +87 -0
  13. package/src/.umi/plugin-access/runtime.tsx +23 -0
  14. package/src/.umi/plugin-initialState/@@initialState.ts +50 -0
  15. package/src/.umi/plugin-initialState/Provider.tsx +19 -0
  16. package/src/.umi/plugin-initialState/runtime.tsx +8 -0
  17. package/src/.umi/plugin-initialState/runtimeConfig.d.ts +5 -0
  18. package/src/.umi/plugin-model/index.tsx +181 -0
  19. package/src/.umi/plugin-model/model.ts +8 -0
  20. package/src/.umi/plugin-model/runtime.tsx +20 -0
  21. package/src/.umi/plugin-request/index.ts +9 -0
  22. package/src/.umi/plugin-request/request.ts +265 -0
  23. package/src/.umi/plugin-request/runtimeConfig.d.ts +6 -0
  24. package/src/.umi/plugin-request/types.d.ts +10 -0
  25. package/src/.umi/testBrowser.tsx +88 -0
  26. package/src/.umi/tsconfig.json +35 -0
  27. package/src/.umi/typings.d.ts +136 -0
  28. package/src/.umi/umi.ts +74 -0
  29. package/src/components/AMap/index.tsx +90 -32
  30. package/src/components/AMap/typing.d.ts +41 -36
  31. package/src/components/SubmitForm/index.tsx +138 -133
  32. package/src/components/XAMap/index.tsx +167 -0
  33. package/tsconfig.json +0 -29
@@ -0,0 +1,265 @@
1
+ // @ts-nocheck
2
+ // This file is generated by Umi automatically
3
+ // DO NOT CHANGE IT MANUALLY!
4
+ import axios, {
5
+ type AxiosInstance,
6
+ type AxiosRequestConfig,
7
+ type AxiosResponse,
8
+ type AxiosError,
9
+ } from 'H:/af_code/af-react-mobile-base-client/node_modules/axios';
10
+ import useUmiRequest, { UseRequestProvider } from 'H:/af_code/af-react-mobile-base-client/node_modules/@ahooksjs/use-request';
11
+ import { ApplyPluginsType } from 'umi';
12
+ import { getPluginManager } from '../core/plugin';
13
+
14
+ import {
15
+ BaseOptions,
16
+ BasePaginatedOptions,
17
+ BaseResult,
18
+ CombineService,
19
+ LoadMoreFormatReturn,
20
+ LoadMoreOptions,
21
+ LoadMoreOptionsWithFormat,
22
+ LoadMoreParams,
23
+ LoadMoreResult,
24
+ OptionsWithFormat,
25
+ PaginatedFormatReturn,
26
+ PaginatedOptionsWithFormat,
27
+ PaginatedParams,
28
+ PaginatedResult,
29
+ } from 'H:/af_code/af-react-mobile-base-client/node_modules/@ahooksjs/use-request/es/types';
30
+
31
+ type ResultWithData< T = any > = { data?: T; [key: string]: any };
32
+
33
+ function useRequest<
34
+ R = any,
35
+ P extends any[] = any,
36
+ U = any,
37
+ UU extends U = any,
38
+ >(
39
+ service: CombineService<R, P>,
40
+ options: OptionsWithFormat<R, P, U, UU>,
41
+ ): BaseResult<U, P>;
42
+ function useRequest<R extends ResultWithData = any, P extends any[] = any>(
43
+ service: CombineService<R, P>,
44
+ options?: BaseOptions<R['data'], P>,
45
+ ): BaseResult<R['data'], P>;
46
+ function useRequest<R extends LoadMoreFormatReturn = any, RR = any>(
47
+ service: CombineService<RR, LoadMoreParams<R>>,
48
+ options: LoadMoreOptionsWithFormat<R, RR>,
49
+ ): LoadMoreResult<R>;
50
+ function useRequest<
51
+ R extends ResultWithData<LoadMoreFormatReturn | any> = any,
52
+ RR extends R = any,
53
+ >(
54
+ service: CombineService<R, LoadMoreParams<R['data']>>,
55
+ options: LoadMoreOptions<RR['data']>,
56
+ ): LoadMoreResult<R['data']>;
57
+
58
+ function useRequest<R = any, Item = any, U extends Item = any>(
59
+ service: CombineService<R, PaginatedParams>,
60
+ options: PaginatedOptionsWithFormat<R, Item, U>,
61
+ ): PaginatedResult<Item>;
62
+ function useRequest<Item = any, U extends Item = any>(
63
+ service: CombineService<
64
+ ResultWithData<PaginatedFormatReturn<Item>>,
65
+ PaginatedParams
66
+ >,
67
+ options: BasePaginatedOptions<U>,
68
+ ): PaginatedResult<Item>;
69
+ function useRequest(service: any, options: any = {}) {
70
+ return useUmiRequest(service, {
71
+ formatResult: result => result?.data,
72
+ requestMethod: (requestOptions: any) => {
73
+ if (typeof requestOptions === 'string') {
74
+ return request(requestOptions);
75
+ }
76
+ if (typeof requestOptions === 'object') {
77
+ const { url, ...rest } = requestOptions;
78
+ return request(url, rest);
79
+ }
80
+ throw new Error('request options error');
81
+ },
82
+ ...options,
83
+ });
84
+ }
85
+
86
+ // request 方法 opts 参数的接口
87
+ interface IRequestOptions extends AxiosRequestConfig {
88
+ skipErrorHandler?: boolean;
89
+ requestInterceptors?: IRequestInterceptorTuple[];
90
+ responseInterceptors?: IResponseInterceptorTuple[];
91
+ [key: string]: any;
92
+ }
93
+
94
+ interface IRequestOptionsWithResponse extends IRequestOptions {
95
+ getResponse: true;
96
+ }
97
+
98
+ interface IRequestOptionsWithoutResponse extends IRequestOptions{
99
+ getResponse: false;
100
+ }
101
+
102
+ interface IRequest{
103
+ <T = any>(url: string, opts: IRequestOptionsWithResponse): Promise<AxiosResponse<T>>;
104
+ <T = any>(url: string, opts: IRequestOptionsWithoutResponse): Promise<T>;
105
+ <T = any>(url: string, opts: IRequestOptions): Promise<T>; // getResponse 默认是 false, 因此不提供该参数时,只返回 data
106
+ <T = any>(url: string): Promise<T>; // 不提供 opts 时,默认使用 'GET' method,并且默认返回 data
107
+ }
108
+
109
+ type RequestError = AxiosError | Error
110
+
111
+ interface IErrorHandler {
112
+ (error: RequestError, opts: IRequestOptions): void;
113
+ }
114
+ type IRequestInterceptorAxios = (config: RequestOptions) => RequestOptions;
115
+ type IRequestInterceptorUmiRequest = (url: string, config : RequestOptions) => { url: string, options: RequestOptions };
116
+ type IRequestInterceptor = IRequestInterceptorAxios | IRequestInterceptorUmiRequest;
117
+ type IErrorInterceptor = (error: Error) => Promise<Error>;
118
+ type IResponseInterceptor = <T = any>(response : AxiosResponse<T>) => AxiosResponse<T> ;
119
+ type IRequestInterceptorTuple = [IRequestInterceptor , IErrorInterceptor] | [ IRequestInterceptor ] | IRequestInterceptor
120
+ type IResponseInterceptorTuple = [IResponseInterceptor, IErrorInterceptor] | [IResponseInterceptor] | IResponseInterceptor
121
+
122
+ export interface RequestConfig<T = any> extends AxiosRequestConfig {
123
+ errorConfig?: {
124
+ errorHandler?: IErrorHandler;
125
+ errorThrower?: ( res: T ) => void
126
+ };
127
+ requestInterceptors?: IRequestInterceptorTuple[];
128
+ responseInterceptors?: IResponseInterceptorTuple[];
129
+ }
130
+
131
+ let requestInstance: AxiosInstance;
132
+ let config: RequestConfig;
133
+ const getConfig = (): RequestConfig => {
134
+ if (config) return config;
135
+ config = getPluginManager().applyPlugins({
136
+ key: 'request',
137
+ type: ApplyPluginsType.modify,
138
+ initialValue: {},
139
+ });
140
+ return config;
141
+ };
142
+
143
+ const getRequestInstance = (): AxiosInstance => {
144
+ if (requestInstance) return requestInstance;
145
+ const config = getConfig();
146
+ requestInstance = axios.create(config);
147
+
148
+ config?.requestInterceptors?.forEach((interceptor) => {
149
+ if(interceptor instanceof Array){
150
+ requestInstance.interceptors.request.use((config) => {
151
+ const { url } = config;
152
+ if(interceptor[0].length === 2){
153
+ const { url: newUrl, options } = interceptor[0](url, config);
154
+ return { ...options, url: newUrl };
155
+ }
156
+ return interceptor[0](config);
157
+ }, interceptor[1]);
158
+ } else {
159
+ requestInstance.interceptors.request.use((config) => {
160
+ const { url } = config;
161
+ if(interceptor.length === 2){
162
+ const { url: newUrl, options } = interceptor(url, config);
163
+ return { ...options, url: newUrl };
164
+ }
165
+ return interceptor(config);
166
+ })
167
+ }
168
+ });
169
+
170
+ config?.responseInterceptors?.forEach((interceptor) => {
171
+ interceptor instanceof Array ?
172
+ requestInstance.interceptors.response.use(interceptor[0], interceptor[1]):
173
+ requestInstance.interceptors.response.use(interceptor);
174
+ });
175
+
176
+ // 当响应的数据 success 是 false 的时候,抛出 error 以供 errorHandler 处理。
177
+ requestInstance.interceptors.response.use((response) => {
178
+ const { data } = response;
179
+ if(data?.success === false && config?.errorConfig?.errorThrower){
180
+ config.errorConfig.errorThrower(data);
181
+ }
182
+ return response;
183
+ })
184
+ return requestInstance;
185
+ };
186
+
187
+ const request: IRequest = (url: string, opts: any = { method: 'GET' }) => {
188
+ const requestInstance = getRequestInstance();
189
+ const config = getConfig();
190
+ const { getResponse = false, requestInterceptors, responseInterceptors } = opts;
191
+ const requestInterceptorsToEject = requestInterceptors?.map((interceptor) => {
192
+ if(interceptor instanceof Array){
193
+ return requestInstance.interceptors.request.use((config) => {
194
+ const { url } = config;
195
+ if(interceptor[0].length === 2){
196
+ const { url: newUrl, options } = interceptor[0](url, config);
197
+ return { ...options, url: newUrl };
198
+ }
199
+ return interceptor[0](config);
200
+ }, interceptor[1]);
201
+ } else {
202
+ return requestInstance.interceptors.request.use((config) => {
203
+ const { url } = config;
204
+ if(interceptor.length === 2){
205
+ const { url: newUrl, options } = interceptor(url, config);
206
+ return { ...options, url: newUrl };
207
+ }
208
+ return interceptor(config);
209
+ })
210
+ }
211
+ });
212
+ const responseInterceptorsToEject = responseInterceptors?.map((interceptor) => {
213
+ return interceptor instanceof Array ?
214
+ requestInstance.interceptors.response.use(interceptor[0], interceptor[1]):
215
+ requestInstance.interceptors.response.use(interceptor);
216
+ });
217
+ return new Promise((resolve, reject)=>{
218
+ requestInstance
219
+ .request({...opts, url})
220
+ .then((res)=>{
221
+ requestInterceptorsToEject?.forEach((interceptor) => {
222
+ requestInstance.interceptors.request.eject(interceptor);
223
+ });
224
+ responseInterceptorsToEject?.forEach((interceptor) => {
225
+ requestInstance.interceptors.response.eject(interceptor);
226
+ });
227
+ resolve(getResponse ? res : res.data);
228
+ })
229
+ .catch((error)=>{
230
+ requestInterceptorsToEject?.forEach((interceptor) => {
231
+ requestInstance.interceptors.request.eject(interceptor);
232
+ });
233
+ responseInterceptorsToEject?.forEach((interceptor) => {
234
+ requestInstance.interceptors.response.eject(interceptor);
235
+ });
236
+ try {
237
+ const handler =
238
+ config?.errorConfig?.errorHandler;
239
+ if(handler)
240
+ handler(error, opts, config);
241
+ } catch (e) {
242
+ reject(e);
243
+ }
244
+ reject(error);
245
+ })
246
+ })
247
+ }
248
+
249
+ export {
250
+ useRequest,
251
+ UseRequestProvider,
252
+ request,
253
+ getRequestInstance,
254
+ };
255
+
256
+ export type {
257
+ AxiosInstance,
258
+ AxiosRequestConfig,
259
+ AxiosResponse,
260
+ AxiosError,
261
+ RequestError,
262
+ IResponseInterceptor as ResponseInterceptor,
263
+ IRequestOptions as RequestOptions,
264
+ IRequest as Request,
265
+ };
@@ -0,0 +1,6 @@
1
+ // This file is generated by Umi automatically
2
+ // DO NOT CHANGE IT MANUALLY!
3
+ import type { RequestConfig } from './types.d'
4
+ export type IRuntimeConfig = {
5
+ request?: RequestConfig
6
+ };
@@ -0,0 +1,10 @@
1
+ // This file is generated by Umi automatically
2
+ // DO NOT CHANGE IT MANUALLY!
3
+ export type {
4
+ RequestConfig,
5
+ AxiosInstance,
6
+ AxiosRequestConfig,
7
+ AxiosResponse,
8
+ AxiosError,
9
+ RequestError,
10
+ ResponseInterceptor } from './request';
@@ -0,0 +1,88 @@
1
+ // @ts-nocheck
2
+ // This file is generated by Umi automatically
3
+ // DO NOT CHANGE IT MANUALLY!
4
+ import React, { useEffect, useState } from 'react';
5
+ import { ApplyPluginsType } from 'umi';
6
+ import { renderClient, RenderClientOpts } from 'H:/af_code/af-react-mobile-base-client/node_modules/@umijs/renderer-react';
7
+ import { createHistory } from './core/history';
8
+ import { createPluginManager } from './core/plugin';
9
+ import { getRoutes } from './core/route';
10
+ import type { Location } from 'history';
11
+
12
+ import './core/polyfill';
13
+
14
+ const publicPath = '/';
15
+ const runtimePublicPath = false;
16
+
17
+ type TestBrowserProps = {
18
+ location?: Partial<Location>;
19
+ historyRef?: React.MutableRefObject<Location>;
20
+ };
21
+
22
+ export function TestBrowser(props: TestBrowserProps) {
23
+ const pluginManager = createPluginManager();
24
+ const [context, setContext] = useState<RenderClientOpts | undefined>(
25
+ undefined
26
+ );
27
+ useEffect(() => {
28
+ const genContext = async () => {
29
+ const { routes, routeComponents } = await getRoutes(pluginManager);
30
+ // allow user to extend routes
31
+ await pluginManager.applyPlugins({
32
+ key: 'patchRoutes',
33
+ type: ApplyPluginsType.event,
34
+ args: {
35
+ routes,
36
+ routeComponents,
37
+ },
38
+ });
39
+ const contextOpts = pluginManager.applyPlugins({
40
+ key: 'modifyContextOpts',
41
+ type: ApplyPluginsType.modify,
42
+ initialValue: {},
43
+ });
44
+ const basename = contextOpts.basename || '/';
45
+ const history = createHistory({
46
+ type: 'memory',
47
+ basename,
48
+ });
49
+ const context = {
50
+ routes,
51
+ routeComponents,
52
+ pluginManager,
53
+ rootElement: contextOpts.rootElement || document.getElementById('root'),
54
+ publicPath,
55
+ runtimePublicPath,
56
+ history,
57
+ basename,
58
+ components: true,
59
+ };
60
+ const modifiedContext = pluginManager.applyPlugins({
61
+ key: 'modifyClientRenderOpts',
62
+ type: ApplyPluginsType.modify,
63
+ initialValue: context,
64
+ });
65
+ return modifiedContext;
66
+ };
67
+ genContext().then((context) => {
68
+ setContext(context);
69
+ if (props.location) {
70
+ context?.history?.push(props.location);
71
+ }
72
+ if (props.historyRef) {
73
+ props.historyRef.current = context?.history;
74
+ }
75
+ });
76
+ }, []);
77
+
78
+ if (context === undefined) {
79
+ return <div id="loading" />;
80
+ }
81
+
82
+ const Children = renderClient(context);
83
+ return (
84
+ <React.Fragment>
85
+ <Children />
86
+ </React.Fragment>
87
+ );
88
+ }
@@ -0,0 +1,35 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "esnext",
4
+ "module": "esnext",
5
+ "moduleResolution": "node",
6
+ "importHelpers": true,
7
+ "jsx": "react-jsx",
8
+ "esModuleInterop": true,
9
+ "sourceMap": true,
10
+ "baseUrl": "../../",
11
+ "strict": true,
12
+ "resolveJsonModule": true,
13
+ "allowSyntheticDefaultImports": true,
14
+ "paths": {
15
+ "@/*": [
16
+ "src/*"
17
+ ],
18
+ "@@/*": [
19
+ "src/.umi/*"
20
+ ],
21
+ "@umijs/max": [
22
+ "H:\\af_code\\af-react-mobile-base-client\\node_modules\\umi"
23
+ ],
24
+ "@umijs/max/typings": [
25
+ "src/.umi/typings"
26
+ ]
27
+ }
28
+ },
29
+ "include": [
30
+ "../../.umirc.ts",
31
+ "../../**/*.d.ts",
32
+ "../../**/*.ts",
33
+ "../../**/*.tsx"
34
+ ]
35
+ }
@@ -0,0 +1,136 @@
1
+ // This file is generated by Umi automatically
2
+ // DO NOT CHANGE IT MANUALLY!
3
+ type CSSModuleClasses = { readonly [key: string]: string }
4
+ declare module '*.css' {
5
+ const classes: CSSModuleClasses
6
+ export default classes
7
+ }
8
+ declare module '*.scss' {
9
+ const classes: CSSModuleClasses
10
+ export default classes
11
+ }
12
+ declare module '*.sass' {
13
+ const classes: CSSModuleClasses
14
+ export default classes
15
+ }
16
+ declare module '*.less' {
17
+ const classes: CSSModuleClasses
18
+ export default classes
19
+ }
20
+ declare module '*.styl' {
21
+ const classes: CSSModuleClasses
22
+ export default classes
23
+ }
24
+ declare module '*.stylus' {
25
+ const classes: CSSModuleClasses
26
+ export default classes
27
+ }
28
+
29
+ // images
30
+ declare module '*.jpg' {
31
+ const src: string
32
+ export default src
33
+ }
34
+ declare module '*.jpeg' {
35
+ const src: string
36
+ export default src
37
+ }
38
+ declare module '*.png' {
39
+ const src: string
40
+ export default src
41
+ }
42
+ declare module '*.gif' {
43
+ const src: string
44
+ export default src
45
+ }
46
+ declare module '*.svg' {
47
+ import * as React from 'react';
48
+ export const ReactComponent: React.FunctionComponent<React.SVGProps<
49
+ SVGSVGElement
50
+ > & { title?: string }>;
51
+
52
+ const src: string
53
+ export default src
54
+ }
55
+ declare module '*.ico' {
56
+ const src: string
57
+ export default src
58
+ }
59
+ declare module '*.webp' {
60
+ const src: string
61
+ export default src
62
+ }
63
+ declare module '*.avif' {
64
+ const src: string
65
+ export default src
66
+ }
67
+
68
+ // media
69
+ declare module '*.mp4' {
70
+ const src: string
71
+ export default src
72
+ }
73
+ declare module '*.webm' {
74
+ const src: string
75
+ export default src
76
+ }
77
+ declare module '*.ogg' {
78
+ const src: string
79
+ export default src
80
+ }
81
+ declare module '*.mp3' {
82
+ const src: string
83
+ export default src
84
+ }
85
+ declare module '*.wav' {
86
+ const src: string
87
+ export default src
88
+ }
89
+ declare module '*.flac' {
90
+ const src: string
91
+ export default src
92
+ }
93
+ declare module '*.aac' {
94
+ const src: string
95
+ export default src
96
+ }
97
+
98
+ // fonts
99
+ declare module '*.woff' {
100
+ const src: string
101
+ export default src
102
+ }
103
+ declare module '*.woff2' {
104
+ const src: string
105
+ export default src
106
+ }
107
+ declare module '*.eot' {
108
+ const src: string
109
+ export default src
110
+ }
111
+ declare module '*.ttf' {
112
+ const src: string
113
+ export default src
114
+ }
115
+ declare module '*.otf' {
116
+ const src: string
117
+ export default src
118
+ }
119
+
120
+ // other
121
+ declare module '*.wasm' {
122
+ const initWasm: (options: WebAssembly.Imports) => Promise<WebAssembly.Exports>
123
+ export default initWasm
124
+ }
125
+ declare module '*.webmanifest' {
126
+ const src: string
127
+ export default src
128
+ }
129
+ declare module '*.pdf' {
130
+ const src: string
131
+ export default src
132
+ }
133
+ declare module '*.txt' {
134
+ const src: string
135
+ export default src
136
+ }
@@ -0,0 +1,74 @@
1
+ // @ts-nocheck
2
+ // This file is generated by Umi automatically
3
+ // DO NOT CHANGE IT MANUALLY!
4
+ import './core/polyfill';
5
+
6
+ import { renderClient } from 'H:/af_code/af-react-mobile-base-client/node_modules/@umijs/renderer-react';
7
+ import { getRoutes } from './core/route';
8
+ import { createPluginManager } from './core/plugin';
9
+ import { createHistory } from './core/history';
10
+ import { ApplyPluginsType } from 'umi';
11
+
12
+
13
+ const publicPath = "/";
14
+ const runtimePublicPath = false;
15
+
16
+ async function render() {
17
+ const pluginManager = createPluginManager();
18
+ const { routes, routeComponents } = await getRoutes(pluginManager);
19
+
20
+ // allow user to extend routes
21
+ await pluginManager.applyPlugins({
22
+ key: 'patchRoutes',
23
+ type: ApplyPluginsType.event,
24
+ args: {
25
+ routes,
26
+ routeComponents,
27
+ },
28
+ });
29
+
30
+ const contextOpts = pluginManager.applyPlugins({
31
+ key: 'modifyContextOpts',
32
+ type: ApplyPluginsType.modify,
33
+ initialValue: {},
34
+ });
35
+
36
+ const basename = contextOpts.basename || '/';
37
+
38
+ const history = createHistory({
39
+ type: contextOpts.historyType || 'hash',
40
+ basename,
41
+ ...contextOpts.historyOpts,
42
+ });
43
+
44
+ return (pluginManager.applyPlugins({
45
+ key: 'render',
46
+ type: ApplyPluginsType.compose,
47
+ initialValue() {
48
+ const context = {
49
+ routes,
50
+ routeComponents,
51
+ pluginManager,
52
+ rootElement: contextOpts.rootElement || document.getElementById('root'),
53
+ publicPath,
54
+ runtimePublicPath,
55
+ history,
56
+ basename,
57
+ callback: contextOpts.callback,
58
+ };
59
+ const modifiedContext = pluginManager.applyPlugins({
60
+ key: 'modifyClientRenderOpts',
61
+ type: ApplyPluginsType.modify,
62
+ initialValue: context,
63
+ });
64
+ return renderClient(modifiedContext);
65
+ },
66
+ }))();
67
+ }
68
+
69
+
70
+ render();
71
+
72
+ window.g_umi = {
73
+ version: '4.0.36',
74
+ };