@fairys/taro-tools-react 1.0.16 → 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.
@@ -1,6 +1,9 @@
1
- import { ViewProps } from '@tarojs/components';
1
+ import { ViewProps, ScrollViewProps } from '@tarojs/components';
2
2
  export interface FairysTaroMainPageProps extends ViewProps {
3
3
  }
4
+ /**
5
+ * 主页面(如果外部使用scroll-view组件,需要设置高度,否则内容会出现滚动)
6
+ */
4
7
  export declare const FairysTaroMainPage: (props: FairysTaroMainPageProps) => import("react/jsx-runtime").JSX.Element;
5
8
  /**查询*/
6
9
  export declare const FairysTaroMainPageSearch: (props: FairysTaroMainPageProps) => import("react/jsx-runtime").JSX.Element;
@@ -8,3 +11,15 @@ export declare const FairysTaroMainPageSearch: (props: FairysTaroMainPageProps)
8
11
  export declare const FairysTaroMainPageBody: (props: FairysTaroMainPageProps) => import("react/jsx-runtime").JSX.Element;
9
12
  /**底部*/
10
13
  export declare const FairysTaroMainPageFooter: (props: FairysTaroMainPageProps) => import("react/jsx-runtime").JSX.Element;
14
+ export interface FairysTaroMainPageScrollViewProps extends ScrollViewProps {
15
+ /**下拉刷新状态*/
16
+ refresherStatus?: boolean;
17
+ /**是否还有更多数据*/
18
+ hasMore?: boolean;
19
+ /**加载更多文本*/
20
+ loadMoreText?: React.ReactNode;
21
+ }
22
+ /**
23
+ * 主页面滚动视图
24
+ */
25
+ export declare const FairysTaroMainPageScrollView: (props: FairysTaroMainPageScrollViewProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,7 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { View } from "@tarojs/components";
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { ScrollView, View } from "@tarojs/components";
3
3
  import clsx from "clsx";
4
- import { useMemo } from "react";
4
+ import { Fragment, useMemo } from "react";
5
5
  const FairysTaroMainPage = (props)=>{
6
6
  const { className: itemClassName, children, ...rest } = props;
7
7
  const cls = useMemo(()=>clsx('fairys_taro-ui-main-page fairystaro__box-border fairystaro__w-full fairystaro__h-full fairystaro__flex fairystaro__flex-col fairystaro__overflow-auto', itemClassName), [
@@ -46,4 +46,29 @@ const FairysTaroMainPageFooter = (props)=>{
46
46
  children: children
47
47
  });
48
48
  };
49
- export { FairysTaroMainPage, FairysTaroMainPageBody, FairysTaroMainPageFooter, FairysTaroMainPageSearch };
49
+ const FairysTaroMainPageScrollView = (props)=>{
50
+ const { className: itemClassName, children, refresherStatus, hasMore = true, loadMoreText, onScrollToLower, ...rest } = props;
51
+ const cls = useMemo(()=>clsx('fairys_taro-ui-main-page-scroll-view fairystaro__box-border fairystaro__w-screen fairystaro__h-screen', itemClassName), [
52
+ itemClassName
53
+ ]);
54
+ return /*#__PURE__*/ jsxs(ScrollView, {
55
+ scrollY: true,
56
+ refresherEnabled: true,
57
+ enhanced: true,
58
+ usingSticky: true,
59
+ refresherTriggered: refresherStatus,
60
+ className: cls,
61
+ ...rest,
62
+ onScrollToLower: (...args)=>{
63
+ if (hasMore) onScrollToLower?.(...args);
64
+ },
65
+ children: [
66
+ children,
67
+ loadMoreText ? /*#__PURE__*/ jsx(View, {
68
+ className: "fairys_taro-ui-main-page-scroll-view-load-more",
69
+ children: loadMoreText
70
+ }) : /*#__PURE__*/ jsx(Fragment, {})
71
+ ]
72
+ });
73
+ };
74
+ export { FairysTaroMainPage, FairysTaroMainPageBody, FairysTaroMainPageFooter, FairysTaroMainPageScrollView, FairysTaroMainPageSearch };
@@ -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
- /**更新页面级的 loadMore */
95
+ /**
96
+ * 更新加载状态对象
97
+ *
98
+ * @param value - 包含页面键和对应加载状态的键值对对象
99
+ */
88
100
  updatedLoading: (value: Record<string, boolean>) => void;
89
101
  /**内置——查询列表*/
90
102
  main_getList: () => Promise<void>;
@@ -30,6 +30,10 @@ class page_data_instance_PageDataInstance extends ProxyInstanceObjectBase {
30
30
  loading: {
31
31
  pageLoading: false
32
32
  },
33
+ tabRefresherStatus: {},
34
+ refresherStatus: false,
35
+ loadMoreStatus: false,
36
+ tabLoadMoreStatus: {},
33
37
  hasLastPage: false
34
38
  };
35
39
  store = proxy({
@@ -126,6 +130,16 @@ class page_data_instance_PageDataInstance extends ProxyInstanceObjectBase {
126
130
  page: this.store[pageField] || 1,
127
131
  pageSize: this.store[pageSizeField] || this.store.defaultPageSize || 20
128
132
  };
133
+ if (1 === payload.page) if (this.store.isTabs) {
134
+ const tabKey = this.store.tabKey;
135
+ if (!this.store.tabRefresherStatus) this.store.tabRefresherStatus = {};
136
+ this.store.tabRefresherStatus[tabKey] = true;
137
+ } else this.store.refresherStatus = true;
138
+ else if (this.store.isTabs) {
139
+ const tabKey = this.store.tabKey;
140
+ if (!this.store.tabLoadMoreStatus) this.store.tabLoadMoreStatus = {};
141
+ this.store.tabLoadMoreStatus[tabKey] = true;
142
+ } else this.store.loadMoreStatus = true;
129
143
  let newParams = this.formateParams({
130
144
  ...payload
131
145
  });
@@ -167,6 +181,16 @@ class page_data_instance_PageDataInstance extends ProxyInstanceObjectBase {
167
181
  this.store.loading.loadMore = false;
168
182
  this.updatedPageLoading(false);
169
183
  }
184
+ if (this.store.isTabs) {
185
+ const tabKey = this.store.tabKey;
186
+ if (!this.store.tabRefresherStatus) this.store.tabRefresherStatus = {};
187
+ if (!this.store.tabLoadMoreStatus) this.store.tabLoadMoreStatus = {};
188
+ this.store.tabLoadMoreStatus[tabKey] = false;
189
+ this.store.tabRefresherStatus[tabKey] = false;
190
+ } else {
191
+ this.store.refresherStatus = false;
192
+ this.store.loadMoreStatus = false;
193
+ }
170
194
  taro.hideLoading();
171
195
  };
172
196
  main_onPageChange = (page)=>{
@@ -8,6 +8,8 @@ export interface PageInfoDataInstanceState extends Record<string, any> {
8
8
  editType?: 'add' | 'edit' | 'info';
9
9
  /**查询详情是否成功*/
10
10
  isInfoSuccess?: boolean;
11
+ /**下拉刷新状态*/
12
+ refresherStatus?: boolean;
11
13
  /**数据默认值不使用*/
12
14
  __defaultValue?: string;
13
15
  }
@@ -14,6 +14,7 @@ class page_info_data_instance_PageInfoDataInstance extends ProxyInstanceObjectBa
14
14
  editType: 'add',
15
15
  editFormData: external_valtio_ref({}),
16
16
  isInfoSuccess: false,
17
+ refresherStatus: false,
17
18
  loading: {
18
19
  pageLoading: false
19
20
  }
@@ -56,6 +57,7 @@ class page_info_data_instance_PageInfoDataInstance extends ProxyInstanceObjectBa
56
57
  taro.showLoading({
57
58
  title: "\u52A0\u8F7D\u4E2D..."
58
59
  });
60
+ this.store.refresherStatus = true;
59
61
  try {
60
62
  this.updatedLoading(true);
61
63
  let newParams = {};
@@ -78,6 +80,7 @@ class page_info_data_instance_PageInfoDataInstance extends ProxyInstanceObjectBa
78
80
  console.log(error);
79
81
  this.updatedLoading(false);
80
82
  }
83
+ this.store.refresherStatus = false;
81
84
  taro.hideLoading();
82
85
  };
83
86
  main_saveInfo = async ()=>{
@@ -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
  }
@@ -41,11 +41,11 @@ export interface RequestInstanceCreateOptions {
41
41
  };
42
42
  dev: Record<string, string | {
43
43
  target: string;
44
- pathRewrite: Record<string, string>;
44
+ pathRewrite?: Record<string, string>;
45
45
  }>;
46
46
  pro: Record<string, string | {
47
47
  target: string;
48
- pathRewrite: Record<string, string>;
48
+ pathRewrite?: Record<string, string>;
49
49
  }>;
50
50
  };
51
51
  /**启用token校验*/
@@ -1,6 +1,9 @@
1
- import { ViewProps } from '@tarojs/components';
1
+ import { ViewProps, ScrollViewProps } from '@tarojs/components';
2
2
  export interface FairysTaroMainPageProps extends ViewProps {
3
3
  }
4
+ /**
5
+ * 主页面(如果外部使用scroll-view组件,需要设置高度,否则内容会出现滚动)
6
+ */
4
7
  export declare const FairysTaroMainPage: (props: FairysTaroMainPageProps) => import("react/jsx-runtime").JSX.Element;
5
8
  /**查询*/
6
9
  export declare const FairysTaroMainPageSearch: (props: FairysTaroMainPageProps) => import("react/jsx-runtime").JSX.Element;
@@ -8,3 +11,15 @@ export declare const FairysTaroMainPageSearch: (props: FairysTaroMainPageProps)
8
11
  export declare const FairysTaroMainPageBody: (props: FairysTaroMainPageProps) => import("react/jsx-runtime").JSX.Element;
9
12
  /**底部*/
10
13
  export declare const FairysTaroMainPageFooter: (props: FairysTaroMainPageProps) => import("react/jsx-runtime").JSX.Element;
14
+ export interface FairysTaroMainPageScrollViewProps extends ScrollViewProps {
15
+ /**下拉刷新状态*/
16
+ refresherStatus?: boolean;
17
+ /**是否还有更多数据*/
18
+ hasMore?: boolean;
19
+ /**加载更多文本*/
20
+ loadMoreText?: React.ReactNode;
21
+ }
22
+ /**
23
+ * 主页面滚动视图
24
+ */
25
+ export declare const FairysTaroMainPageScrollView: (props: FairysTaroMainPageScrollViewProps) => import("react/jsx-runtime").JSX.Element;
@@ -34,6 +34,7 @@ var __webpack_exports__ = {};
34
34
  __webpack_require__.r(__webpack_exports__);
35
35
  __webpack_require__.d(__webpack_exports__, {
36
36
  FairysTaroMainPageFooter: ()=>FairysTaroMainPageFooter,
37
+ FairysTaroMainPageScrollView: ()=>FairysTaroMainPageScrollView,
37
38
  FairysTaroMainPage: ()=>FairysTaroMainPage,
38
39
  FairysTaroMainPageSearch: ()=>FairysTaroMainPageSearch,
39
40
  FairysTaroMainPageBody: ()=>FairysTaroMainPageBody
@@ -87,14 +88,41 @@ const FairysTaroMainPageFooter = (props)=>{
87
88
  children: children
88
89
  });
89
90
  };
91
+ const FairysTaroMainPageScrollView = (props)=>{
92
+ const { className: itemClassName, children, refresherStatus, hasMore = true, loadMoreText, onScrollToLower, ...rest } = props;
93
+ const cls = (0, external_react_namespaceObject.useMemo)(()=>external_clsx_default()('fairys_taro-ui-main-page-scroll-view fairystaro__box-border fairystaro__w-screen fairystaro__h-screen', itemClassName), [
94
+ itemClassName
95
+ ]);
96
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(components_namespaceObject.ScrollView, {
97
+ scrollY: true,
98
+ refresherEnabled: true,
99
+ enhanced: true,
100
+ usingSticky: true,
101
+ refresherTriggered: refresherStatus,
102
+ className: cls,
103
+ ...rest,
104
+ onScrollToLower: (...args)=>{
105
+ if (hasMore) onScrollToLower?.(...args);
106
+ },
107
+ children: [
108
+ children,
109
+ loadMoreText ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(components_namespaceObject.View, {
110
+ className: "fairys_taro-ui-main-page-scroll-view-load-more",
111
+ children: loadMoreText
112
+ }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_namespaceObject.Fragment, {})
113
+ ]
114
+ });
115
+ };
90
116
  exports.FairysTaroMainPage = __webpack_exports__.FairysTaroMainPage;
91
117
  exports.FairysTaroMainPageBody = __webpack_exports__.FairysTaroMainPageBody;
92
118
  exports.FairysTaroMainPageFooter = __webpack_exports__.FairysTaroMainPageFooter;
119
+ exports.FairysTaroMainPageScrollView = __webpack_exports__.FairysTaroMainPageScrollView;
93
120
  exports.FairysTaroMainPageSearch = __webpack_exports__.FairysTaroMainPageSearch;
94
121
  for(var __webpack_i__ in __webpack_exports__)if (-1 === [
95
122
  "FairysTaroMainPage",
96
123
  "FairysTaroMainPageBody",
97
124
  "FairysTaroMainPageFooter",
125
+ "FairysTaroMainPageScrollView",
98
126
  "FairysTaroMainPageSearch"
99
127
  ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
100
128
  Object.defineProperty(exports, '__esModule', {
@@ -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
- /**更新页面级的 loadMore */
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)=>{
@@ -8,6 +8,8 @@ export interface PageInfoDataInstanceState extends Record<string, any> {
8
8
  editType?: 'add' | 'edit' | 'info';
9
9
  /**查询详情是否成功*/
10
10
  isInfoSuccess?: boolean;
11
+ /**下拉刷新状态*/
12
+ refresherStatus?: boolean;
11
13
  /**数据默认值不使用*/
12
14
  __defaultValue?: string;
13
15
  }
@@ -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 ()=>{
@@ -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
  }
@@ -41,11 +41,11 @@ export interface RequestInstanceCreateOptions {
41
41
  };
42
42
  dev: Record<string, string | {
43
43
  target: string;
44
- pathRewrite: Record<string, string>;
44
+ pathRewrite?: Record<string, string>;
45
45
  }>;
46
46
  pro: Record<string, string | {
47
47
  target: string;
48
- pathRewrite: Record<string, string>;
48
+ pathRewrite?: Record<string, string>;
49
49
  }>;
50
50
  };
51
51
  /**启用token校验*/
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.16",
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
+ };
@@ -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
- /**更新页面级的 loadMore */
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
  /**内置——翻页*/
@@ -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
 
@@ -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: Record<string, string> }>;
105
- pro: Record<string, string | { target: string; pathRewrite: Record<string, string> }>;
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;