@fairys/taro-tools-react 1.0.15 → 1.0.17
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/components/MainPage/index.d.ts +16 -1
- package/esm/components/MainPage/index.js +29 -4
- package/esm/components/Mesage/index.js +2 -2
- package/esm/components/Toast/index.js +2 -2
- package/esm/components/connectToastMessage/index.d.ts +12 -1
- package/esm/components/connectToastMessage/index.js +3 -3
- package/esm/context/{global.data.instance.d.ts → global.message.data.instance.d.ts} +10 -7
- package/esm/context/{global.data.instance.js → global.message.data.instance.js} +6 -6
- package/esm/context/index.d.ts +1 -1
- package/esm/context/index.js +1 -1
- package/esm/context/page.data.instance.d.ts +13 -1
- package/esm/context/page.data.instance.js +24 -0
- package/esm/context/page.info.data.instance.d.ts +2 -0
- package/esm/context/page.info.data.instance.js +5 -2
- package/esm/styles/index.css +8 -0
- package/esm/utils/request.d.ts +2 -2
- package/esm/utils/request.js +8 -8
- package/lib/components/MainPage/index.d.ts +16 -1
- package/lib/components/MainPage/index.js +28 -0
- package/lib/components/Mesage/index.js +2 -2
- package/lib/components/Toast/index.js +2 -2
- package/lib/components/connectToastMessage/index.d.ts +12 -1
- package/lib/components/connectToastMessage/index.js +2 -2
- package/lib/context/{global.data.instance.d.ts → global.message.data.instance.d.ts} +10 -7
- package/lib/context/{global.data.instance.js → global.message.data.instance.js} +14 -14
- package/lib/context/index.d.ts +1 -1
- package/lib/context/index.js +5 -5
- package/lib/context/page.data.instance.d.ts +13 -1
- package/lib/context/page.data.instance.js +24 -0
- package/lib/context/page.info.data.instance.d.ts +2 -0
- package/lib/context/page.info.data.instance.js +5 -2
- package/lib/styles/index.css +8 -0
- package/lib/utils/request.d.ts +2 -2
- package/lib/utils/request.js +8 -8
- package/package.json +1 -1
- package/src/components/MainPage/index.tsx +62 -2
- package/src/components/Mesage/index.tsx +3 -3
- package/src/components/Toast/index.tsx +2 -2
- package/src/components/connectToastMessage/index.tsx +14 -3
- package/src/context/{global.data.instance.ts → global.message.data.instance.ts} +14 -13
- package/src/context/index.ts +1 -1
- package/src/context/page.data.instance.tsx +56 -2
- package/src/context/page.info.data.instance.tsx +8 -2
- package/src/utils/request.ts +10 -10
|
@@ -2,7 +2,7 @@ import { proxy, ref, useSnapshot } from 'valtio';
|
|
|
2
2
|
import { ProxyInstanceObjectBase } from 'utils/valtio/instance';
|
|
3
3
|
import { createContext, useContext, useEffect, useMemo, useRef } from 'react';
|
|
4
4
|
import navigate from '../utils/navigate';
|
|
5
|
-
import {
|
|
5
|
+
import { globalMessageDataInstance } from './global.message.data.instance';
|
|
6
6
|
import { globalSettingDataInstance } from './global.setting.data.instance';
|
|
7
7
|
import { useDidShow } from '@tarojs/taro';
|
|
8
8
|
import Taro from '@tarojs/taro';
|
|
@@ -16,6 +16,8 @@ export interface PageInfoDataInstanceState extends Record<string, any> {
|
|
|
16
16
|
editType?: 'add' | 'edit' | 'info';
|
|
17
17
|
/**查询详情是否成功*/
|
|
18
18
|
isInfoSuccess?: boolean;
|
|
19
|
+
/**下拉刷新状态*/
|
|
20
|
+
refresherStatus?: boolean;
|
|
19
21
|
/**数据默认值不使用*/
|
|
20
22
|
__defaultValue?: string;
|
|
21
23
|
}
|
|
@@ -32,6 +34,8 @@ export class PageInfoDataInstance<
|
|
|
32
34
|
editFormData: ref({}),
|
|
33
35
|
/**查询详情是否成功*/
|
|
34
36
|
isInfoSuccess: false,
|
|
37
|
+
/**下拉刷新状态*/
|
|
38
|
+
refresherStatus: false,
|
|
35
39
|
/**加载状态*/
|
|
36
40
|
loading: { pageLoading: false },
|
|
37
41
|
} as unknown as T;
|
|
@@ -104,6 +108,7 @@ export class PageInfoDataInstance<
|
|
|
104
108
|
return;
|
|
105
109
|
}
|
|
106
110
|
Taro.showLoading({ title: '加载中...' });
|
|
111
|
+
this.store.refresherStatus = true;
|
|
107
112
|
try {
|
|
108
113
|
this.updatedLoading(true);
|
|
109
114
|
let newParams = {} as any;
|
|
@@ -127,6 +132,7 @@ export class PageInfoDataInstance<
|
|
|
127
132
|
console.log(error);
|
|
128
133
|
this.updatedLoading(false);
|
|
129
134
|
}
|
|
135
|
+
this.store.refresherStatus = false;
|
|
130
136
|
Taro.hideLoading();
|
|
131
137
|
};
|
|
132
138
|
|
|
@@ -146,7 +152,7 @@ export class PageInfoDataInstance<
|
|
|
146
152
|
this.updatedLoading(false);
|
|
147
153
|
if (result && result.code === globalSettingDataInstance.store.requestSuccessCode) {
|
|
148
154
|
if (this.requestSaveInfoConfig?.isShowSuccessMessage === false) {
|
|
149
|
-
|
|
155
|
+
globalMessageDataInstance.showMessage({ content: result.message || '保存成功' });
|
|
150
156
|
} else {
|
|
151
157
|
Taro.showToast({ title: result.message || '保存成功', icon: 'none' });
|
|
152
158
|
}
|
package/src/utils/request.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Taro from '@tarojs/taro';
|
|
2
2
|
import { globalSettingDataInstance } from 'context/global.setting.data.instance';
|
|
3
|
-
import {
|
|
3
|
+
import { globalMessageDataInstance } from 'context/global.message.data.instance';
|
|
4
4
|
|
|
5
5
|
const codeMessage = {
|
|
6
6
|
400: '发出的请求错误',
|
|
@@ -53,7 +53,7 @@ const requestResponseHandle = (
|
|
|
53
53
|
// 权限问题 ,重新登录
|
|
54
54
|
msg = '请重新登录';
|
|
55
55
|
/**重新跳转登录页面*/
|
|
56
|
-
|
|
56
|
+
globalMessageDataInstance.toLoginPage();
|
|
57
57
|
} else if (![globalSettingDataInstance.store.requestSuccessCode, 200].includes(code)) {
|
|
58
58
|
// 提示内容
|
|
59
59
|
// @ts-ignore
|
|
@@ -73,7 +73,7 @@ const requestResponseHandle = (
|
|
|
73
73
|
icon: 'none',
|
|
74
74
|
});
|
|
75
75
|
} else {
|
|
76
|
-
|
|
76
|
+
globalMessageDataInstance.showMessage({
|
|
77
77
|
content: msg || '请求发生错误',
|
|
78
78
|
type: 'error',
|
|
79
79
|
});
|
|
@@ -101,8 +101,8 @@ export interface RequestInstanceCreateOptions {
|
|
|
101
101
|
dev?: string;
|
|
102
102
|
pro?: string;
|
|
103
103
|
};
|
|
104
|
-
dev: Record<string, string | { target: string; pathRewrite
|
|
105
|
-
pro: Record<string, string | { target: string; pathRewrite
|
|
104
|
+
dev: Record<string, string | { target: string; pathRewrite?: Record<string, string> }>;
|
|
105
|
+
pro: Record<string, string | { target: string; pathRewrite?: Record<string, string> }>;
|
|
106
106
|
};
|
|
107
107
|
/**启用token校验*/
|
|
108
108
|
isEnableTokenAuth?: boolean;
|
|
@@ -231,14 +231,14 @@ export class RequestInstance {
|
|
|
231
231
|
icon: 'none',
|
|
232
232
|
});
|
|
233
233
|
} else {
|
|
234
|
-
|
|
234
|
+
globalMessageDataInstance.showMessage({
|
|
235
235
|
content: '未登录',
|
|
236
236
|
type: 'error',
|
|
237
237
|
});
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
240
|
options?.fail?.({ errMsg: '未登录' });
|
|
241
|
-
|
|
241
|
+
globalMessageDataInstance.toLoginPage();
|
|
242
242
|
return undefined;
|
|
243
243
|
}
|
|
244
244
|
}
|
|
@@ -281,7 +281,7 @@ export class RequestInstance {
|
|
|
281
281
|
icon: 'none',
|
|
282
282
|
});
|
|
283
283
|
} else {
|
|
284
|
-
|
|
284
|
+
globalMessageDataInstance.showMessage({
|
|
285
285
|
content: result.errMsg || '请求发生错误',
|
|
286
286
|
type: 'error',
|
|
287
287
|
});
|
|
@@ -397,7 +397,7 @@ export class RequestInstance {
|
|
|
397
397
|
icon: 'none',
|
|
398
398
|
});
|
|
399
399
|
} else {
|
|
400
|
-
|
|
400
|
+
globalMessageDataInstance.showMessage({
|
|
401
401
|
content: result.errMsg || '请求发生错误',
|
|
402
402
|
type: 'error',
|
|
403
403
|
});
|
|
@@ -462,7 +462,7 @@ export class RequestInstance {
|
|
|
462
462
|
icon: 'none',
|
|
463
463
|
});
|
|
464
464
|
} else {
|
|
465
|
-
|
|
465
|
+
globalMessageDataInstance.showMessage({
|
|
466
466
|
content: result.errMsg || '请求发生错误',
|
|
467
467
|
type: 'error',
|
|
468
468
|
});
|