@fairys/taro-tools-react 1.0.9 → 1.0.11
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.js +3 -3
- package/esm/context/page.info.data.instance.js +3 -3
- package/esm/utils/request.d.ts +4 -0
- package/esm/utils/request.js +33 -6
- 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.js +3 -3
- package/lib/context/page.info.data.instance.js +3 -3
- package/lib/utils/request.d.ts +4 -0
- package/lib/utils/request.js +33 -6
- 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 +3 -3
- package/src/context/page.info.data.instance.tsx +3 -3
- package/src/utils/request.ts +67 -21
|
@@ -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
|
|
@@ -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
|
};
|
|
@@ -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.d.ts
CHANGED
|
@@ -46,8 +46,12 @@ export interface RequestInstanceCreateOptions {
|
|
|
46
46
|
pathRewrite: Record<string, string>;
|
|
47
47
|
}>;
|
|
48
48
|
};
|
|
49
|
+
/**启用token校验*/
|
|
50
|
+
isEnableTokenAuth?: boolean;
|
|
49
51
|
}
|
|
50
52
|
export declare class RequestInstance {
|
|
53
|
+
/**启用token校验*/
|
|
54
|
+
isEnableTokenAuth?: boolean;
|
|
51
55
|
/**请求IP地址*/
|
|
52
56
|
IP?: string | ((url: string, module?: string, env?: string) => string);
|
|
53
57
|
/**简单的代理配置*/
|
package/esm/utils/request.js
CHANGED
|
@@ -30,12 +30,18 @@ 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
|
});
|
|
37
42
|
};
|
|
38
43
|
class RequestInstance {
|
|
44
|
+
isEnableTokenAuth = true;
|
|
39
45
|
IP;
|
|
40
46
|
proxy;
|
|
41
47
|
commonOptions = {};
|
|
@@ -53,6 +59,7 @@ class RequestInstance {
|
|
|
53
59
|
...this.commonOptions,
|
|
54
60
|
...options.commonOptions
|
|
55
61
|
};
|
|
62
|
+
this.isEnableTokenAuth = options.isEnableTokenAuth || true;
|
|
56
63
|
return this;
|
|
57
64
|
};
|
|
58
65
|
getHttpPath = (url, module)=>{
|
|
@@ -110,8 +117,13 @@ class RequestInstance {
|
|
|
110
117
|
...header
|
|
111
118
|
};
|
|
112
119
|
if (token) newHeader[globalSettingDataInstance.store.headerTokenName || 'token'] = token;
|
|
113
|
-
else if (true !== isIgnoreToken) {
|
|
114
|
-
if (false !== isShowErrorMessage)
|
|
120
|
+
else if (true !== isIgnoreToken && this.isEnableTokenAuth) {
|
|
121
|
+
if (false !== isShowErrorMessage) if (globalSettingDataInstance.store.isUseTaroToast) taro.showToast({
|
|
122
|
+
title: "\u672A\u767B\u5F55",
|
|
123
|
+
duration: 3000,
|
|
124
|
+
icon: 'none'
|
|
125
|
+
});
|
|
126
|
+
else globalDataInstance.showMessage({
|
|
115
127
|
content: "\u672A\u767B\u5F55",
|
|
116
128
|
type: 'error'
|
|
117
129
|
});
|
|
@@ -144,7 +156,12 @@ class RequestInstance {
|
|
|
144
156
|
options?.success?.(result);
|
|
145
157
|
},
|
|
146
158
|
fail: (result)=>{
|
|
147
|
-
if (false !== isShowErrorMessage)
|
|
159
|
+
if (false !== isShowErrorMessage) if (globalSettingDataInstance.store.isUseTaroToast) taro.showToast({
|
|
160
|
+
title: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
161
|
+
duration: 3000,
|
|
162
|
+
icon: 'none'
|
|
163
|
+
});
|
|
164
|
+
else globalDataInstance.showMessage({
|
|
148
165
|
content: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
149
166
|
type: 'error'
|
|
150
167
|
});
|
|
@@ -233,7 +250,12 @@ class RequestInstance {
|
|
|
233
250
|
}
|
|
234
251
|
},
|
|
235
252
|
fail: (result)=>{
|
|
236
|
-
if (false !== isShowErrorMessage)
|
|
253
|
+
if (false !== isShowErrorMessage) if (globalSettingDataInstance.store.isUseTaroToast) taro.showToast({
|
|
254
|
+
title: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
255
|
+
duration: 3000,
|
|
256
|
+
icon: 'none'
|
|
257
|
+
});
|
|
258
|
+
else globalDataInstance.showMessage({
|
|
237
259
|
content: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
238
260
|
type: 'error'
|
|
239
261
|
});
|
|
@@ -279,7 +301,12 @@ class RequestInstance {
|
|
|
279
301
|
options?.success?.(result);
|
|
280
302
|
},
|
|
281
303
|
fail: (result)=>{
|
|
282
|
-
if (false !== isShowErrorMessage)
|
|
304
|
+
if (false !== isShowErrorMessage) if (globalSettingDataInstance.store.isUseTaroToast) taro.showToast({
|
|
305
|
+
title: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
306
|
+
duration: 3000,
|
|
307
|
+
icon: 'none'
|
|
308
|
+
});
|
|
309
|
+
else globalDataInstance.showMessage({
|
|
283
310
|
content: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
284
311
|
type: 'error'
|
|
285
312
|
});
|
|
@@ -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
|
|
@@ -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
|
};
|
|
@@ -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.d.ts
CHANGED
|
@@ -46,8 +46,12 @@ export interface RequestInstanceCreateOptions {
|
|
|
46
46
|
pathRewrite: Record<string, string>;
|
|
47
47
|
}>;
|
|
48
48
|
};
|
|
49
|
+
/**启用token校验*/
|
|
50
|
+
isEnableTokenAuth?: boolean;
|
|
49
51
|
}
|
|
50
52
|
export declare class RequestInstance {
|
|
53
|
+
/**启用token校验*/
|
|
54
|
+
isEnableTokenAuth?: boolean;
|
|
51
55
|
/**请求IP地址*/
|
|
52
56
|
IP?: string | ((url: string, module?: string, env?: string) => string);
|
|
53
57
|
/**简单的代理配置*/
|
package/lib/utils/request.js
CHANGED
|
@@ -70,12 +70,18 @@ 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
|
});
|
|
77
82
|
};
|
|
78
83
|
class RequestInstance {
|
|
84
|
+
isEnableTokenAuth = true;
|
|
79
85
|
IP;
|
|
80
86
|
proxy;
|
|
81
87
|
commonOptions = {};
|
|
@@ -93,6 +99,7 @@ class RequestInstance {
|
|
|
93
99
|
...this.commonOptions,
|
|
94
100
|
...options.commonOptions
|
|
95
101
|
};
|
|
102
|
+
this.isEnableTokenAuth = options.isEnableTokenAuth || true;
|
|
96
103
|
return this;
|
|
97
104
|
};
|
|
98
105
|
getHttpPath = (url, module)=>{
|
|
@@ -150,8 +157,13 @@ class RequestInstance {
|
|
|
150
157
|
...header
|
|
151
158
|
};
|
|
152
159
|
if (token) newHeader[global_setting_data_instance_js_namespaceObject.globalSettingDataInstance.store.headerTokenName || 'token'] = token;
|
|
153
|
-
else if (true !== isIgnoreToken) {
|
|
154
|
-
if (false !== isShowErrorMessage)
|
|
160
|
+
else if (true !== isIgnoreToken && this.isEnableTokenAuth) {
|
|
161
|
+
if (false !== isShowErrorMessage) if (global_setting_data_instance_js_namespaceObject.globalSettingDataInstance.store.isUseTaroToast) taro_default().showToast({
|
|
162
|
+
title: "\u672A\u767B\u5F55",
|
|
163
|
+
duration: 3000,
|
|
164
|
+
icon: 'none'
|
|
165
|
+
});
|
|
166
|
+
else global_data_instance_js_namespaceObject.globalDataInstance.showMessage({
|
|
155
167
|
content: "\u672A\u767B\u5F55",
|
|
156
168
|
type: 'error'
|
|
157
169
|
});
|
|
@@ -184,7 +196,12 @@ class RequestInstance {
|
|
|
184
196
|
options?.success?.(result);
|
|
185
197
|
},
|
|
186
198
|
fail: (result)=>{
|
|
187
|
-
if (false !== isShowErrorMessage)
|
|
199
|
+
if (false !== isShowErrorMessage) if (global_setting_data_instance_js_namespaceObject.globalSettingDataInstance.store.isUseTaroToast) taro_default().showToast({
|
|
200
|
+
title: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
201
|
+
duration: 3000,
|
|
202
|
+
icon: 'none'
|
|
203
|
+
});
|
|
204
|
+
else global_data_instance_js_namespaceObject.globalDataInstance.showMessage({
|
|
188
205
|
content: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
189
206
|
type: 'error'
|
|
190
207
|
});
|
|
@@ -273,7 +290,12 @@ class RequestInstance {
|
|
|
273
290
|
}
|
|
274
291
|
},
|
|
275
292
|
fail: (result)=>{
|
|
276
|
-
if (false !== isShowErrorMessage)
|
|
293
|
+
if (false !== isShowErrorMessage) if (global_setting_data_instance_js_namespaceObject.globalSettingDataInstance.store.isUseTaroToast) taro_default().showToast({
|
|
294
|
+
title: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
295
|
+
duration: 3000,
|
|
296
|
+
icon: 'none'
|
|
297
|
+
});
|
|
298
|
+
else global_data_instance_js_namespaceObject.globalDataInstance.showMessage({
|
|
277
299
|
content: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
278
300
|
type: 'error'
|
|
279
301
|
});
|
|
@@ -319,7 +341,12 @@ class RequestInstance {
|
|
|
319
341
|
options?.success?.(result);
|
|
320
342
|
},
|
|
321
343
|
fail: (result)=>{
|
|
322
|
-
if (false !== isShowErrorMessage)
|
|
344
|
+
if (false !== isShowErrorMessage) if (global_setting_data_instance_js_namespaceObject.globalSettingDataInstance.store.isUseTaroToast) taro_default().showToast({
|
|
345
|
+
title: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
346
|
+
duration: 3000,
|
|
347
|
+
icon: 'none'
|
|
348
|
+
});
|
|
349
|
+
else global_data_instance_js_namespaceObject.globalDataInstance.showMessage({
|
|
323
350
|
content: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
324
351
|
type: 'error'
|
|
325
352
|
});
|
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.11",
|
|
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
|
/**
|
|
@@ -492,7 +492,7 @@ export const usePageDataInstanceState = <
|
|
|
492
492
|
T extends PageDataInstanceState = PageDataInstanceState,
|
|
493
493
|
M extends PageDataInstance<T> = PageDataInstance<T>,
|
|
494
494
|
>() => {
|
|
495
|
-
const
|
|
496
|
-
const store = useSnapshot(
|
|
497
|
-
return [store,
|
|
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];
|
|
498
498
|
};
|
|
@@ -283,7 +283,7 @@ export const usePageInfoDataInstanceState = <
|
|
|
283
283
|
T extends PageInfoDataInstanceState = PageInfoDataInstanceState,
|
|
284
284
|
M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>,
|
|
285
285
|
>() => {
|
|
286
|
-
const
|
|
287
|
-
const store = useSnapshot(
|
|
288
|
-
return [store,
|
|
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];
|
|
289
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
|
|
|
@@ -94,9 +102,14 @@ export interface RequestInstanceCreateOptions {
|
|
|
94
102
|
dev: Record<string, string | { target: string; pathRewrite: Record<string, string> }>;
|
|
95
103
|
pro: Record<string, string | { target: string; pathRewrite: Record<string, string> }>;
|
|
96
104
|
};
|
|
105
|
+
/**启用token校验*/
|
|
106
|
+
isEnableTokenAuth?: boolean;
|
|
97
107
|
}
|
|
98
108
|
|
|
99
109
|
export class RequestInstance {
|
|
110
|
+
/**启用token校验*/
|
|
111
|
+
public isEnableTokenAuth?: boolean = true;
|
|
112
|
+
|
|
100
113
|
/**请求IP地址*/
|
|
101
114
|
public IP?: string | ((url: string, module?: string, env?: string) => string);
|
|
102
115
|
/**简单的代理配置*/
|
|
@@ -120,6 +133,7 @@ export class RequestInstance {
|
|
|
120
133
|
this.IP = options.IP || this.IP;
|
|
121
134
|
this.proxy = options.proxy || this.proxy;
|
|
122
135
|
this.commonOptions = { ...this.commonOptions, ...options.commonOptions };
|
|
136
|
+
this.isEnableTokenAuth = options.isEnableTokenAuth || true;
|
|
123
137
|
return this;
|
|
124
138
|
};
|
|
125
139
|
|
|
@@ -205,13 +219,21 @@ export class RequestInstance {
|
|
|
205
219
|
if (token) {
|
|
206
220
|
newHeader[globalSettingDataInstance.store.headerTokenName || 'token'] = token;
|
|
207
221
|
} else {
|
|
208
|
-
if (isIgnoreToken !== true) {
|
|
222
|
+
if (isIgnoreToken !== true && this.isEnableTokenAuth) {
|
|
209
223
|
// 跳转登录页
|
|
210
224
|
if (isShowErrorMessage !== false) {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
225
|
+
if (globalSettingDataInstance.store.isUseTaroToast) {
|
|
226
|
+
Taro.showToast({
|
|
227
|
+
title: '未登录',
|
|
228
|
+
duration: 3000,
|
|
229
|
+
icon: 'none',
|
|
230
|
+
});
|
|
231
|
+
} else {
|
|
232
|
+
globalDataInstance.showMessage({
|
|
233
|
+
content: '未登录',
|
|
234
|
+
type: 'error',
|
|
235
|
+
});
|
|
236
|
+
}
|
|
215
237
|
}
|
|
216
238
|
options?.fail?.({ errMsg: '未登录' });
|
|
217
239
|
globalDataInstance.toLoginPage();
|
|
@@ -250,10 +272,18 @@ export class RequestInstance {
|
|
|
250
272
|
},
|
|
251
273
|
fail: (result) => {
|
|
252
274
|
if (isShowErrorMessage !== false) {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
275
|
+
if (globalSettingDataInstance.store.isUseTaroToast) {
|
|
276
|
+
Taro.showToast({
|
|
277
|
+
title: result.errMsg || '请求发生错误',
|
|
278
|
+
duration: 3000,
|
|
279
|
+
icon: 'none',
|
|
280
|
+
});
|
|
281
|
+
} else {
|
|
282
|
+
globalDataInstance.showMessage({
|
|
283
|
+
content: result.errMsg || '请求发生错误',
|
|
284
|
+
type: 'error',
|
|
285
|
+
});
|
|
286
|
+
}
|
|
257
287
|
}
|
|
258
288
|
options?.fail?.(result);
|
|
259
289
|
},
|
|
@@ -358,10 +388,18 @@ export class RequestInstance {
|
|
|
358
388
|
},
|
|
359
389
|
fail: (result) => {
|
|
360
390
|
if (isShowErrorMessage !== false) {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
391
|
+
if (globalSettingDataInstance.store.isUseTaroToast) {
|
|
392
|
+
Taro.showToast({
|
|
393
|
+
title: result.errMsg || '请求发生错误',
|
|
394
|
+
duration: 3000,
|
|
395
|
+
icon: 'none',
|
|
396
|
+
});
|
|
397
|
+
} else {
|
|
398
|
+
globalDataInstance.showMessage({
|
|
399
|
+
content: result.errMsg || '请求发生错误',
|
|
400
|
+
type: 'error',
|
|
401
|
+
});
|
|
402
|
+
}
|
|
365
403
|
}
|
|
366
404
|
options?.fail?.(result);
|
|
367
405
|
},
|
|
@@ -415,10 +453,18 @@ export class RequestInstance {
|
|
|
415
453
|
},
|
|
416
454
|
fail: (result) => {
|
|
417
455
|
if (isShowErrorMessage !== false) {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
456
|
+
if (globalSettingDataInstance.store.isUseTaroToast) {
|
|
457
|
+
Taro.showToast({
|
|
458
|
+
title: result.errMsg || '请求发生错误',
|
|
459
|
+
duration: 3000,
|
|
460
|
+
icon: 'none',
|
|
461
|
+
});
|
|
462
|
+
} else {
|
|
463
|
+
globalDataInstance.showMessage({
|
|
464
|
+
content: result.errMsg || '请求发生错误',
|
|
465
|
+
type: 'error',
|
|
466
|
+
});
|
|
467
|
+
}
|
|
422
468
|
}
|
|
423
469
|
options?.fail?.(result);
|
|
424
470
|
},
|