@fairys/taro-tools-react 1.0.8 → 1.0.10
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/esm/context/global.setting.data.instance.d.ts +2 -0
- package/esm/context/global.setting.data.instance.js +2 -1
- package/esm/context/page.data.instance.d.ts +15 -15
- package/esm/context/page.data.instance.js +3 -3
- package/esm/context/page.info.data.instance.d.ts +10 -10
- package/esm/context/page.info.data.instance.js +3 -3
- package/esm/utils/request.js +30 -5
- package/lib/context/global.setting.data.instance.d.ts +2 -0
- package/lib/context/global.setting.data.instance.js +2 -1
- package/lib/context/page.data.instance.d.ts +15 -15
- package/lib/context/page.data.instance.js +3 -3
- package/lib/context/page.info.data.instance.d.ts +10 -10
- package/lib/context/page.info.data.instance.js +3 -3
- package/lib/utils/request.js +30 -5
- package/package.json +1 -1
- package/src/context/global.data.instance.ts +1 -0
- package/src/context/global.setting.data.instance.ts +3 -0
- package/src/context/page.data.instance.tsx +36 -26
- package/src/context/page.info.data.instance.tsx +33 -19
- package/src/utils/request.ts +60 -20
|
@@ -9,7 +9,8 @@ class GlobalSettingDataInstance extends ProxyInstanceObjectBase {
|
|
|
9
9
|
loginPageRoute: 'pages/login/index',
|
|
10
10
|
ignoreAuthRoutes: [],
|
|
11
11
|
useAuthHasMenuPermission: true,
|
|
12
|
-
isEnableAuth: true
|
|
12
|
+
isEnableAuth: true,
|
|
13
|
+
isUseTaroToast: true
|
|
13
14
|
};
|
|
14
15
|
store = proxy({
|
|
15
16
|
...this.defaultStore
|
|
@@ -112,40 +112,40 @@ export interface PageDataOptions<T extends PageDataInstanceState = PageDataInsta
|
|
|
112
112
|
defaultPageSize?: number;
|
|
113
113
|
}
|
|
114
114
|
/**初始化实例*/
|
|
115
|
-
export declare function usePageDataInstance<T extends PageDataInstanceState = PageDataInstanceState
|
|
115
|
+
export declare function usePageDataInstance<T extends PageDataInstanceState = PageDataInstanceState, M extends PageDataInstance<T> = PageDataInstance<T>>(instance?: M): M;
|
|
116
116
|
/**页面级数据状态管理上下文*/
|
|
117
117
|
export declare const PageDataInstanceContext: import("react").Context<PageDataInstance<PageDataInstanceState>>;
|
|
118
118
|
/**获取上下文实例*/
|
|
119
|
-
export declare const usePageDataInstanceContext: <T extends PageDataInstanceState = PageDataInstanceState>() =>
|
|
120
|
-
export interface PageDataInstanceContextProviderProps<T extends PageDataInstanceState = PageDataInstanceState> extends PageDataOptions<T> {
|
|
121
|
-
instance?:
|
|
119
|
+
export declare const usePageDataInstanceContext: <T extends PageDataInstanceState = PageDataInstanceState, M extends PageDataInstance<T> = PageDataInstance<T>>() => M;
|
|
120
|
+
export interface PageDataInstanceContextProviderProps<T extends PageDataInstanceState = PageDataInstanceState, M extends PageDataInstance<T> = PageDataInstance<T>> extends PageDataOptions<T> {
|
|
121
|
+
instance?: M;
|
|
122
122
|
children: React.ReactNode;
|
|
123
123
|
/**请求之前处理参数*/
|
|
124
|
-
onBefore?:
|
|
124
|
+
onBefore?: M['onBefore'];
|
|
125
125
|
/**请求接口*/
|
|
126
|
-
getList?:
|
|
126
|
+
getList?: M['getList'];
|
|
127
127
|
/**请求之后处理返回值进行存储*/
|
|
128
|
-
onAfter?:
|
|
128
|
+
onAfter?: M['onAfter'];
|
|
129
129
|
/** 额外数据处理*/
|
|
130
|
-
onExtraData?:
|
|
130
|
+
onExtraData?: M['onExtraData'];
|
|
131
131
|
/** code!== 200 时 触发*/
|
|
132
|
-
onError?:
|
|
132
|
+
onError?: M['onError'];
|
|
133
133
|
/**获取弹框内重置参数*/
|
|
134
|
-
getResetValues?:
|
|
134
|
+
getResetValues?: M['getResetValues'];
|
|
135
135
|
/**默认查询参数*/
|
|
136
|
-
defaultQuery?:
|
|
136
|
+
defaultQuery?: M['defaultQuery'];
|
|
137
137
|
/**那些字段取值对象 code值*/
|
|
138
|
-
codeFields?:
|
|
138
|
+
codeFields?: M['codeFields'];
|
|
139
139
|
/**那些字段取值对象的 value 值 */
|
|
140
|
-
valueFields?:
|
|
140
|
+
valueFields?: M['valueFields'];
|
|
141
141
|
/**是否是第一次加载*/
|
|
142
142
|
isMountLoad?: boolean;
|
|
143
143
|
/**页面标题*/
|
|
144
144
|
title?: string;
|
|
145
145
|
}
|
|
146
146
|
/**页面级数据状态管理上下文提供者*/
|
|
147
|
-
export declare function PageDataInstanceContextProvider<T extends PageDataInstanceState = PageDataInstanceState>(props: PageDataInstanceContextProviderProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
147
|
+
export declare function PageDataInstanceContextProvider<T extends PageDataInstanceState = PageDataInstanceState, M extends PageDataInstance<T> = PageDataInstance<T>>(props: PageDataInstanceContextProviderProps<T, M>): import("react/jsx-runtime").JSX.Element;
|
|
148
148
|
/**
|
|
149
149
|
* 页面级数据状态管理
|
|
150
150
|
*/
|
|
151
|
-
export declare const usePageDataInstanceState: <T extends PageDataInstanceState = PageDataInstanceState>() => [T,
|
|
151
|
+
export declare const usePageDataInstanceState: <T extends PageDataInstanceState = PageDataInstanceState, M extends PageDataInstance<T> = PageDataInstance<T>>() => [T, M, string | undefined];
|
|
@@ -311,13 +311,13 @@ function PageDataInstanceContextProvider(props) {
|
|
|
311
311
|
});
|
|
312
312
|
}
|
|
313
313
|
const usePageDataInstanceState = ()=>{
|
|
314
|
-
const
|
|
315
|
-
const store = useSnapshot(
|
|
314
|
+
const pageMainDataInstance = usePageDataInstanceContext();
|
|
315
|
+
const store = useSnapshot(pageMainDataInstance.store, {
|
|
316
316
|
sync: true
|
|
317
317
|
});
|
|
318
318
|
return [
|
|
319
319
|
store,
|
|
320
|
-
|
|
320
|
+
pageMainDataInstance,
|
|
321
321
|
store.__defaultValue
|
|
322
322
|
];
|
|
323
323
|
};
|
|
@@ -59,35 +59,35 @@ export declare class PageInfoDataInstance<T extends PageInfoDataInstanceState =
|
|
|
59
59
|
/**保存数据*/
|
|
60
60
|
main_saveInfo: () => Promise<void>;
|
|
61
61
|
}
|
|
62
|
-
export interface PageInfoDataOptions<T extends PageInfoDataInstanceState = PageInfoDataInstanceState> {
|
|
62
|
+
export interface PageInfoDataOptions<T extends PageInfoDataInstanceState = PageInfoDataInstanceState, M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>> {
|
|
63
63
|
/**详情查询请求配置*/
|
|
64
|
-
requestInfoConfig?:
|
|
64
|
+
requestInfoConfig?: M['requestInfoConfig'];
|
|
65
65
|
/**详情保存请求配置*/
|
|
66
|
-
requestSaveInfoConfig?:
|
|
66
|
+
requestSaveInfoConfig?: M['requestSaveInfoConfig'];
|
|
67
67
|
/**初始值*/
|
|
68
68
|
initialValues?: Partial<T>;
|
|
69
69
|
/**editFormData是否使用valtio proxy 存储*/
|
|
70
70
|
isProxy?: boolean;
|
|
71
71
|
}
|
|
72
72
|
/**初始化实例*/
|
|
73
|
-
export declare const usePageInfoDataInstance: <T extends PageInfoDataInstanceState = PageInfoDataInstanceState
|
|
73
|
+
export declare const usePageInfoDataInstance: <T extends PageInfoDataInstanceState = PageInfoDataInstanceState, M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>>(instance?: M) => M;
|
|
74
74
|
/**页面级数据状态管理上下文*/
|
|
75
75
|
export declare const PageInfoDataInstanceContext: import("react").Context<PageInfoDataInstance<PageInfoDataInstanceState>>;
|
|
76
76
|
/**获取上下文实例*/
|
|
77
|
-
export declare const usePageInfoDataInstanceContext: <T extends PageInfoDataInstanceState = PageInfoDataInstanceState>() =>
|
|
78
|
-
export interface PageInfoDataInstanceContextProviderProps<T extends PageInfoDataInstanceState = PageInfoDataInstanceState> extends PageInfoDataOptions<T> {
|
|
79
|
-
instance?:
|
|
77
|
+
export declare const usePageInfoDataInstanceContext: <T extends PageInfoDataInstanceState = PageInfoDataInstanceState, M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>>() => M;
|
|
78
|
+
export interface PageInfoDataInstanceContextProviderProps<T extends PageInfoDataInstanceState = PageInfoDataInstanceState, M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>> extends PageInfoDataOptions<T, M> {
|
|
79
|
+
instance?: M;
|
|
80
80
|
children: React.ReactNode;
|
|
81
81
|
/**页面标题*/
|
|
82
82
|
title?: string;
|
|
83
83
|
/**页面一加载是否请求详情接口*/
|
|
84
84
|
isMountRequestInfo?: boolean;
|
|
85
85
|
/**自定义hooks,挂载参数和设置完初始值后执行*/
|
|
86
|
-
useHooks?: (instance:
|
|
86
|
+
useHooks?: (instance: M) => void;
|
|
87
87
|
}
|
|
88
88
|
/**页面级数据状态管理上下文提供者*/
|
|
89
|
-
export declare function PageInfoDataInstanceContextProvider<T extends PageInfoDataInstanceState = PageInfoDataInstanceState>(props: PageInfoDataInstanceContextProviderProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
89
|
+
export declare function PageInfoDataInstanceContextProvider<T extends PageInfoDataInstanceState = PageInfoDataInstanceState, M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>>(props: PageInfoDataInstanceContextProviderProps<T, M>): import("react/jsx-runtime").JSX.Element;
|
|
90
90
|
/**
|
|
91
91
|
* 页面级数据状态管理
|
|
92
92
|
*/
|
|
93
|
-
export declare const usePageInfoDataInstanceState: <T extends PageInfoDataInstanceState = PageInfoDataInstanceState>() => [T,
|
|
93
|
+
export declare const usePageInfoDataInstanceState: <T extends PageInfoDataInstanceState = PageInfoDataInstanceState, M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>>() => [T, M, string | undefined];
|
|
@@ -155,13 +155,13 @@ function PageInfoDataInstanceContextProvider(props) {
|
|
|
155
155
|
});
|
|
156
156
|
}
|
|
157
157
|
const usePageInfoDataInstanceState = ()=>{
|
|
158
|
-
const
|
|
159
|
-
const store = useSnapshot(
|
|
158
|
+
const pageInfoDataInstance = usePageInfoDataInstanceContext();
|
|
159
|
+
const store = useSnapshot(pageInfoDataInstance.store, {
|
|
160
160
|
sync: true
|
|
161
161
|
});
|
|
162
162
|
return [
|
|
163
163
|
store,
|
|
164
|
-
|
|
164
|
+
pageInfoDataInstance,
|
|
165
165
|
store.__defaultValue
|
|
166
166
|
];
|
|
167
167
|
};
|
package/esm/utils/request.js
CHANGED
|
@@ -30,7 +30,12 @@ const requestResponseHandle = (result, options)=>{
|
|
|
30
30
|
msg = codeMessage[result?.statusCode];
|
|
31
31
|
console.log(error);
|
|
32
32
|
}
|
|
33
|
-
if (msg && options?.isShowErrorMessage !== false)
|
|
33
|
+
if (msg && options?.isShowErrorMessage !== false) if (globalSettingDataInstance.store.isUseTaroToast) taro.showToast({
|
|
34
|
+
title: msg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
35
|
+
duration: 3000,
|
|
36
|
+
icon: 'none'
|
|
37
|
+
});
|
|
38
|
+
else globalDataInstance.showMessage({
|
|
34
39
|
content: msg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
35
40
|
type: 'error'
|
|
36
41
|
});
|
|
@@ -111,7 +116,12 @@ class RequestInstance {
|
|
|
111
116
|
};
|
|
112
117
|
if (token) newHeader[globalSettingDataInstance.store.headerTokenName || 'token'] = token;
|
|
113
118
|
else if (true !== isIgnoreToken) {
|
|
114
|
-
if (false !== isShowErrorMessage)
|
|
119
|
+
if (false !== isShowErrorMessage) if (globalSettingDataInstance.store.isUseTaroToast) taro.showToast({
|
|
120
|
+
title: "\u672A\u767B\u5F55",
|
|
121
|
+
duration: 3000,
|
|
122
|
+
icon: 'none'
|
|
123
|
+
});
|
|
124
|
+
else globalDataInstance.showMessage({
|
|
115
125
|
content: "\u672A\u767B\u5F55",
|
|
116
126
|
type: 'error'
|
|
117
127
|
});
|
|
@@ -144,7 +154,12 @@ class RequestInstance {
|
|
|
144
154
|
options?.success?.(result);
|
|
145
155
|
},
|
|
146
156
|
fail: (result)=>{
|
|
147
|
-
if (false !== isShowErrorMessage)
|
|
157
|
+
if (false !== isShowErrorMessage) if (globalSettingDataInstance.store.isUseTaroToast) taro.showToast({
|
|
158
|
+
title: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
159
|
+
duration: 3000,
|
|
160
|
+
icon: 'none'
|
|
161
|
+
});
|
|
162
|
+
else globalDataInstance.showMessage({
|
|
148
163
|
content: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
149
164
|
type: 'error'
|
|
150
165
|
});
|
|
@@ -233,7 +248,12 @@ class RequestInstance {
|
|
|
233
248
|
}
|
|
234
249
|
},
|
|
235
250
|
fail: (result)=>{
|
|
236
|
-
if (false !== isShowErrorMessage)
|
|
251
|
+
if (false !== isShowErrorMessage) if (globalSettingDataInstance.store.isUseTaroToast) taro.showToast({
|
|
252
|
+
title: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
253
|
+
duration: 3000,
|
|
254
|
+
icon: 'none'
|
|
255
|
+
});
|
|
256
|
+
else globalDataInstance.showMessage({
|
|
237
257
|
content: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
238
258
|
type: 'error'
|
|
239
259
|
});
|
|
@@ -279,7 +299,12 @@ class RequestInstance {
|
|
|
279
299
|
options?.success?.(result);
|
|
280
300
|
},
|
|
281
301
|
fail: (result)=>{
|
|
282
|
-
if (false !== isShowErrorMessage)
|
|
302
|
+
if (false !== isShowErrorMessage) if (globalSettingDataInstance.store.isUseTaroToast) taro.showToast({
|
|
303
|
+
title: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
304
|
+
duration: 3000,
|
|
305
|
+
icon: 'none'
|
|
306
|
+
});
|
|
307
|
+
else globalDataInstance.showMessage({
|
|
283
308
|
content: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
284
309
|
type: 'error'
|
|
285
310
|
});
|
|
@@ -39,7 +39,8 @@ class GlobalSettingDataInstance extends instance_js_namespaceObject.ProxyInstanc
|
|
|
39
39
|
loginPageRoute: 'pages/login/index',
|
|
40
40
|
ignoreAuthRoutes: [],
|
|
41
41
|
useAuthHasMenuPermission: true,
|
|
42
|
-
isEnableAuth: true
|
|
42
|
+
isEnableAuth: true,
|
|
43
|
+
isUseTaroToast: true
|
|
43
44
|
};
|
|
44
45
|
store = (0, external_valtio_namespaceObject.proxy)({
|
|
45
46
|
...this.defaultStore
|
|
@@ -112,40 +112,40 @@ export interface PageDataOptions<T extends PageDataInstanceState = PageDataInsta
|
|
|
112
112
|
defaultPageSize?: number;
|
|
113
113
|
}
|
|
114
114
|
/**初始化实例*/
|
|
115
|
-
export declare function usePageDataInstance<T extends PageDataInstanceState = PageDataInstanceState
|
|
115
|
+
export declare function usePageDataInstance<T extends PageDataInstanceState = PageDataInstanceState, M extends PageDataInstance<T> = PageDataInstance<T>>(instance?: M): M;
|
|
116
116
|
/**页面级数据状态管理上下文*/
|
|
117
117
|
export declare const PageDataInstanceContext: import("react").Context<PageDataInstance<PageDataInstanceState>>;
|
|
118
118
|
/**获取上下文实例*/
|
|
119
|
-
export declare const usePageDataInstanceContext: <T extends PageDataInstanceState = PageDataInstanceState>() =>
|
|
120
|
-
export interface PageDataInstanceContextProviderProps<T extends PageDataInstanceState = PageDataInstanceState> extends PageDataOptions<T> {
|
|
121
|
-
instance?:
|
|
119
|
+
export declare const usePageDataInstanceContext: <T extends PageDataInstanceState = PageDataInstanceState, M extends PageDataInstance<T> = PageDataInstance<T>>() => M;
|
|
120
|
+
export interface PageDataInstanceContextProviderProps<T extends PageDataInstanceState = PageDataInstanceState, M extends PageDataInstance<T> = PageDataInstance<T>> extends PageDataOptions<T> {
|
|
121
|
+
instance?: M;
|
|
122
122
|
children: React.ReactNode;
|
|
123
123
|
/**请求之前处理参数*/
|
|
124
|
-
onBefore?:
|
|
124
|
+
onBefore?: M['onBefore'];
|
|
125
125
|
/**请求接口*/
|
|
126
|
-
getList?:
|
|
126
|
+
getList?: M['getList'];
|
|
127
127
|
/**请求之后处理返回值进行存储*/
|
|
128
|
-
onAfter?:
|
|
128
|
+
onAfter?: M['onAfter'];
|
|
129
129
|
/** 额外数据处理*/
|
|
130
|
-
onExtraData?:
|
|
130
|
+
onExtraData?: M['onExtraData'];
|
|
131
131
|
/** code!== 200 时 触发*/
|
|
132
|
-
onError?:
|
|
132
|
+
onError?: M['onError'];
|
|
133
133
|
/**获取弹框内重置参数*/
|
|
134
|
-
getResetValues?:
|
|
134
|
+
getResetValues?: M['getResetValues'];
|
|
135
135
|
/**默认查询参数*/
|
|
136
|
-
defaultQuery?:
|
|
136
|
+
defaultQuery?: M['defaultQuery'];
|
|
137
137
|
/**那些字段取值对象 code值*/
|
|
138
|
-
codeFields?:
|
|
138
|
+
codeFields?: M['codeFields'];
|
|
139
139
|
/**那些字段取值对象的 value 值 */
|
|
140
|
-
valueFields?:
|
|
140
|
+
valueFields?: M['valueFields'];
|
|
141
141
|
/**是否是第一次加载*/
|
|
142
142
|
isMountLoad?: boolean;
|
|
143
143
|
/**页面标题*/
|
|
144
144
|
title?: string;
|
|
145
145
|
}
|
|
146
146
|
/**页面级数据状态管理上下文提供者*/
|
|
147
|
-
export declare function PageDataInstanceContextProvider<T extends PageDataInstanceState = PageDataInstanceState>(props: PageDataInstanceContextProviderProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
147
|
+
export declare function PageDataInstanceContextProvider<T extends PageDataInstanceState = PageDataInstanceState, M extends PageDataInstance<T> = PageDataInstance<T>>(props: PageDataInstanceContextProviderProps<T, M>): import("react/jsx-runtime").JSX.Element;
|
|
148
148
|
/**
|
|
149
149
|
* 页面级数据状态管理
|
|
150
150
|
*/
|
|
151
|
-
export declare const usePageDataInstanceState: <T extends PageDataInstanceState = PageDataInstanceState>() => [T,
|
|
151
|
+
export declare const usePageDataInstanceState: <T extends PageDataInstanceState = PageDataInstanceState, M extends PageDataInstance<T> = PageDataInstance<T>>() => [T, M, string | undefined];
|
|
@@ -354,13 +354,13 @@ function PageDataInstanceContextProvider(props) {
|
|
|
354
354
|
});
|
|
355
355
|
}
|
|
356
356
|
const usePageDataInstanceState = ()=>{
|
|
357
|
-
const
|
|
358
|
-
const store = (0, external_valtio_namespaceObject.useSnapshot)(
|
|
357
|
+
const pageMainDataInstance = usePageDataInstanceContext();
|
|
358
|
+
const store = (0, external_valtio_namespaceObject.useSnapshot)(pageMainDataInstance.store, {
|
|
359
359
|
sync: true
|
|
360
360
|
});
|
|
361
361
|
return [
|
|
362
362
|
store,
|
|
363
|
-
|
|
363
|
+
pageMainDataInstance,
|
|
364
364
|
store.__defaultValue
|
|
365
365
|
];
|
|
366
366
|
};
|
|
@@ -59,35 +59,35 @@ export declare class PageInfoDataInstance<T extends PageInfoDataInstanceState =
|
|
|
59
59
|
/**保存数据*/
|
|
60
60
|
main_saveInfo: () => Promise<void>;
|
|
61
61
|
}
|
|
62
|
-
export interface PageInfoDataOptions<T extends PageInfoDataInstanceState = PageInfoDataInstanceState> {
|
|
62
|
+
export interface PageInfoDataOptions<T extends PageInfoDataInstanceState = PageInfoDataInstanceState, M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>> {
|
|
63
63
|
/**详情查询请求配置*/
|
|
64
|
-
requestInfoConfig?:
|
|
64
|
+
requestInfoConfig?: M['requestInfoConfig'];
|
|
65
65
|
/**详情保存请求配置*/
|
|
66
|
-
requestSaveInfoConfig?:
|
|
66
|
+
requestSaveInfoConfig?: M['requestSaveInfoConfig'];
|
|
67
67
|
/**初始值*/
|
|
68
68
|
initialValues?: Partial<T>;
|
|
69
69
|
/**editFormData是否使用valtio proxy 存储*/
|
|
70
70
|
isProxy?: boolean;
|
|
71
71
|
}
|
|
72
72
|
/**初始化实例*/
|
|
73
|
-
export declare const usePageInfoDataInstance: <T extends PageInfoDataInstanceState = PageInfoDataInstanceState
|
|
73
|
+
export declare const usePageInfoDataInstance: <T extends PageInfoDataInstanceState = PageInfoDataInstanceState, M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>>(instance?: M) => M;
|
|
74
74
|
/**页面级数据状态管理上下文*/
|
|
75
75
|
export declare const PageInfoDataInstanceContext: import("react").Context<PageInfoDataInstance<PageInfoDataInstanceState>>;
|
|
76
76
|
/**获取上下文实例*/
|
|
77
|
-
export declare const usePageInfoDataInstanceContext: <T extends PageInfoDataInstanceState = PageInfoDataInstanceState>() =>
|
|
78
|
-
export interface PageInfoDataInstanceContextProviderProps<T extends PageInfoDataInstanceState = PageInfoDataInstanceState> extends PageInfoDataOptions<T> {
|
|
79
|
-
instance?:
|
|
77
|
+
export declare const usePageInfoDataInstanceContext: <T extends PageInfoDataInstanceState = PageInfoDataInstanceState, M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>>() => M;
|
|
78
|
+
export interface PageInfoDataInstanceContextProviderProps<T extends PageInfoDataInstanceState = PageInfoDataInstanceState, M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>> extends PageInfoDataOptions<T, M> {
|
|
79
|
+
instance?: M;
|
|
80
80
|
children: React.ReactNode;
|
|
81
81
|
/**页面标题*/
|
|
82
82
|
title?: string;
|
|
83
83
|
/**页面一加载是否请求详情接口*/
|
|
84
84
|
isMountRequestInfo?: boolean;
|
|
85
85
|
/**自定义hooks,挂载参数和设置完初始值后执行*/
|
|
86
|
-
useHooks?: (instance:
|
|
86
|
+
useHooks?: (instance: M) => void;
|
|
87
87
|
}
|
|
88
88
|
/**页面级数据状态管理上下文提供者*/
|
|
89
|
-
export declare function PageInfoDataInstanceContextProvider<T extends PageInfoDataInstanceState = PageInfoDataInstanceState>(props: PageInfoDataInstanceContextProviderProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
89
|
+
export declare function PageInfoDataInstanceContextProvider<T extends PageInfoDataInstanceState = PageInfoDataInstanceState, M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>>(props: PageInfoDataInstanceContextProviderProps<T, M>): import("react/jsx-runtime").JSX.Element;
|
|
90
90
|
/**
|
|
91
91
|
* 页面级数据状态管理
|
|
92
92
|
*/
|
|
93
|
-
export declare const usePageInfoDataInstanceState: <T extends PageInfoDataInstanceState = PageInfoDataInstanceState>() => [T,
|
|
93
|
+
export declare const usePageInfoDataInstanceState: <T extends PageInfoDataInstanceState = PageInfoDataInstanceState, M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>>() => [T, M, string | undefined];
|
|
@@ -199,13 +199,13 @@ function PageInfoDataInstanceContextProvider(props) {
|
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
201
|
const usePageInfoDataInstanceState = ()=>{
|
|
202
|
-
const
|
|
203
|
-
const store = (0, external_valtio_namespaceObject.useSnapshot)(
|
|
202
|
+
const pageInfoDataInstance = usePageInfoDataInstanceContext();
|
|
203
|
+
const store = (0, external_valtio_namespaceObject.useSnapshot)(pageInfoDataInstance.store, {
|
|
204
204
|
sync: true
|
|
205
205
|
});
|
|
206
206
|
return [
|
|
207
207
|
store,
|
|
208
|
-
|
|
208
|
+
pageInfoDataInstance,
|
|
209
209
|
store.__defaultValue
|
|
210
210
|
];
|
|
211
211
|
};
|
package/lib/utils/request.js
CHANGED
|
@@ -70,7 +70,12 @@ const requestResponseHandle = (result, options)=>{
|
|
|
70
70
|
msg = codeMessage[result?.statusCode];
|
|
71
71
|
console.log(error);
|
|
72
72
|
}
|
|
73
|
-
if (msg && options?.isShowErrorMessage !== false)
|
|
73
|
+
if (msg && options?.isShowErrorMessage !== false) if (global_setting_data_instance_js_namespaceObject.globalSettingDataInstance.store.isUseTaroToast) taro_default().showToast({
|
|
74
|
+
title: msg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
75
|
+
duration: 3000,
|
|
76
|
+
icon: 'none'
|
|
77
|
+
});
|
|
78
|
+
else global_data_instance_js_namespaceObject.globalDataInstance.showMessage({
|
|
74
79
|
content: msg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
75
80
|
type: 'error'
|
|
76
81
|
});
|
|
@@ -151,7 +156,12 @@ class RequestInstance {
|
|
|
151
156
|
};
|
|
152
157
|
if (token) newHeader[global_setting_data_instance_js_namespaceObject.globalSettingDataInstance.store.headerTokenName || 'token'] = token;
|
|
153
158
|
else if (true !== isIgnoreToken) {
|
|
154
|
-
if (false !== isShowErrorMessage)
|
|
159
|
+
if (false !== isShowErrorMessage) if (global_setting_data_instance_js_namespaceObject.globalSettingDataInstance.store.isUseTaroToast) taro_default().showToast({
|
|
160
|
+
title: "\u672A\u767B\u5F55",
|
|
161
|
+
duration: 3000,
|
|
162
|
+
icon: 'none'
|
|
163
|
+
});
|
|
164
|
+
else global_data_instance_js_namespaceObject.globalDataInstance.showMessage({
|
|
155
165
|
content: "\u672A\u767B\u5F55",
|
|
156
166
|
type: 'error'
|
|
157
167
|
});
|
|
@@ -184,7 +194,12 @@ class RequestInstance {
|
|
|
184
194
|
options?.success?.(result);
|
|
185
195
|
},
|
|
186
196
|
fail: (result)=>{
|
|
187
|
-
if (false !== isShowErrorMessage)
|
|
197
|
+
if (false !== isShowErrorMessage) if (global_setting_data_instance_js_namespaceObject.globalSettingDataInstance.store.isUseTaroToast) taro_default().showToast({
|
|
198
|
+
title: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
199
|
+
duration: 3000,
|
|
200
|
+
icon: 'none'
|
|
201
|
+
});
|
|
202
|
+
else global_data_instance_js_namespaceObject.globalDataInstance.showMessage({
|
|
188
203
|
content: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
189
204
|
type: 'error'
|
|
190
205
|
});
|
|
@@ -273,7 +288,12 @@ class RequestInstance {
|
|
|
273
288
|
}
|
|
274
289
|
},
|
|
275
290
|
fail: (result)=>{
|
|
276
|
-
if (false !== isShowErrorMessage)
|
|
291
|
+
if (false !== isShowErrorMessage) if (global_setting_data_instance_js_namespaceObject.globalSettingDataInstance.store.isUseTaroToast) taro_default().showToast({
|
|
292
|
+
title: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
293
|
+
duration: 3000,
|
|
294
|
+
icon: 'none'
|
|
295
|
+
});
|
|
296
|
+
else global_data_instance_js_namespaceObject.globalDataInstance.showMessage({
|
|
277
297
|
content: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
278
298
|
type: 'error'
|
|
279
299
|
});
|
|
@@ -319,7 +339,12 @@ class RequestInstance {
|
|
|
319
339
|
options?.success?.(result);
|
|
320
340
|
},
|
|
321
341
|
fail: (result)=>{
|
|
322
|
-
if (false !== isShowErrorMessage)
|
|
342
|
+
if (false !== isShowErrorMessage) if (global_setting_data_instance_js_namespaceObject.globalSettingDataInstance.store.isUseTaroToast) taro_default().showToast({
|
|
343
|
+
title: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
344
|
+
duration: 3000,
|
|
345
|
+
icon: 'none'
|
|
346
|
+
});
|
|
347
|
+
else global_data_instance_js_namespaceObject.globalDataInstance.showMessage({
|
|
323
348
|
content: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
324
349
|
type: 'error'
|
|
325
350
|
});
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"author": "SunLxy <1011771396@qq.com>",
|
|
4
4
|
"description": "框架组件库",
|
|
5
5
|
"homepage": "https://github.com/autumn-fairy-tales/fairys-taro-react",
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.10",
|
|
7
7
|
"main": "esm/index.js",
|
|
8
8
|
"types": "esm/index.d.ts",
|
|
9
9
|
"module": "esm/index.js",
|
|
@@ -6,6 +6,7 @@ import React from 'react';
|
|
|
6
6
|
import type { FairysTaroMessageItemProps } from 'components/Mesage';
|
|
7
7
|
import { ProxyInstanceObjectBase } from 'utils/valtio/instance';
|
|
8
8
|
import { globalSettingDataInstance } from './global.setting.data.instance';
|
|
9
|
+
import Taro from '@tarojs/taro';
|
|
9
10
|
|
|
10
11
|
export interface MessageDataType extends FairysTaroMessageItemProps {
|
|
11
12
|
/**用于唯一标识提示框(默认自动生成)*/
|
|
@@ -33,6 +33,8 @@ export interface GlobalSettingDataInstanceState {
|
|
|
33
33
|
useAuthHasMenuPermission?: boolean;
|
|
34
34
|
/**是否开启权限校验*/
|
|
35
35
|
isEnableAuth?: boolean;
|
|
36
|
+
/**是否使用Taro自带的toast提示*/
|
|
37
|
+
isUseTaroToast?: boolean;
|
|
36
38
|
/**数据默认值不使用*/
|
|
37
39
|
__defaultValue?: string;
|
|
38
40
|
}
|
|
@@ -47,6 +49,7 @@ export class GlobalSettingDataInstance extends ProxyInstanceObjectBase<GlobalSet
|
|
|
47
49
|
ignoreAuthRoutes: [],
|
|
48
50
|
useAuthHasMenuPermission: true,
|
|
49
51
|
isEnableAuth: true,
|
|
52
|
+
isUseTaroToast: true,
|
|
50
53
|
};
|
|
51
54
|
store = proxy<GlobalSettingDataInstanceState>({ ...this.defaultStore });
|
|
52
55
|
/**
|
|
@@ -373,12 +373,13 @@ export interface PageDataOptions<T extends PageDataInstanceState = PageDataInsta
|
|
|
373
373
|
}
|
|
374
374
|
|
|
375
375
|
/**初始化实例*/
|
|
376
|
-
export function usePageDataInstance<
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
376
|
+
export function usePageDataInstance<
|
|
377
|
+
T extends PageDataInstanceState = PageDataInstanceState,
|
|
378
|
+
M extends PageDataInstance<T> = PageDataInstance<T>,
|
|
379
|
+
>(instance?: M) {
|
|
380
|
+
const ref = useRef<M>();
|
|
380
381
|
if (!ref.current) {
|
|
381
|
-
ref.current = instance || new PageDataInstance<T>();
|
|
382
|
+
ref.current = instance || (new PageDataInstance<T>() as M);
|
|
382
383
|
}
|
|
383
384
|
return ref.current;
|
|
384
385
|
}
|
|
@@ -387,33 +388,38 @@ export function usePageDataInstance<T extends PageDataInstanceState = PageDataIn
|
|
|
387
388
|
export const PageDataInstanceContext = createContext<PageDataInstance>(new PageDataInstance());
|
|
388
389
|
|
|
389
390
|
/**获取上下文实例*/
|
|
390
|
-
export const usePageDataInstanceContext = <
|
|
391
|
-
|
|
391
|
+
export const usePageDataInstanceContext = <
|
|
392
|
+
T extends PageDataInstanceState = PageDataInstanceState,
|
|
393
|
+
M extends PageDataInstance<T> = PageDataInstance<T>,
|
|
394
|
+
>() => {
|
|
395
|
+
const PageDataInstance = useContext(PageDataInstanceContext) as M;
|
|
392
396
|
return PageDataInstance;
|
|
393
397
|
};
|
|
394
398
|
|
|
395
|
-
export interface PageDataInstanceContextProviderProps<
|
|
396
|
-
extends
|
|
397
|
-
|
|
399
|
+
export interface PageDataInstanceContextProviderProps<
|
|
400
|
+
T extends PageDataInstanceState = PageDataInstanceState,
|
|
401
|
+
M extends PageDataInstance<T> = PageDataInstance<T>,
|
|
402
|
+
> extends PageDataOptions<T> {
|
|
403
|
+
instance?: M;
|
|
398
404
|
children: React.ReactNode;
|
|
399
405
|
/**请求之前处理参数*/
|
|
400
|
-
onBefore?:
|
|
406
|
+
onBefore?: M['onBefore'];
|
|
401
407
|
/**请求接口*/
|
|
402
|
-
getList?:
|
|
408
|
+
getList?: M['getList'];
|
|
403
409
|
/**请求之后处理返回值进行存储*/
|
|
404
|
-
onAfter?:
|
|
410
|
+
onAfter?: M['onAfter'];
|
|
405
411
|
/** 额外数据处理*/
|
|
406
|
-
onExtraData?:
|
|
412
|
+
onExtraData?: M['onExtraData'];
|
|
407
413
|
/** code!== 200 时 触发*/
|
|
408
|
-
onError?:
|
|
414
|
+
onError?: M['onError'];
|
|
409
415
|
/**获取弹框内重置参数*/
|
|
410
|
-
getResetValues?:
|
|
416
|
+
getResetValues?: M['getResetValues'];
|
|
411
417
|
/**默认查询参数*/
|
|
412
|
-
defaultQuery?:
|
|
418
|
+
defaultQuery?: M['defaultQuery'];
|
|
413
419
|
/**那些字段取值对象 code值*/
|
|
414
|
-
codeFields?:
|
|
420
|
+
codeFields?: M['codeFields'];
|
|
415
421
|
/**那些字段取值对象的 value 值 */
|
|
416
|
-
valueFields?:
|
|
422
|
+
valueFields?: M['valueFields'];
|
|
417
423
|
/**是否是第一次加载*/
|
|
418
424
|
isMountLoad?: boolean;
|
|
419
425
|
/**页面标题*/
|
|
@@ -421,9 +427,10 @@ export interface PageDataInstanceContextProviderProps<T extends PageDataInstance
|
|
|
421
427
|
}
|
|
422
428
|
|
|
423
429
|
/**页面级数据状态管理上下文提供者*/
|
|
424
|
-
export function PageDataInstanceContextProvider<
|
|
425
|
-
|
|
426
|
-
|
|
430
|
+
export function PageDataInstanceContextProvider<
|
|
431
|
+
T extends PageDataInstanceState = PageDataInstanceState,
|
|
432
|
+
M extends PageDataInstance<T> = PageDataInstance<T>,
|
|
433
|
+
>(props: PageDataInstanceContextProviderProps<T, M>) {
|
|
427
434
|
const {
|
|
428
435
|
instance,
|
|
429
436
|
children,
|
|
@@ -481,8 +488,11 @@ export function PageDataInstanceContextProvider<T extends PageDataInstanceState
|
|
|
481
488
|
/**
|
|
482
489
|
* 页面级数据状态管理
|
|
483
490
|
*/
|
|
484
|
-
export const usePageDataInstanceState = <
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
491
|
+
export const usePageDataInstanceState = <
|
|
492
|
+
T extends PageDataInstanceState = PageDataInstanceState,
|
|
493
|
+
M extends PageDataInstance<T> = PageDataInstance<T>,
|
|
494
|
+
>() => {
|
|
495
|
+
const pageMainDataInstance = usePageDataInstanceContext<T, M>();
|
|
496
|
+
const store = useSnapshot(pageMainDataInstance.store, { sync: true }) as T;
|
|
497
|
+
return [store, pageMainDataInstance, store.__defaultValue] as [T, M, string | undefined];
|
|
488
498
|
};
|
|
@@ -176,11 +176,14 @@ export class PageInfoDataInstance<
|
|
|
176
176
|
};
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
export interface PageInfoDataOptions<
|
|
179
|
+
export interface PageInfoDataOptions<
|
|
180
|
+
T extends PageInfoDataInstanceState = PageInfoDataInstanceState,
|
|
181
|
+
M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>,
|
|
182
|
+
> {
|
|
180
183
|
/**详情查询请求配置*/
|
|
181
|
-
requestInfoConfig?:
|
|
184
|
+
requestInfoConfig?: M['requestInfoConfig'];
|
|
182
185
|
/**详情保存请求配置*/
|
|
183
|
-
requestSaveInfoConfig?:
|
|
186
|
+
requestSaveInfoConfig?: M['requestSaveInfoConfig'];
|
|
184
187
|
/**初始值*/
|
|
185
188
|
initialValues?: Partial<T>;
|
|
186
189
|
/**editFormData是否使用valtio proxy 存储*/
|
|
@@ -188,15 +191,18 @@ export interface PageInfoDataOptions<T extends PageInfoDataInstanceState = PageI
|
|
|
188
191
|
}
|
|
189
192
|
|
|
190
193
|
/**初始化实例*/
|
|
191
|
-
export const usePageInfoDataInstance = <
|
|
192
|
-
|
|
194
|
+
export const usePageInfoDataInstance = <
|
|
195
|
+
T extends PageInfoDataInstanceState = PageInfoDataInstanceState,
|
|
196
|
+
M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>,
|
|
197
|
+
>(
|
|
198
|
+
instance?: M,
|
|
193
199
|
) => {
|
|
194
|
-
const ref = useRef<
|
|
200
|
+
const ref = useRef<M>();
|
|
195
201
|
if (!ref.current) {
|
|
196
202
|
if (instance) {
|
|
197
203
|
ref.current = instance;
|
|
198
204
|
} else {
|
|
199
|
-
ref.current = new PageInfoDataInstance<T>();
|
|
205
|
+
ref.current = new PageInfoDataInstance<T>() as M;
|
|
200
206
|
}
|
|
201
207
|
}
|
|
202
208
|
return ref.current;
|
|
@@ -206,28 +212,33 @@ export const usePageInfoDataInstance = <T extends PageInfoDataInstanceState = Pa
|
|
|
206
212
|
export const PageInfoDataInstanceContext = createContext<PageInfoDataInstance>(new PageInfoDataInstance());
|
|
207
213
|
|
|
208
214
|
/**获取上下文实例*/
|
|
209
|
-
export const usePageInfoDataInstanceContext = <
|
|
210
|
-
|
|
215
|
+
export const usePageInfoDataInstanceContext = <
|
|
216
|
+
T extends PageInfoDataInstanceState = PageInfoDataInstanceState,
|
|
217
|
+
M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>,
|
|
218
|
+
>() => {
|
|
219
|
+
const PageInfoDataInstance = useContext(PageInfoDataInstanceContext) as M;
|
|
211
220
|
return PageInfoDataInstance;
|
|
212
221
|
};
|
|
213
222
|
|
|
214
223
|
export interface PageInfoDataInstanceContextProviderProps<
|
|
215
224
|
T extends PageInfoDataInstanceState = PageInfoDataInstanceState,
|
|
216
|
-
|
|
217
|
-
|
|
225
|
+
M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>,
|
|
226
|
+
> extends PageInfoDataOptions<T, M> {
|
|
227
|
+
instance?: M;
|
|
218
228
|
children: React.ReactNode;
|
|
219
229
|
/**页面标题*/
|
|
220
230
|
title?: string;
|
|
221
231
|
/**页面一加载是否请求详情接口*/
|
|
222
232
|
isMountRequestInfo?: boolean;
|
|
223
233
|
/**自定义hooks,挂载参数和设置完初始值后执行*/
|
|
224
|
-
useHooks?: (instance:
|
|
234
|
+
useHooks?: (instance: M) => void;
|
|
225
235
|
}
|
|
226
236
|
|
|
227
237
|
/**页面级数据状态管理上下文提供者*/
|
|
228
|
-
export function PageInfoDataInstanceContextProvider<
|
|
229
|
-
|
|
230
|
-
|
|
238
|
+
export function PageInfoDataInstanceContextProvider<
|
|
239
|
+
T extends PageInfoDataInstanceState = PageInfoDataInstanceState,
|
|
240
|
+
M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>,
|
|
241
|
+
>(props: PageInfoDataInstanceContextProviderProps<T, M>) {
|
|
231
242
|
const {
|
|
232
243
|
instance,
|
|
233
244
|
children,
|
|
@@ -268,8 +279,11 @@ export function PageInfoDataInstanceContextProvider<T extends PageInfoDataInstan
|
|
|
268
279
|
/**
|
|
269
280
|
* 页面级数据状态管理
|
|
270
281
|
*/
|
|
271
|
-
export const usePageInfoDataInstanceState = <
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
282
|
+
export const usePageInfoDataInstanceState = <
|
|
283
|
+
T extends PageInfoDataInstanceState = PageInfoDataInstanceState,
|
|
284
|
+
M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>,
|
|
285
|
+
>() => {
|
|
286
|
+
const pageInfoDataInstance = usePageInfoDataInstanceContext<T, M>();
|
|
287
|
+
const store = useSnapshot(pageInfoDataInstance.store, { sync: true }) as T;
|
|
288
|
+
return [store, pageInfoDataInstance, store.__defaultValue] as [T, M, string | undefined];
|
|
275
289
|
};
|
package/src/utils/request.ts
CHANGED
|
@@ -64,10 +64,18 @@ const requestResponseHandle = (
|
|
|
64
64
|
console.log(error);
|
|
65
65
|
}
|
|
66
66
|
if (msg && options?.isShowErrorMessage !== false) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
if (globalSettingDataInstance.store.isUseTaroToast) {
|
|
68
|
+
Taro.showToast({
|
|
69
|
+
title: msg || '请求发生错误',
|
|
70
|
+
duration: 3000,
|
|
71
|
+
icon: 'none',
|
|
72
|
+
});
|
|
73
|
+
} else {
|
|
74
|
+
globalDataInstance.showMessage({
|
|
75
|
+
content: msg || '请求发生错误',
|
|
76
|
+
type: 'error',
|
|
77
|
+
});
|
|
78
|
+
}
|
|
71
79
|
}
|
|
72
80
|
};
|
|
73
81
|
|
|
@@ -208,10 +216,18 @@ export class RequestInstance {
|
|
|
208
216
|
if (isIgnoreToken !== true) {
|
|
209
217
|
// 跳转登录页
|
|
210
218
|
if (isShowErrorMessage !== false) {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
219
|
+
if (globalSettingDataInstance.store.isUseTaroToast) {
|
|
220
|
+
Taro.showToast({
|
|
221
|
+
title: '未登录',
|
|
222
|
+
duration: 3000,
|
|
223
|
+
icon: 'none',
|
|
224
|
+
});
|
|
225
|
+
} else {
|
|
226
|
+
globalDataInstance.showMessage({
|
|
227
|
+
content: '未登录',
|
|
228
|
+
type: 'error',
|
|
229
|
+
});
|
|
230
|
+
}
|
|
215
231
|
}
|
|
216
232
|
options?.fail?.({ errMsg: '未登录' });
|
|
217
233
|
globalDataInstance.toLoginPage();
|
|
@@ -250,10 +266,18 @@ export class RequestInstance {
|
|
|
250
266
|
},
|
|
251
267
|
fail: (result) => {
|
|
252
268
|
if (isShowErrorMessage !== false) {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
269
|
+
if (globalSettingDataInstance.store.isUseTaroToast) {
|
|
270
|
+
Taro.showToast({
|
|
271
|
+
title: result.errMsg || '请求发生错误',
|
|
272
|
+
duration: 3000,
|
|
273
|
+
icon: 'none',
|
|
274
|
+
});
|
|
275
|
+
} else {
|
|
276
|
+
globalDataInstance.showMessage({
|
|
277
|
+
content: result.errMsg || '请求发生错误',
|
|
278
|
+
type: 'error',
|
|
279
|
+
});
|
|
280
|
+
}
|
|
257
281
|
}
|
|
258
282
|
options?.fail?.(result);
|
|
259
283
|
},
|
|
@@ -358,10 +382,18 @@ export class RequestInstance {
|
|
|
358
382
|
},
|
|
359
383
|
fail: (result) => {
|
|
360
384
|
if (isShowErrorMessage !== false) {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
385
|
+
if (globalSettingDataInstance.store.isUseTaroToast) {
|
|
386
|
+
Taro.showToast({
|
|
387
|
+
title: result.errMsg || '请求发生错误',
|
|
388
|
+
duration: 3000,
|
|
389
|
+
icon: 'none',
|
|
390
|
+
});
|
|
391
|
+
} else {
|
|
392
|
+
globalDataInstance.showMessage({
|
|
393
|
+
content: result.errMsg || '请求发生错误',
|
|
394
|
+
type: 'error',
|
|
395
|
+
});
|
|
396
|
+
}
|
|
365
397
|
}
|
|
366
398
|
options?.fail?.(result);
|
|
367
399
|
},
|
|
@@ -415,10 +447,18 @@ export class RequestInstance {
|
|
|
415
447
|
},
|
|
416
448
|
fail: (result) => {
|
|
417
449
|
if (isShowErrorMessage !== false) {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
450
|
+
if (globalSettingDataInstance.store.isUseTaroToast) {
|
|
451
|
+
Taro.showToast({
|
|
452
|
+
title: result.errMsg || '请求发生错误',
|
|
453
|
+
duration: 3000,
|
|
454
|
+
icon: 'none',
|
|
455
|
+
});
|
|
456
|
+
} else {
|
|
457
|
+
globalDataInstance.showMessage({
|
|
458
|
+
content: result.errMsg || '请求发生错误',
|
|
459
|
+
type: 'error',
|
|
460
|
+
});
|
|
461
|
+
}
|
|
422
462
|
}
|
|
423
463
|
options?.fail?.(result);
|
|
424
464
|
},
|