@yh-ui/request 1.0.53 → 1.0.54
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/dist/useLoadMore.cjs +8 -11
- package/dist/useLoadMore.mjs +8 -11
- package/package.json +2 -2
package/dist/useLoadMore.cjs
CHANGED
|
@@ -38,9 +38,8 @@ function useLoadMore(service, options = {}) {
|
|
|
38
38
|
return isLoadMore && !noMore.value && !loadingMore.value;
|
|
39
39
|
});
|
|
40
40
|
const loadService = loadMoreService || service;
|
|
41
|
-
const loadData = async (isRefresh = false) => {
|
|
41
|
+
const loadData = async (requestedPage, isRefresh = false) => {
|
|
42
42
|
if (loading.value || loadingMore.value) return;
|
|
43
|
-
const requestedPage = current.value;
|
|
44
43
|
const isLoadMoreOp = !isRefresh;
|
|
45
44
|
loading.value = isLoadMoreOp ? false : true;
|
|
46
45
|
if (isRefresh) refreshing.value = true;
|
|
@@ -48,7 +47,7 @@ function useLoadMore(service, options = {}) {
|
|
|
48
47
|
error.value = void 0;
|
|
49
48
|
try {
|
|
50
49
|
const extraParams = params.value.slice(2);
|
|
51
|
-
const response = await loadService(
|
|
50
|
+
const response = await loadService(requestedPage, pageSize.value, ...extraParams);
|
|
52
51
|
const pageData = response.data;
|
|
53
52
|
if (pageData && typeof pageData === "object") {
|
|
54
53
|
const paginatedData = pageData;
|
|
@@ -56,7 +55,6 @@ function useLoadMore(service, options = {}) {
|
|
|
56
55
|
}
|
|
57
56
|
if (isRefresh) {
|
|
58
57
|
data.value = pageData;
|
|
59
|
-
current.value = requestedPage + 1;
|
|
60
58
|
} else {
|
|
61
59
|
const oldData = data.value;
|
|
62
60
|
if (Array.isArray(oldData) && Array.isArray(pageData)) {
|
|
@@ -64,8 +62,8 @@ function useLoadMore(service, options = {}) {
|
|
|
64
62
|
} else {
|
|
65
63
|
data.value = pageData;
|
|
66
64
|
}
|
|
67
|
-
current.value = requestedPage + 1;
|
|
68
65
|
}
|
|
66
|
+
current.value = requestedPage;
|
|
69
67
|
onSuccess?.(pageData, params.value);
|
|
70
68
|
} catch (err) {
|
|
71
69
|
error.value = err;
|
|
@@ -79,19 +77,18 @@ function useLoadMore(service, options = {}) {
|
|
|
79
77
|
};
|
|
80
78
|
const loadMore = async () => {
|
|
81
79
|
if (noMore.value || loadingMore.value) return;
|
|
82
|
-
await loadData(false);
|
|
80
|
+
await loadData(current.value + 1, false);
|
|
83
81
|
};
|
|
84
82
|
const reload = async () => {
|
|
85
|
-
|
|
86
|
-
await loadData(true);
|
|
83
|
+
await loadData(initialPage, true);
|
|
87
84
|
};
|
|
88
85
|
const refresh = async () => {
|
|
89
86
|
await reload();
|
|
90
87
|
};
|
|
91
88
|
const pagination = {
|
|
92
89
|
loadPage: async page => {
|
|
93
|
-
|
|
94
|
-
await loadData(true);
|
|
90
|
+
if (page < 1 || totalPages.value > 0 && page > totalPages.value) return;
|
|
91
|
+
await loadData(page, true);
|
|
95
92
|
},
|
|
96
93
|
nextPage: loadMore,
|
|
97
94
|
prevPage: async () => {
|
|
@@ -113,7 +110,7 @@ function useLoadMore(service, options = {}) {
|
|
|
113
110
|
};
|
|
114
111
|
if (!manual) {
|
|
115
112
|
(0, _vue.onMounted)(() => {
|
|
116
|
-
loadData();
|
|
113
|
+
loadData(current.value, false);
|
|
117
114
|
});
|
|
118
115
|
}
|
|
119
116
|
return {
|
package/dist/useLoadMore.mjs
CHANGED
|
@@ -32,9 +32,8 @@ export function useLoadMore(service, options = {}) {
|
|
|
32
32
|
return isLoadMore && !noMore.value && !loadingMore.value;
|
|
33
33
|
});
|
|
34
34
|
const loadService = loadMoreService || service;
|
|
35
|
-
const loadData = async (isRefresh = false) => {
|
|
35
|
+
const loadData = async (requestedPage, isRefresh = false) => {
|
|
36
36
|
if (loading.value || loadingMore.value) return;
|
|
37
|
-
const requestedPage = current.value;
|
|
38
37
|
const isLoadMoreOp = !isRefresh;
|
|
39
38
|
loading.value = isLoadMoreOp ? false : true;
|
|
40
39
|
if (isRefresh) refreshing.value = true;
|
|
@@ -42,7 +41,7 @@ export function useLoadMore(service, options = {}) {
|
|
|
42
41
|
error.value = void 0;
|
|
43
42
|
try {
|
|
44
43
|
const extraParams = params.value.slice(2);
|
|
45
|
-
const response = await loadService(
|
|
44
|
+
const response = await loadService(requestedPage, pageSize.value, ...extraParams);
|
|
46
45
|
const pageData = response.data;
|
|
47
46
|
if (pageData && typeof pageData === "object") {
|
|
48
47
|
const paginatedData = pageData;
|
|
@@ -54,7 +53,6 @@ export function useLoadMore(service, options = {}) {
|
|
|
54
53
|
}
|
|
55
54
|
if (isRefresh) {
|
|
56
55
|
data.value = pageData;
|
|
57
|
-
current.value = requestedPage + 1;
|
|
58
56
|
} else {
|
|
59
57
|
const oldData = data.value;
|
|
60
58
|
if (Array.isArray(oldData) && Array.isArray(pageData)) {
|
|
@@ -62,8 +60,8 @@ export function useLoadMore(service, options = {}) {
|
|
|
62
60
|
} else {
|
|
63
61
|
data.value = pageData;
|
|
64
62
|
}
|
|
65
|
-
current.value = requestedPage + 1;
|
|
66
63
|
}
|
|
64
|
+
current.value = requestedPage;
|
|
67
65
|
onSuccess?.(pageData, params.value);
|
|
68
66
|
} catch (err) {
|
|
69
67
|
error.value = err;
|
|
@@ -77,19 +75,18 @@ export function useLoadMore(service, options = {}) {
|
|
|
77
75
|
};
|
|
78
76
|
const loadMore = async () => {
|
|
79
77
|
if (noMore.value || loadingMore.value) return;
|
|
80
|
-
await loadData(false);
|
|
78
|
+
await loadData(current.value + 1, false);
|
|
81
79
|
};
|
|
82
80
|
const reload = async () => {
|
|
83
|
-
|
|
84
|
-
await loadData(true);
|
|
81
|
+
await loadData(initialPage, true);
|
|
85
82
|
};
|
|
86
83
|
const refresh = async () => {
|
|
87
84
|
await reload();
|
|
88
85
|
};
|
|
89
86
|
const pagination = {
|
|
90
87
|
loadPage: async (page) => {
|
|
91
|
-
|
|
92
|
-
await loadData(true);
|
|
88
|
+
if (page < 1 || totalPages.value > 0 && page > totalPages.value) return;
|
|
89
|
+
await loadData(page, true);
|
|
93
90
|
},
|
|
94
91
|
nextPage: loadMore,
|
|
95
92
|
prevPage: async () => {
|
|
@@ -111,7 +108,7 @@ export function useLoadMore(service, options = {}) {
|
|
|
111
108
|
};
|
|
112
109
|
if (!manual) {
|
|
113
110
|
onMounted(() => {
|
|
114
|
-
loadData();
|
|
111
|
+
loadData(current.value, false);
|
|
115
112
|
});
|
|
116
113
|
}
|
|
117
114
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yh-ui/request",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.54",
|
|
4
4
|
"description": "YH-UI HTTP request hooks - Enterprise-grade request management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"postpack": "node ../../scripts/prepare-package-manifest.mjs restore"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@yh-ui/utils": "^1.0.
|
|
35
|
+
"@yh-ui/utils": "^1.0.54"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"vue": "^3.5.35",
|