@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
|
@@ -33,9 +33,9 @@ var __webpack_require__ = {};
|
|
|
33
33
|
var __webpack_exports__ = {};
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
globalMessageDataInstance: ()=>globalMessageDataInstance,
|
|
37
|
+
GlobalMessageDataInstance: ()=>GlobalMessageDataInstance,
|
|
38
|
+
useGlobalMessageData: ()=>useGlobalMessageData
|
|
39
39
|
});
|
|
40
40
|
const external_valtio_namespaceObject = require("valtio");
|
|
41
41
|
const navigate_js_namespaceObject = require("../utils/navigate.js");
|
|
@@ -43,7 +43,7 @@ var navigate_js_default = /*#__PURE__*/ __webpack_require__.n(navigate_js_namesp
|
|
|
43
43
|
const useId_js_namespaceObject = require("../utils/useId.js");
|
|
44
44
|
const instance_js_namespaceObject = require("../utils/valtio/instance.js");
|
|
45
45
|
const external_global_setting_data_instance_js_namespaceObject = require("./global.setting.data.instance.js");
|
|
46
|
-
class
|
|
46
|
+
class GlobalMessageDataInstance extends instance_js_namespaceObject.ProxyInstanceObjectBase {
|
|
47
47
|
store = (0, external_valtio_namespaceObject.proxy)({
|
|
48
48
|
messageData: (0, external_valtio_namespaceObject.ref)([]),
|
|
49
49
|
toastData: void 0
|
|
@@ -100,22 +100,22 @@ class GlobalDataInstance extends instance_js_namespaceObject.ProxyInstanceObject
|
|
|
100
100
|
});
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
const store = (0, external_valtio_namespaceObject.useSnapshot)(
|
|
103
|
+
const globalMessageDataInstance = new GlobalMessageDataInstance();
|
|
104
|
+
const useGlobalMessageData = ()=>{
|
|
105
|
+
const store = (0, external_valtio_namespaceObject.useSnapshot)(globalMessageDataInstance.store);
|
|
106
106
|
return [
|
|
107
107
|
store,
|
|
108
|
-
|
|
108
|
+
globalMessageDataInstance,
|
|
109
109
|
store.__defaultValue
|
|
110
110
|
];
|
|
111
111
|
};
|
|
112
|
-
exports.
|
|
113
|
-
exports.
|
|
114
|
-
exports.
|
|
112
|
+
exports.GlobalMessageDataInstance = __webpack_exports__.GlobalMessageDataInstance;
|
|
113
|
+
exports.globalMessageDataInstance = __webpack_exports__.globalMessageDataInstance;
|
|
114
|
+
exports.useGlobalMessageData = __webpack_exports__.useGlobalMessageData;
|
|
115
115
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
116
|
-
"
|
|
117
|
-
"
|
|
118
|
-
"
|
|
116
|
+
"GlobalMessageDataInstance",
|
|
117
|
+
"globalMessageDataInstance",
|
|
118
|
+
"useGlobalMessageData"
|
|
119
119
|
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
120
120
|
Object.defineProperty(exports, '__esModule', {
|
|
121
121
|
value: true
|
package/lib/context/index.d.ts
CHANGED
package/lib/context/index.js
CHANGED
|
@@ -3,8 +3,8 @@ var __webpack_modules__ = {
|
|
|
3
3
|
"./auth.data.instance": function(module) {
|
|
4
4
|
module.exports = require("./auth.data.instance.js");
|
|
5
5
|
},
|
|
6
|
-
"./global.data.instance": function(module) {
|
|
7
|
-
module.exports = require("./global.data.instance.js");
|
|
6
|
+
"./global.message.data.instance": function(module) {
|
|
7
|
+
module.exports = require("./global.message.data.instance.js");
|
|
8
8
|
},
|
|
9
9
|
"./global.setting.data.instance": function(module) {
|
|
10
10
|
module.exports = require("./global.setting.data.instance.js");
|
|
@@ -59,10 +59,10 @@ function __webpack_require__(moduleId) {
|
|
|
59
59
|
var __webpack_exports__ = {};
|
|
60
60
|
(()=>{
|
|
61
61
|
__webpack_require__.r(__webpack_exports__);
|
|
62
|
-
var
|
|
62
|
+
var _global_message_data_instance__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./global.message.data.instance");
|
|
63
63
|
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
64
|
-
for(var __WEBPACK_IMPORT_KEY__ in
|
|
65
|
-
return
|
|
64
|
+
for(var __WEBPACK_IMPORT_KEY__ in _global_message_data_instance__WEBPACK_IMPORTED_MODULE_0__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
65
|
+
return _global_message_data_instance__WEBPACK_IMPORTED_MODULE_0__[key];
|
|
66
66
|
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
67
67
|
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
68
68
|
var _page_data_instance__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./page.data.instance");
|
|
@@ -2,6 +2,10 @@ import { ProxyInstanceObjectBase } from '../utils/valtio/instance';
|
|
|
2
2
|
export interface PageDataInstanceState extends Record<string, any> {
|
|
3
3
|
/**loading存储*/
|
|
4
4
|
loading?: Record<string, boolean>;
|
|
5
|
+
/**下拉刷新状态*/
|
|
6
|
+
refresherStatus?: boolean;
|
|
7
|
+
/**上拉加载*/
|
|
8
|
+
loadMoreStatus?: boolean;
|
|
5
9
|
/**当前页*/
|
|
6
10
|
page?: number;
|
|
7
11
|
/**分页数*/
|
|
@@ -37,6 +41,10 @@ export interface PageDataInstanceState extends Record<string, any> {
|
|
|
37
41
|
query?: Record<string, any>;
|
|
38
42
|
[s: string]: any;
|
|
39
43
|
}[];
|
|
44
|
+
/**tab多页签下拉刷新状态*/
|
|
45
|
+
tabRefresherStatus?: Record<string, boolean>;
|
|
46
|
+
/**tab多页签上拉加载状态*/
|
|
47
|
+
tabLoadMoreStatus?: Record<string, boolean>;
|
|
40
48
|
/**是否是tab多页签*/
|
|
41
49
|
isTabs?: boolean;
|
|
42
50
|
/**是否展开查询条件*/
|
|
@@ -84,7 +92,11 @@ export declare class PageDataInstance<T extends PageDataInstanceState = PageData
|
|
|
84
92
|
updatedSearch: (value?: Record<string, any>) => void;
|
|
85
93
|
/**更新页面级的 pageLoading */
|
|
86
94
|
updatedPageLoading: (loading?: boolean) => void;
|
|
87
|
-
|
|
95
|
+
/**
|
|
96
|
+
* 更新加载状态对象
|
|
97
|
+
*
|
|
98
|
+
* @param value - 包含页面键和对应加载状态的键值对对象
|
|
99
|
+
*/
|
|
88
100
|
updatedLoading: (value: Record<string, boolean>) => void;
|
|
89
101
|
/**内置——查询列表*/
|
|
90
102
|
main_getList: () => Promise<void>;
|
|
@@ -73,6 +73,10 @@ class page_data_instance_PageDataInstance extends instance_js_namespaceObject.Pr
|
|
|
73
73
|
loading: {
|
|
74
74
|
pageLoading: false
|
|
75
75
|
},
|
|
76
|
+
tabRefresherStatus: {},
|
|
77
|
+
refresherStatus: false,
|
|
78
|
+
loadMoreStatus: false,
|
|
79
|
+
tabLoadMoreStatus: {},
|
|
76
80
|
hasLastPage: false
|
|
77
81
|
};
|
|
78
82
|
store = (0, external_valtio_namespaceObject.proxy)({
|
|
@@ -169,6 +173,16 @@ class page_data_instance_PageDataInstance extends instance_js_namespaceObject.Pr
|
|
|
169
173
|
page: this.store[pageField] || 1,
|
|
170
174
|
pageSize: this.store[pageSizeField] || this.store.defaultPageSize || 20
|
|
171
175
|
};
|
|
176
|
+
if (1 === payload.page) if (this.store.isTabs) {
|
|
177
|
+
const tabKey = this.store.tabKey;
|
|
178
|
+
if (!this.store.tabRefresherStatus) this.store.tabRefresherStatus = {};
|
|
179
|
+
this.store.tabRefresherStatus[tabKey] = true;
|
|
180
|
+
} else this.store.refresherStatus = true;
|
|
181
|
+
else if (this.store.isTabs) {
|
|
182
|
+
const tabKey = this.store.tabKey;
|
|
183
|
+
if (!this.store.tabLoadMoreStatus) this.store.tabLoadMoreStatus = {};
|
|
184
|
+
this.store.tabLoadMoreStatus[tabKey] = true;
|
|
185
|
+
} else this.store.loadMoreStatus = true;
|
|
172
186
|
let newParams = this.formateParams({
|
|
173
187
|
...payload
|
|
174
188
|
});
|
|
@@ -210,6 +224,16 @@ class page_data_instance_PageDataInstance extends instance_js_namespaceObject.Pr
|
|
|
210
224
|
this.store.loading.loadMore = false;
|
|
211
225
|
this.updatedPageLoading(false);
|
|
212
226
|
}
|
|
227
|
+
if (this.store.isTabs) {
|
|
228
|
+
const tabKey = this.store.tabKey;
|
|
229
|
+
if (!this.store.tabRefresherStatus) this.store.tabRefresherStatus = {};
|
|
230
|
+
if (!this.store.tabLoadMoreStatus) this.store.tabLoadMoreStatus = {};
|
|
231
|
+
this.store.tabLoadMoreStatus[tabKey] = false;
|
|
232
|
+
this.store.tabRefresherStatus[tabKey] = false;
|
|
233
|
+
} else {
|
|
234
|
+
this.store.refresherStatus = false;
|
|
235
|
+
this.store.loadMoreStatus = false;
|
|
236
|
+
}
|
|
213
237
|
taro_default().hideLoading();
|
|
214
238
|
};
|
|
215
239
|
main_onPageChange = (page)=>{
|
|
@@ -46,7 +46,7 @@ const instance_js_namespaceObject = require("../utils/valtio/instance.js");
|
|
|
46
46
|
const external_react_namespaceObject = require("react");
|
|
47
47
|
const navigate_js_namespaceObject = require("../utils/navigate.js");
|
|
48
48
|
var navigate_js_default = /*#__PURE__*/ __webpack_require__.n(navigate_js_namespaceObject);
|
|
49
|
-
const
|
|
49
|
+
const external_global_message_data_instance_js_namespaceObject = require("./global.message.data.instance.js");
|
|
50
50
|
const external_global_setting_data_instance_js_namespaceObject = require("./global.setting.data.instance.js");
|
|
51
51
|
const taro_namespaceObject = require("@tarojs/taro");
|
|
52
52
|
var taro_default = /*#__PURE__*/ __webpack_require__.n(taro_namespaceObject);
|
|
@@ -58,6 +58,7 @@ class page_info_data_instance_PageInfoDataInstance extends instance_js_namespace
|
|
|
58
58
|
editType: 'add',
|
|
59
59
|
editFormData: (0, external_valtio_namespaceObject.ref)({}),
|
|
60
60
|
isInfoSuccess: false,
|
|
61
|
+
refresherStatus: false,
|
|
61
62
|
loading: {
|
|
62
63
|
pageLoading: false
|
|
63
64
|
}
|
|
@@ -100,6 +101,7 @@ class page_info_data_instance_PageInfoDataInstance extends instance_js_namespace
|
|
|
100
101
|
taro_default().showLoading({
|
|
101
102
|
title: "\u52A0\u8F7D\u4E2D..."
|
|
102
103
|
});
|
|
104
|
+
this.store.refresherStatus = true;
|
|
103
105
|
try {
|
|
104
106
|
this.updatedLoading(true);
|
|
105
107
|
let newParams = {};
|
|
@@ -122,6 +124,7 @@ class page_info_data_instance_PageInfoDataInstance extends instance_js_namespace
|
|
|
122
124
|
console.log(error);
|
|
123
125
|
this.updatedLoading(false);
|
|
124
126
|
}
|
|
127
|
+
this.store.refresherStatus = false;
|
|
125
128
|
taro_default().hideLoading();
|
|
126
129
|
};
|
|
127
130
|
main_saveInfo = async ()=>{
|
|
@@ -136,7 +139,7 @@ class page_info_data_instance_PageInfoDataInstance extends instance_js_namespace
|
|
|
136
139
|
taro_default().hideLoading();
|
|
137
140
|
this.updatedLoading(false);
|
|
138
141
|
if (result && result.code === external_global_setting_data_instance_js_namespaceObject.globalSettingDataInstance.store.requestSuccessCode) {
|
|
139
|
-
if (this.requestSaveInfoConfig?.isShowSuccessMessage === false)
|
|
142
|
+
if (this.requestSaveInfoConfig?.isShowSuccessMessage === false) external_global_message_data_instance_js_namespaceObject.globalMessageDataInstance.showMessage({
|
|
140
143
|
content: result.message || "\u4FDD\u5B58\u6210\u529F"
|
|
141
144
|
});
|
|
142
145
|
else taro_default().showToast({
|
package/lib/styles/index.css
CHANGED
|
@@ -83,6 +83,10 @@
|
|
|
83
83
|
height: 100%;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
.fairystaro__h-screen {
|
|
87
|
+
height: 100vh;
|
|
88
|
+
}
|
|
89
|
+
|
|
86
90
|
.fairystaro__max-h-full {
|
|
87
91
|
max-height: 100%;
|
|
88
92
|
}
|
|
@@ -95,6 +99,10 @@
|
|
|
95
99
|
width: 100%;
|
|
96
100
|
}
|
|
97
101
|
|
|
102
|
+
.fairystaro__w-screen {
|
|
103
|
+
width: 100vw;
|
|
104
|
+
}
|
|
105
|
+
|
|
98
106
|
.fairystaro__flex {
|
|
99
107
|
display: flex;
|
|
100
108
|
}
|
package/lib/utils/request.d.ts
CHANGED
|
@@ -41,11 +41,11 @@ export interface RequestInstanceCreateOptions {
|
|
|
41
41
|
};
|
|
42
42
|
dev: Record<string, string | {
|
|
43
43
|
target: string;
|
|
44
|
-
pathRewrite
|
|
44
|
+
pathRewrite?: Record<string, string>;
|
|
45
45
|
}>;
|
|
46
46
|
pro: Record<string, string | {
|
|
47
47
|
target: string;
|
|
48
|
-
pathRewrite
|
|
48
|
+
pathRewrite?: Record<string, string>;
|
|
49
49
|
}>;
|
|
50
50
|
};
|
|
51
51
|
/**启用token校验*/
|
package/lib/utils/request.js
CHANGED
|
@@ -40,7 +40,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
40
40
|
const taro_namespaceObject = require("@tarojs/taro");
|
|
41
41
|
var taro_default = /*#__PURE__*/ __webpack_require__.n(taro_namespaceObject);
|
|
42
42
|
const global_setting_data_instance_js_namespaceObject = require("../context/global.setting.data.instance.js");
|
|
43
|
-
const
|
|
43
|
+
const global_message_data_instance_js_namespaceObject = require("../context/global.message.data.instance.js");
|
|
44
44
|
const codeMessage = {
|
|
45
45
|
400: "\u53D1\u51FA\u7684\u8BF7\u6C42\u9519\u8BEF",
|
|
46
46
|
401: "\u7528\u6237\u6CA1\u6709\u6743\u9650",
|
|
@@ -61,7 +61,7 @@ const requestResponseHandle = (result, options)=>{
|
|
|
61
61
|
const code = result?.data?.code;
|
|
62
62
|
if (401 === statusCode || 401 === code || code === global_setting_data_instance_js_namespaceObject.globalSettingDataInstance.store.tokenExpiredCode) {
|
|
63
63
|
msg = "\u8BF7\u91CD\u65B0\u767B\u5F55";
|
|
64
|
-
|
|
64
|
+
global_message_data_instance_js_namespaceObject.globalMessageDataInstance.toLoginPage();
|
|
65
65
|
} else msg = [
|
|
66
66
|
global_setting_data_instance_js_namespaceObject.globalSettingDataInstance.store.requestSuccessCode,
|
|
67
67
|
200
|
|
@@ -75,7 +75,7 @@ const requestResponseHandle = (result, options)=>{
|
|
|
75
75
|
duration: 3000,
|
|
76
76
|
icon: 'none'
|
|
77
77
|
});
|
|
78
|
-
else
|
|
78
|
+
else global_message_data_instance_js_namespaceObject.globalMessageDataInstance.showMessage({
|
|
79
79
|
content: msg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
80
80
|
type: 'error'
|
|
81
81
|
});
|
|
@@ -163,14 +163,14 @@ class RequestInstance {
|
|
|
163
163
|
duration: 3000,
|
|
164
164
|
icon: 'none'
|
|
165
165
|
});
|
|
166
|
-
else
|
|
166
|
+
else global_message_data_instance_js_namespaceObject.globalMessageDataInstance.showMessage({
|
|
167
167
|
content: "\u672A\u767B\u5F55",
|
|
168
168
|
type: 'error'
|
|
169
169
|
});
|
|
170
170
|
options?.fail?.({
|
|
171
171
|
errMsg: "\u672A\u767B\u5F55"
|
|
172
172
|
});
|
|
173
|
-
|
|
173
|
+
global_message_data_instance_js_namespaceObject.globalMessageDataInstance.toLoginPage();
|
|
174
174
|
return;
|
|
175
175
|
}
|
|
176
176
|
return {
|
|
@@ -201,7 +201,7 @@ class RequestInstance {
|
|
|
201
201
|
duration: 3000,
|
|
202
202
|
icon: 'none'
|
|
203
203
|
});
|
|
204
|
-
else
|
|
204
|
+
else global_message_data_instance_js_namespaceObject.globalMessageDataInstance.showMessage({
|
|
205
205
|
content: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
206
206
|
type: 'error'
|
|
207
207
|
});
|
|
@@ -295,7 +295,7 @@ class RequestInstance {
|
|
|
295
295
|
duration: 3000,
|
|
296
296
|
icon: 'none'
|
|
297
297
|
});
|
|
298
|
-
else
|
|
298
|
+
else global_message_data_instance_js_namespaceObject.globalMessageDataInstance.showMessage({
|
|
299
299
|
content: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
300
300
|
type: 'error'
|
|
301
301
|
});
|
|
@@ -346,7 +346,7 @@ class RequestInstance {
|
|
|
346
346
|
duration: 3000,
|
|
347
347
|
icon: 'none'
|
|
348
348
|
});
|
|
349
|
-
else
|
|
349
|
+
else global_message_data_instance_js_namespaceObject.globalMessageDataInstance.showMessage({
|
|
350
350
|
content: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
351
351
|
type: 'error'
|
|
352
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.17",
|
|
7
7
|
"main": "esm/index.js",
|
|
8
8
|
"types": "esm/index.d.ts",
|
|
9
9
|
"module": "esm/index.js",
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { ViewProps, View } from '@tarojs/components';
|
|
1
|
+
import { ViewProps, View, ScrollView, ScrollViewProps } from '@tarojs/components';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import { useMemo } from 'react';
|
|
3
|
+
import { Fragment, useMemo } from 'react';
|
|
4
4
|
|
|
5
5
|
export interface FairysTaroMainPageProps extends ViewProps {}
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* 主页面(如果外部使用scroll-view组件,需要设置高度,否则内容会出现滚动)
|
|
9
|
+
*/
|
|
7
10
|
export const FairysTaroMainPage = (props: FairysTaroMainPageProps) => {
|
|
8
11
|
const { className: itemClassName, children, ...rest } = props;
|
|
9
12
|
|
|
@@ -70,3 +73,60 @@ export const FairysTaroMainPageFooter = (props: FairysTaroMainPageProps) => {
|
|
|
70
73
|
</View>
|
|
71
74
|
);
|
|
72
75
|
};
|
|
76
|
+
|
|
77
|
+
export interface FairysTaroMainPageScrollViewProps extends ScrollViewProps {
|
|
78
|
+
/**下拉刷新状态*/
|
|
79
|
+
refresherStatus?: boolean;
|
|
80
|
+
/**是否还有更多数据*/
|
|
81
|
+
hasMore?: boolean;
|
|
82
|
+
/**加载更多文本*/
|
|
83
|
+
loadMoreText?: React.ReactNode;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* 主页面滚动视图
|
|
88
|
+
*/
|
|
89
|
+
export const FairysTaroMainPageScrollView = (props: FairysTaroMainPageScrollViewProps) => {
|
|
90
|
+
const {
|
|
91
|
+
className: itemClassName,
|
|
92
|
+
children,
|
|
93
|
+
refresherStatus,
|
|
94
|
+
hasMore = true,
|
|
95
|
+
loadMoreText,
|
|
96
|
+
onScrollToLower,
|
|
97
|
+
...rest
|
|
98
|
+
} = props;
|
|
99
|
+
|
|
100
|
+
const cls = useMemo(
|
|
101
|
+
() =>
|
|
102
|
+
clsx(
|
|
103
|
+
'fairys_taro-ui-main-page-scroll-view fairystaro__box-border fairystaro__w-screen fairystaro__h-screen',
|
|
104
|
+
itemClassName,
|
|
105
|
+
),
|
|
106
|
+
[itemClassName],
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<ScrollView
|
|
111
|
+
scrollY
|
|
112
|
+
refresherEnabled
|
|
113
|
+
enhanced
|
|
114
|
+
usingSticky
|
|
115
|
+
refresherTriggered={refresherStatus}
|
|
116
|
+
className={cls}
|
|
117
|
+
{...rest}
|
|
118
|
+
onScrollToLower={(...args) => {
|
|
119
|
+
if (hasMore) {
|
|
120
|
+
onScrollToLower?.(...args);
|
|
121
|
+
}
|
|
122
|
+
}}
|
|
123
|
+
>
|
|
124
|
+
{children}
|
|
125
|
+
{loadMoreText ? (
|
|
126
|
+
<View className="fairys_taro-ui-main-page-scroll-view-load-more">{loadMoreText}</View>
|
|
127
|
+
) : (
|
|
128
|
+
<Fragment />
|
|
129
|
+
)}
|
|
130
|
+
</ScrollView>
|
|
131
|
+
);
|
|
132
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { View, ViewProps } from '@tarojs/components';
|
|
2
2
|
import { Fragment, useMemo } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { useGlobalMessageData } from 'context/global.message.data.instance';
|
|
4
4
|
import { FairysTaroPortal } from 'components/Portal';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
|
-
import type { MessageDataType } from 'context/global.data.instance';
|
|
6
|
+
import type { MessageDataType } from 'context/global.message.data.instance';
|
|
7
7
|
|
|
8
8
|
export interface FairysTaroMessageItemProps extends Omit<ViewProps, 'style'> {
|
|
9
9
|
/**
|
|
@@ -190,7 +190,7 @@ export const FairysTaroMessage = (props: FairysTaroMessageProps) => {
|
|
|
190
190
|
export const FairysTaroPortalMessage = (props: FairysTaroMessageProps) => {
|
|
191
191
|
const { className: messageClassName, ...rest } = props;
|
|
192
192
|
|
|
193
|
-
const [state] =
|
|
193
|
+
const [state] = useGlobalMessageData();
|
|
194
194
|
const messageData = state.messageData;
|
|
195
195
|
const classNames = useMemo(
|
|
196
196
|
() =>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Toast } from '@nutui/nutui-react-taro';
|
|
2
2
|
import { FairysTaroPortal } from 'components/Portal';
|
|
3
|
-
import {
|
|
3
|
+
import { useGlobalMessageData } from 'context/global.message.data.instance';
|
|
4
4
|
|
|
5
5
|
export const FairysTaroToast = () => {
|
|
6
|
-
const [state, proxyInstance] =
|
|
6
|
+
const [state, proxyInstance] = useGlobalMessageData();
|
|
7
7
|
const toastConfig = state.toastData as any;
|
|
8
8
|
|
|
9
9
|
return (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FairysTaroPortalMessage } from 'components/Mesage';
|
|
2
2
|
import { FairysTaroToast } from 'components/Toast';
|
|
3
|
-
import React, { Fragment } from 'react';
|
|
3
|
+
import React, { Fragment, memo } from 'react';
|
|
4
4
|
|
|
5
5
|
export interface ConnectToastMessageOptions {
|
|
6
6
|
/**
|
|
@@ -11,9 +11,20 @@ export interface ConnectToastMessageOptions {
|
|
|
11
11
|
isRoot?: boolean;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* 高阶组件,用于为 React 组件连接 Toast 和 Message 功能
|
|
16
|
+
*
|
|
17
|
+
* 根据不同的运行环境(H5/微信小程序)和组件层级(根页面/子页面),
|
|
18
|
+
* 决定是否渲染 Toast 和 Message 组件,以避免功能冲突和界面遮挡
|
|
19
|
+
*
|
|
20
|
+
* @param Component - 需要被包装的 React 组件
|
|
21
|
+
* @param options - 配置选项
|
|
22
|
+
* @param options.isRoot - 是否为根页面组件,默认为 false
|
|
23
|
+
* @returns 返回一个经过优化的 React 组件,根据环境条件选择性渲染 Toast 和 Message
|
|
24
|
+
*/
|
|
14
25
|
export const connectToastMessage = (Component: React.FC, options: ConnectToastMessageOptions = {}) => {
|
|
15
26
|
const { isRoot = false } = options;
|
|
16
|
-
return (props: any) => {
|
|
27
|
+
return memo((props: any) => {
|
|
17
28
|
// 在 h5 中,只有根页面才需要展示 message 组件 和 toast 组件,其他页面只是渲染组件就好
|
|
18
29
|
|
|
19
30
|
// 微信中,根目录不显示 message 组件 和 toast 组件,因为会遮挡页面内容
|
|
@@ -37,5 +48,5 @@ export const connectToastMessage = (Component: React.FC, options: ConnectToastMe
|
|
|
37
48
|
{isRoot ? <FairysTaroPortalMessage /> : <Fragment />}
|
|
38
49
|
</Fragment>
|
|
39
50
|
);
|
|
40
|
-
};
|
|
51
|
+
});
|
|
41
52
|
};
|
|
@@ -6,7 +6,6 @@ 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';
|
|
10
9
|
|
|
11
10
|
export interface MessageDataType extends FairysTaroMessageItemProps {
|
|
12
11
|
/**用于唯一标识提示框(默认自动生成)*/
|
|
@@ -24,7 +23,7 @@ export interface MessageDataType extends FairysTaroMessageItemProps {
|
|
|
24
23
|
|
|
25
24
|
export interface ToastDataType extends Partial<TaroToastProps> {}
|
|
26
25
|
|
|
27
|
-
export interface
|
|
26
|
+
export interface GlobalMessageDataInstanceState {
|
|
28
27
|
/**弹框提示框*/
|
|
29
28
|
messageData?: MessageDataType[];
|
|
30
29
|
/**提示框数据*/
|
|
@@ -32,9 +31,11 @@ export interface GlobalDataInstanceState {
|
|
|
32
31
|
/**数据默认值不使用*/
|
|
33
32
|
__defaultValue?: string;
|
|
34
33
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
/**
|
|
35
|
+
* 全局消息数据实例
|
|
36
|
+
*/
|
|
37
|
+
export class GlobalMessageDataInstance extends ProxyInstanceObjectBase<GlobalMessageDataInstanceState> {
|
|
38
|
+
store = proxy<GlobalMessageDataInstanceState>({
|
|
38
39
|
messageData: ref([]),
|
|
39
40
|
toastData: undefined,
|
|
40
41
|
});
|
|
@@ -101,18 +102,18 @@ export class GlobalDataInstance extends ProxyInstanceObjectBase<GlobalDataInstan
|
|
|
101
102
|
};
|
|
102
103
|
}
|
|
103
104
|
/**
|
|
104
|
-
*
|
|
105
|
+
* 全局消息数据实例
|
|
105
106
|
*/
|
|
106
|
-
export const
|
|
107
|
+
export const globalMessageDataInstance = new GlobalMessageDataInstance();
|
|
107
108
|
|
|
108
109
|
/**
|
|
109
|
-
*
|
|
110
|
+
* 全局消息数据状态管理
|
|
110
111
|
*/
|
|
111
|
-
export const
|
|
112
|
-
const store = useSnapshot(
|
|
113
|
-
return [store,
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
export const useGlobalMessageData = () => {
|
|
113
|
+
const store = useSnapshot(globalMessageDataInstance.store);
|
|
114
|
+
return [store, globalMessageDataInstance, store.__defaultValue] as [
|
|
115
|
+
GlobalMessageDataInstanceState,
|
|
116
|
+
GlobalMessageDataInstance,
|
|
116
117
|
string | undefined,
|
|
117
118
|
];
|
|
118
119
|
};
|
package/src/context/index.ts
CHANGED
|
@@ -7,6 +7,10 @@ import Taro, { useDidShow } from '@tarojs/taro';
|
|
|
7
7
|
export interface PageDataInstanceState extends Record<string, any> {
|
|
8
8
|
/**loading存储*/
|
|
9
9
|
loading?: Record<string, boolean>;
|
|
10
|
+
/**下拉刷新状态*/
|
|
11
|
+
refresherStatus?: boolean;
|
|
12
|
+
/**上拉加载*/
|
|
13
|
+
loadMoreStatus?: boolean;
|
|
10
14
|
/**当前页*/
|
|
11
15
|
page?: number;
|
|
12
16
|
/**分页数*/
|
|
@@ -42,6 +46,10 @@ export interface PageDataInstanceState extends Record<string, any> {
|
|
|
42
46
|
query?: Record<string, any>;
|
|
43
47
|
[s: string]: any;
|
|
44
48
|
}[];
|
|
49
|
+
/**tab多页签下拉刷新状态*/
|
|
50
|
+
tabRefresherStatus?: Record<string, boolean>;
|
|
51
|
+
/**tab多页签上拉加载状态*/
|
|
52
|
+
tabLoadMoreStatus?: Record<string, boolean>;
|
|
45
53
|
/**是否是tab多页签*/
|
|
46
54
|
isTabs?: boolean;
|
|
47
55
|
/**是否展开查询条件*/
|
|
@@ -95,6 +103,14 @@ export class PageDataInstance<
|
|
|
95
103
|
selectedRowKeys: ref([]),
|
|
96
104
|
/**加载状态*/
|
|
97
105
|
loading: { pageLoading: false },
|
|
106
|
+
/**tab多页签下拉刷新状态*/
|
|
107
|
+
tabRefresherStatus: {},
|
|
108
|
+
/**下拉刷新状态*/
|
|
109
|
+
refresherStatus: false,
|
|
110
|
+
/**上拉加载*/
|
|
111
|
+
loadMoreStatus: false,
|
|
112
|
+
/**tab多页签上拉加载状态*/
|
|
113
|
+
tabLoadMoreStatus: {},
|
|
98
114
|
/**是否最后一页*/
|
|
99
115
|
hasLastPage: false,
|
|
100
116
|
} as unknown as T;
|
|
@@ -151,7 +167,6 @@ export class PageDataInstance<
|
|
|
151
167
|
this.store.search[key] = value[key];
|
|
152
168
|
}
|
|
153
169
|
};
|
|
154
|
-
|
|
155
170
|
/**更新页面级的 pageLoading */
|
|
156
171
|
updatedPageLoading = (loading: boolean = true) => {
|
|
157
172
|
if (typeof this.store?.loading === 'object') {
|
|
@@ -160,7 +175,11 @@ export class PageDataInstance<
|
|
|
160
175
|
this.store.loading = { pageLoading: loading };
|
|
161
176
|
}
|
|
162
177
|
};
|
|
163
|
-
|
|
178
|
+
/**
|
|
179
|
+
* 更新加载状态对象
|
|
180
|
+
*
|
|
181
|
+
* @param value - 包含页面键和对应加载状态的键值对对象
|
|
182
|
+
*/
|
|
164
183
|
updatedLoading = (value: Record<string, boolean>) => {
|
|
165
184
|
if (typeof this.store?.loading === 'object') {
|
|
166
185
|
this.store.loading = { ...this.store.loading, ...value };
|
|
@@ -209,6 +228,27 @@ export class PageDataInstance<
|
|
|
209
228
|
page: this.store[pageField] || 1,
|
|
210
229
|
pageSize: this.store[pageSizeField] || this.store.defaultPageSize || 20,
|
|
211
230
|
};
|
|
231
|
+
if (payload.page === 1) {
|
|
232
|
+
if (this.store.isTabs) {
|
|
233
|
+
const tabKey = this.store.tabKey;
|
|
234
|
+
if (!this.store.tabRefresherStatus) {
|
|
235
|
+
this.store.tabRefresherStatus = {};
|
|
236
|
+
}
|
|
237
|
+
this.store.tabRefresherStatus[tabKey] = true;
|
|
238
|
+
} else {
|
|
239
|
+
this.store.refresherStatus = true;
|
|
240
|
+
}
|
|
241
|
+
} else {
|
|
242
|
+
if (this.store.isTabs) {
|
|
243
|
+
const tabKey = this.store.tabKey;
|
|
244
|
+
if (!this.store.tabLoadMoreStatus) {
|
|
245
|
+
this.store.tabLoadMoreStatus = {};
|
|
246
|
+
}
|
|
247
|
+
this.store.tabLoadMoreStatus[tabKey] = true;
|
|
248
|
+
} else {
|
|
249
|
+
this.store.loadMoreStatus = true;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
212
252
|
let newParams = this.formateParams({ ...payload }) as any;
|
|
213
253
|
if (this.onBefore) {
|
|
214
254
|
newParams = this.onBefore(payload, this.store, this);
|
|
@@ -252,6 +292,20 @@ export class PageDataInstance<
|
|
|
252
292
|
this.store.loading.loadMore = false;
|
|
253
293
|
this.updatedPageLoading(false);
|
|
254
294
|
}
|
|
295
|
+
if (this.store.isTabs) {
|
|
296
|
+
const tabKey = this.store.tabKey;
|
|
297
|
+
if (!this.store.tabRefresherStatus) {
|
|
298
|
+
this.store.tabRefresherStatus = {};
|
|
299
|
+
}
|
|
300
|
+
if (!this.store.tabLoadMoreStatus) {
|
|
301
|
+
this.store.tabLoadMoreStatus = {};
|
|
302
|
+
}
|
|
303
|
+
this.store.tabLoadMoreStatus[tabKey] = false;
|
|
304
|
+
this.store.tabRefresherStatus[tabKey] = false;
|
|
305
|
+
} else {
|
|
306
|
+
this.store.refresherStatus = false;
|
|
307
|
+
this.store.loadMoreStatus = false;
|
|
308
|
+
}
|
|
255
309
|
Taro.hideLoading();
|
|
256
310
|
};
|
|
257
311
|
/**内置——翻页*/
|