zx-infinite-scroll 1.0.4 → 1.0.7
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/README.md +10 -77
- package/dist/index.es.js +204 -196
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
const Ee = { class: "loading-content" }, Re = { class: "loading-text" }, Ce = /* @__PURE__ */
|
|
1
|
+
import { defineComponent as Y, openBlock as f, createElementBlock as p, normalizeClass as X, createElementVNode as $, toDisplayString as V, computed as se, normalizeStyle as P, renderSlot as K, createTextVNode as ge, createCommentVNode as D, ref as d, watch as j, onMounted as fe, nextTick as I, onBeforeUnmount as xe, withDirectives as ye, vShow as Te, createVNode as be, createBlock as U, withCtx as we } from "vue";
|
|
2
|
+
const Ee = { class: "loading-content" }, Re = { class: "loading-text" }, Ce = /* @__PURE__ */ Y({
|
|
3
3
|
name: "RequestLoading",
|
|
4
4
|
__name: "request-loading",
|
|
5
5
|
props: {
|
|
@@ -7,24 +7,24 @@ const Ee = { class: "loading-content" }, Re = { class: "loading-text" }, Ce = /*
|
|
|
7
7
|
fullscreen: { type: Boolean, default: !1 }
|
|
8
8
|
},
|
|
9
9
|
setup(t) {
|
|
10
|
-
return (
|
|
11
|
-
class:
|
|
10
|
+
return (m, g) => (f(), p("div", {
|
|
11
|
+
class: X(["loading-container", { fullscreen: t.fullscreen }])
|
|
12
12
|
}, [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
$("div", Ee, [
|
|
14
|
+
g[0] || (g[0] = $("span", { class: "loading-spinner" }, null, -1)),
|
|
15
|
+
$("span", Re, V(t.text), 1)
|
|
16
16
|
])
|
|
17
17
|
], 2));
|
|
18
18
|
}
|
|
19
|
-
}), G = (t,
|
|
20
|
-
const
|
|
21
|
-
for (const [
|
|
22
|
-
|
|
23
|
-
return
|
|
24
|
-
},
|
|
19
|
+
}), G = (t, m) => {
|
|
20
|
+
const g = t.__vccOpts || t;
|
|
21
|
+
for (const [l, x] of m)
|
|
22
|
+
g[l] = x;
|
|
23
|
+
return g;
|
|
24
|
+
}, Z = /* @__PURE__ */ G(Ce, [["__scopeId", "data-v-d89150ba"]]), ke = ["src"], Le = {
|
|
25
25
|
key: 0,
|
|
26
26
|
class: "empty-text"
|
|
27
|
-
}, He = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='80' viewBox='0 0 96 80' fill='none'%3E%3Cpath d='M8 16C8 12.6863 10.6863 10 14 10H38L44 16H82C85.3137 16 88 18.6863 88 22V66C88 69.3137 85.3137 72 82 72H14C10.6863 72 8 69.3137 8 66V16Z' fill='%23E8E8E8'/%3E%3Cpath d='M8 20C8 18.3431 9.34315 17 11 17H85C86.6569 17 88 18.3431 88 20V66C88 69.3137 85.3137 72 82 72H14C10.6863 72 8 69.3137 8 66V20Z' fill='%23F5F5F5'/%3E%3Cpath d='M38 42C38 40.8954 38.8954 40 40 40H56C57.1046 40 58 40.8954 58 42V44C58 45.1046 57.1046 46 56 46H40C38.8954 46 38 45.1046 38 44V42Z' fill='%23D9D9D9'/%3E%3C/svg%3E", Se = /* @__PURE__ */
|
|
27
|
+
}, He = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='80' viewBox='0 0 96 80' fill='none'%3E%3Cpath d='M8 16C8 12.6863 10.6863 10 14 10H38L44 16H82C85.3137 16 88 18.6863 88 22V66C88 69.3137 85.3137 72 82 72H14C10.6863 72 8 69.3137 8 66V16Z' fill='%23E8E8E8'/%3E%3Cpath d='M8 20C8 18.3431 9.34315 17 11 17H85C86.6569 17 88 18.3431 88 20V66C88 69.3137 85.3137 72 82 72H14C10.6863 72 8 69.3137 8 66V20Z' fill='%23F5F5F5'/%3E%3Cpath d='M38 42C38 40.8954 38.8954 40 40 40H56C57.1046 40 58 40.8954 58 42V44C58 45.1046 57.1046 46 56 46H40C38.8954 46 38 45.1046 38 44V42Z' fill='%23D9D9D9'/%3E%3C/svg%3E", Se = /* @__PURE__ */ Y({
|
|
28
28
|
name: "EmptyComponent",
|
|
29
29
|
__name: "empty-component",
|
|
30
30
|
props: {
|
|
@@ -34,38 +34,38 @@ const Ee = { class: "loading-content" }, Re = { class: "loading-text" }, Ce = /*
|
|
|
34
34
|
emptyImage: { default: "" }
|
|
35
35
|
},
|
|
36
36
|
setup(t) {
|
|
37
|
-
const
|
|
38
|
-
paddingTop: typeof
|
|
39
|
-
})),
|
|
40
|
-
return (x, a) => (f(),
|
|
37
|
+
const m = t, g = se(() => ({
|
|
38
|
+
paddingTop: typeof m.paddingTop == "number" ? `${m.paddingTop}px` : m.paddingTop
|
|
39
|
+
})), l = se(() => m.emptyImage || He);
|
|
40
|
+
return (x, a) => (f(), p("div", {
|
|
41
41
|
class: "empty-wrap",
|
|
42
|
-
style:
|
|
42
|
+
style: P(g.value)
|
|
43
43
|
}, [
|
|
44
|
-
|
|
44
|
+
$("img", {
|
|
45
45
|
class: "empty-image",
|
|
46
|
-
src:
|
|
46
|
+
src: l.value,
|
|
47
47
|
alt: ""
|
|
48
|
-
}, null, 8,
|
|
49
|
-
t.showText ? (f(),
|
|
50
|
-
|
|
51
|
-
ge(
|
|
48
|
+
}, null, 8, ke),
|
|
49
|
+
t.showText ? (f(), p("p", Le, [
|
|
50
|
+
K(x.$slots, "default", {}, () => [
|
|
51
|
+
ge(V(t.text), 1)
|
|
52
52
|
], !0)
|
|
53
|
-
])) :
|
|
53
|
+
])) : D("", !0)
|
|
54
54
|
], 4));
|
|
55
55
|
}
|
|
56
|
-
}),
|
|
56
|
+
}), de = /* @__PURE__ */ G(Se, [["__scopeId", "data-v-3c452901"]]), ze = { class: "pull-refresh-content" }, Be = { key: 0 }, Me = {
|
|
57
57
|
key: 1,
|
|
58
58
|
class: "pull-text"
|
|
59
59
|
}, De = {
|
|
60
60
|
key: 2,
|
|
61
61
|
class: "pull-text"
|
|
62
|
-
},
|
|
62
|
+
}, Ie = {
|
|
63
63
|
key: 0,
|
|
64
64
|
class: "content-loading-mask"
|
|
65
|
-
},
|
|
65
|
+
}, Ve = {
|
|
66
66
|
key: 1,
|
|
67
67
|
class: "finished-text"
|
|
68
|
-
}, ue = 8, $e = /* @__PURE__ */
|
|
68
|
+
}, ue = 8, $e = /* @__PURE__ */ Y({
|
|
69
69
|
name: "InfiniteScroll",
|
|
70
70
|
__name: "infinite-scroll",
|
|
71
71
|
props: {
|
|
@@ -86,189 +86,189 @@ const Ee = { class: "loading-content" }, Re = { class: "loading-text" }, Ce = /*
|
|
|
86
86
|
contentLoading: { type: Boolean, default: !1 }
|
|
87
87
|
},
|
|
88
88
|
emits: ["refresh", "load", "retry"],
|
|
89
|
-
setup(t, { expose:
|
|
90
|
-
const
|
|
91
|
-
let
|
|
92
|
-
function
|
|
93
|
-
!
|
|
89
|
+
setup(t, { expose: m, emit: g }) {
|
|
90
|
+
const l = t, x = g, a = d(null), i = d(null), R = d(null), o = d("idle"), h = d(0), y = d(!1);
|
|
91
|
+
let w = 0, C = 0, T = 0, b = "none", v = !1, H = !1, S = !1, k = null, s = null, n = null, u = null, c = -1;
|
|
92
|
+
function B(e, r) {
|
|
93
|
+
!l.pullRefresh || v || (w = e, C = r, T = 0, b = "none", o.value = "idle");
|
|
94
94
|
}
|
|
95
|
-
function J(e,
|
|
96
|
-
if (!
|
|
97
|
-
const
|
|
98
|
-
if (
|
|
99
|
-
const
|
|
100
|
-
if (
|
|
101
|
-
|
|
95
|
+
function J(e, r, E) {
|
|
96
|
+
if (!l.pullRefresh || v || C === 0) return !1;
|
|
97
|
+
const M = e - w, L = r - C;
|
|
98
|
+
if (b === "none") {
|
|
99
|
+
const z = Math.abs(M), O = Math.abs(L);
|
|
100
|
+
if (z > ue || O > ue)
|
|
101
|
+
b = O > z * 1.5 ? "vertical" : "horizontal";
|
|
102
102
|
else
|
|
103
103
|
return !1;
|
|
104
104
|
}
|
|
105
|
-
if (
|
|
106
|
-
const q =
|
|
107
|
-
if (!q &&
|
|
108
|
-
const
|
|
109
|
-
return !!(
|
|
105
|
+
if (b === "horizontal") return !1;
|
|
106
|
+
const q = pe() <= 1;
|
|
107
|
+
if (!q && L < 0) {
|
|
108
|
+
const z = a.value;
|
|
109
|
+
return !!(z && z.scrollHeight - z.scrollTop - z.clientHeight <= 1 && E);
|
|
110
110
|
}
|
|
111
|
-
return q ? (T = Math.max(0, Math.min(
|
|
112
|
-
|
|
113
|
-
})),
|
|
111
|
+
return q ? (T = Math.max(0, Math.min(L, 150)), y.value = !0, s === null && (s = requestAnimationFrame(() => {
|
|
112
|
+
s = null, h.value = T * 0.5, T === 0 ? o.value = "idle" : o.value = T > l.pullThreshold ? "loosing" : "pulling";
|
|
113
|
+
})), L > 0) : !1;
|
|
114
114
|
}
|
|
115
115
|
function Q() {
|
|
116
|
-
!
|
|
116
|
+
!l.pullRefresh || v || (s !== null && (cancelAnimationFrame(s), s = null), y.value = !1, T > l.pullThreshold ? (v = !0, o.value = "refreshing", h.value = 50, x("refresh")) : (h.value = 0, o.value = "idle"), ie());
|
|
117
117
|
}
|
|
118
|
-
function
|
|
119
|
-
!
|
|
118
|
+
function ve() {
|
|
119
|
+
!l.pullRefresh || v || (s !== null && (cancelAnimationFrame(s), s = null), y.value = !1, h.value = 0, o.value = "idle", ie());
|
|
120
120
|
}
|
|
121
121
|
function W(e) {
|
|
122
|
-
|
|
122
|
+
B(e.touches[0].clientX, e.touches[0].clientY);
|
|
123
123
|
}
|
|
124
124
|
function _(e) {
|
|
125
|
-
const
|
|
126
|
-
J(
|
|
125
|
+
const r = e.touches[0];
|
|
126
|
+
J(r.clientX, r.clientY, e.cancelable) && e.cancelable && e.preventDefault();
|
|
127
127
|
}
|
|
128
128
|
function ee() {
|
|
129
129
|
Q();
|
|
130
130
|
}
|
|
131
131
|
function te() {
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
function le(e) {
|
|
135
|
-
!n.pullRefresh || v || e.button !== 0 || (B = !0, M(e.clientX, e.clientY));
|
|
132
|
+
ve();
|
|
136
133
|
}
|
|
137
134
|
function ne(e) {
|
|
138
|
-
|
|
135
|
+
!l.pullRefresh || v || e.button !== 0 || (S = !0, B(e.clientX, e.clientY));
|
|
136
|
+
}
|
|
137
|
+
function le(e) {
|
|
138
|
+
S && J(e.clientX, e.clientY, !0) && e.preventDefault();
|
|
139
139
|
}
|
|
140
140
|
function ae() {
|
|
141
|
-
|
|
141
|
+
S && (S = !1, Q());
|
|
142
142
|
}
|
|
143
|
-
function
|
|
144
|
-
|
|
143
|
+
function ie() {
|
|
144
|
+
w = 0, C = 0, T = 0, b = "none";
|
|
145
145
|
}
|
|
146
|
-
function
|
|
147
|
-
|
|
146
|
+
function A() {
|
|
147
|
+
l.loading || l.finished || l.error || H || k || (k = window.setTimeout(() => {
|
|
148
148
|
var q;
|
|
149
149
|
k = null;
|
|
150
150
|
const e = a.value;
|
|
151
151
|
if (!e) return;
|
|
152
|
-
const { scrollTop:
|
|
153
|
-
if (
|
|
154
|
-
if (c ===
|
|
155
|
-
c =
|
|
152
|
+
const { scrollTop: r, clientHeight: E, scrollHeight: M } = e, L = ((q = i.value) == null ? void 0 : q.clientHeight) || 0;
|
|
153
|
+
if (L <= E) {
|
|
154
|
+
if (c === L) return;
|
|
155
|
+
c = L, oe(!0);
|
|
156
156
|
return;
|
|
157
157
|
}
|
|
158
|
-
|
|
158
|
+
M - r - E <= l.loadThreshold && oe(!1);
|
|
159
159
|
}, 100));
|
|
160
160
|
}
|
|
161
|
-
function
|
|
162
|
-
|
|
163
|
-
var
|
|
164
|
-
const
|
|
165
|
-
|
|
161
|
+
function oe(e = !1) {
|
|
162
|
+
H = !0, x("load"), I(() => {
|
|
163
|
+
var E;
|
|
164
|
+
const r = a.value;
|
|
165
|
+
r && (e ? r.scrollTop = r.scrollHeight : (E = R.value) == null || E.scrollIntoView({ block: "end", behavior: "smooth" }));
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
|
-
function
|
|
168
|
+
function pe() {
|
|
169
169
|
var e;
|
|
170
170
|
return ((e = a.value) == null ? void 0 : e.scrollTop) ?? 0;
|
|
171
171
|
}
|
|
172
|
-
function
|
|
173
|
-
v = !1, h.value = 0,
|
|
174
|
-
|
|
172
|
+
function N() {
|
|
173
|
+
v = !1, h.value = 0, n !== null && clearTimeout(n), n = window.setTimeout(() => {
|
|
174
|
+
o.value = "idle", n = null;
|
|
175
175
|
}, 250), c = -1, I(() => {
|
|
176
176
|
F();
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
|
-
function
|
|
180
|
-
|
|
181
|
-
var
|
|
182
|
-
const e = ((
|
|
179
|
+
function re() {
|
|
180
|
+
H = !1, I(() => {
|
|
181
|
+
var r;
|
|
182
|
+
const e = ((r = i.value) == null ? void 0 : r.clientHeight) || 0;
|
|
183
183
|
c !== -1 && e === c || (c = -1, F());
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
186
|
function F() {
|
|
187
|
-
|
|
188
|
-
var
|
|
189
|
-
const e = ((
|
|
190
|
-
e <=
|
|
187
|
+
l.finished || l.loading || l.error || I(() => {
|
|
188
|
+
var E, M;
|
|
189
|
+
const e = ((E = i.value) == null ? void 0 : E.clientHeight) || 0, r = ((M = a.value) == null ? void 0 : M.clientHeight) || 0;
|
|
190
|
+
e <= r && !H && A();
|
|
191
191
|
});
|
|
192
192
|
}
|
|
193
193
|
function me() {
|
|
194
194
|
x("retry");
|
|
195
195
|
}
|
|
196
|
-
return
|
|
197
|
-
() =>
|
|
196
|
+
return j(
|
|
197
|
+
() => l.loading,
|
|
198
198
|
(e) => {
|
|
199
|
-
e || (
|
|
199
|
+
e || (H = !1);
|
|
200
200
|
}
|
|
201
|
-
),
|
|
202
|
-
() =>
|
|
201
|
+
), j(
|
|
202
|
+
() => l.finished,
|
|
203
203
|
(e) => {
|
|
204
204
|
e && (c = -1);
|
|
205
205
|
}
|
|
206
|
-
),
|
|
206
|
+
), fe(() => {
|
|
207
207
|
const e = a.value;
|
|
208
|
-
e && (
|
|
208
|
+
e && (l.pullRefresh && (e.addEventListener("touchstart", W, { passive: !0 }), e.addEventListener("touchmove", _, { passive: !1 }), e.addEventListener("touchend", ee, { passive: !0 }), e.addEventListener("touchcancel", te, { passive: !0 }), e.addEventListener("mousedown", ne), window.addEventListener("mousemove", le), window.addEventListener("mouseup", ae)), e.addEventListener("scroll", A, { passive: !0 }), typeof ResizeObserver < "u" && (u = new ResizeObserver(() => {
|
|
209
209
|
F();
|
|
210
|
-
}), u.observe(e),
|
|
210
|
+
}), u.observe(e), i.value && u.observe(i.value)), I(() => {
|
|
211
211
|
F();
|
|
212
212
|
}));
|
|
213
|
-
}),
|
|
213
|
+
}), xe(() => {
|
|
214
214
|
const e = a.value;
|
|
215
|
-
e && (e.removeEventListener("touchstart", W), e.removeEventListener("touchmove", _), e.removeEventListener("touchend", ee), e.removeEventListener("touchcancel", te), e.removeEventListener("mousedown",
|
|
216
|
-
}),
|
|
217
|
-
refresh:
|
|
218
|
-
finishRefresh:
|
|
219
|
-
finishPullDown:
|
|
220
|
-
finishLoad:
|
|
221
|
-
finishPullUp:
|
|
215
|
+
e && (e.removeEventListener("touchstart", W), e.removeEventListener("touchmove", _), e.removeEventListener("touchend", ee), e.removeEventListener("touchcancel", te), e.removeEventListener("mousedown", ne), e.removeEventListener("scroll", A)), window.removeEventListener("mousemove", le), window.removeEventListener("mouseup", ae), u && (u.disconnect(), u = null), s !== null && (cancelAnimationFrame(s), s = null), k !== null && (clearTimeout(k), k = null), n !== null && (clearTimeout(n), n = null);
|
|
216
|
+
}), m({
|
|
217
|
+
refresh: N,
|
|
218
|
+
finishRefresh: N,
|
|
219
|
+
finishPullDown: N,
|
|
220
|
+
finishLoad: re,
|
|
221
|
+
finishPullUp: re,
|
|
222
222
|
checkContentHeight: F
|
|
223
|
-
}), (e,
|
|
223
|
+
}), (e, r) => (f(), p("div", {
|
|
224
224
|
ref_key: "containerRef",
|
|
225
225
|
ref: a,
|
|
226
226
|
class: "infinite-scroll"
|
|
227
227
|
}, [
|
|
228
|
-
t.pullRefresh ? (f(),
|
|
228
|
+
t.pullRefresh ? (f(), p("div", {
|
|
229
229
|
key: 0,
|
|
230
|
-
class:
|
|
231
|
-
style:
|
|
230
|
+
class: X(["pull-refresh-indicator", { "no-transition": y.value }]),
|
|
231
|
+
style: P({ transform: `translateY(${h.value}px)` })
|
|
232
232
|
}, [
|
|
233
|
-
|
|
234
|
-
|
|
233
|
+
ye($("div", ze, [
|
|
234
|
+
o.value === "refreshing" ? (f(), p("span", Be)) : o.value === "loosing" ? (f(), p("span", Me, V(t.loosingText), 1)) : (f(), p("span", De, V(t.pullingText), 1))
|
|
235
235
|
], 512), [
|
|
236
|
-
[
|
|
236
|
+
[Te, o.value !== "idle"]
|
|
237
237
|
])
|
|
238
|
-
], 6)) :
|
|
239
|
-
|
|
238
|
+
], 6)) : D("", !0),
|
|
239
|
+
$("div", {
|
|
240
240
|
ref_key: "contentRef",
|
|
241
|
-
ref:
|
|
242
|
-
class:
|
|
243
|
-
style:
|
|
241
|
+
ref: i,
|
|
242
|
+
class: X(["infinite-scroll-content", { "no-transition": y.value }]),
|
|
243
|
+
style: P(t.pullRefresh ? { transform: `translateY(${h.value}px)` } : {})
|
|
244
244
|
}, [
|
|
245
|
-
t.contentLoading ? (f(),
|
|
246
|
-
|
|
247
|
-
])) :
|
|
248
|
-
t.isEmpty && !t.loading ? (f(),
|
|
245
|
+
t.contentLoading ? (f(), p("div", Ie, [
|
|
246
|
+
be(Z, { text: t.refreshingText }, null, 8, ["text"])
|
|
247
|
+
])) : D("", !0),
|
|
248
|
+
t.isEmpty && !t.loading ? (f(), U(de, {
|
|
249
249
|
key: 1,
|
|
250
250
|
text: t.emptyText
|
|
251
|
-
}, null, 8, ["text"])) :
|
|
252
|
-
|
|
253
|
-
t.isEmpty ?
|
|
251
|
+
}, null, 8, ["text"])) : D("", !0),
|
|
252
|
+
K(e.$slots, "default", {}, void 0, !0),
|
|
253
|
+
t.isEmpty ? D("", !0) : (f(), p("div", {
|
|
254
254
|
key: 2,
|
|
255
255
|
ref_key: "indicatorRef",
|
|
256
|
-
ref:
|
|
256
|
+
ref: R,
|
|
257
257
|
class: "load-more-indicator"
|
|
258
258
|
}, [
|
|
259
|
-
t.loading &&
|
|
259
|
+
t.loading && o.value !== "refreshing" ? (f(), U(Z, {
|
|
260
260
|
key: 0,
|
|
261
261
|
text: t.loadingText
|
|
262
|
-
}, null, 8, ["text"])) : t.finished ? (f(),
|
|
262
|
+
}, null, 8, ["text"])) : t.finished ? (f(), p("span", Ve, V(t.finishedText), 1)) : t.error ? (f(), p("span", {
|
|
263
263
|
key: 2,
|
|
264
264
|
class: "error-text",
|
|
265
265
|
onClick: me
|
|
266
|
-
},
|
|
266
|
+
}, V(t.errorText), 1)) : D("", !0)
|
|
267
267
|
], 512))
|
|
268
268
|
], 6)
|
|
269
269
|
], 512));
|
|
270
270
|
}
|
|
271
|
-
}),
|
|
271
|
+
}), he = /* @__PURE__ */ G($e, [["__scopeId", "data-v-bf5ca1d9"]]), Fe = /* @__PURE__ */ Y({
|
|
272
272
|
name: "InfiniteScrollV2",
|
|
273
273
|
__name: "infinite-scroll-v2",
|
|
274
274
|
props: {
|
|
@@ -289,96 +289,96 @@ const Ee = { class: "loading-content" }, Re = { class: "loading-text" }, Ce = /*
|
|
|
289
289
|
errorText: { default: "加载失败,点击重试" }
|
|
290
290
|
},
|
|
291
291
|
emits: ["success", "error", "update:list"],
|
|
292
|
-
setup(t, { expose:
|
|
293
|
-
const
|
|
294
|
-
let
|
|
295
|
-
async function v(
|
|
296
|
-
|
|
297
|
-
const u =
|
|
292
|
+
setup(t, { expose: m, emit: g }) {
|
|
293
|
+
const l = t, x = g, a = d(null), i = d([]), R = d(!1), o = d(!1), h = d(!1), y = d(!1), w = d(0), C = d(1), T = d(!1);
|
|
294
|
+
let b = 0;
|
|
295
|
+
async function v(n = !1) {
|
|
296
|
+
n && (C.value = 1, o.value = !1, h.value = !1), R.value = !0, y.value = !1, b += 1;
|
|
297
|
+
const u = b;
|
|
298
298
|
try {
|
|
299
|
-
const c = await
|
|
300
|
-
page:
|
|
301
|
-
pageSize:
|
|
302
|
-
...
|
|
299
|
+
const c = await l.fetchFn({
|
|
300
|
+
page: C.value,
|
|
301
|
+
pageSize: l.pageSize,
|
|
302
|
+
...l.params
|
|
303
303
|
});
|
|
304
|
-
if (u !==
|
|
305
|
-
const
|
|
306
|
-
|
|
304
|
+
if (u !== b) return;
|
|
305
|
+
const B = (c == null ? void 0 : c.records) || [];
|
|
306
|
+
n ? (i.value = B, w.value = 0) : i.value = [...i.value, ...B], w.value = Number((c == null ? void 0 : c.total) || 0), o.value = i.value.length >= w.value, h.value = i.value.length === 0, x("success", { records: B, total: w.value, reset: n }), x("update:list", i.value);
|
|
307
307
|
} catch (c) {
|
|
308
|
-
if (u !==
|
|
308
|
+
if (u !== b) return;
|
|
309
309
|
y.value = !0, x("error", c);
|
|
310
310
|
} finally {
|
|
311
|
-
u ===
|
|
311
|
+
u === b && (R.value = !1);
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
|
-
async function
|
|
315
|
-
var
|
|
316
|
-
T.value = !0, (
|
|
314
|
+
async function H() {
|
|
315
|
+
var n;
|
|
316
|
+
T.value = !0, (n = a.value) == null || n.finishRefresh(), await new Promise((u) => {
|
|
317
317
|
setTimeout(() => u(), 250);
|
|
318
318
|
}), await v(!0), T.value = !1;
|
|
319
319
|
}
|
|
320
|
-
async function
|
|
321
|
-
var
|
|
322
|
-
if (
|
|
323
|
-
(
|
|
320
|
+
async function S() {
|
|
321
|
+
var n, u;
|
|
322
|
+
if (o.value) {
|
|
323
|
+
(n = a.value) == null || n.finishLoad();
|
|
324
324
|
return;
|
|
325
325
|
}
|
|
326
|
-
|
|
326
|
+
i.value.length > 0 && (C.value += 1), await v(!1), (u = a.value) == null || u.finishLoad();
|
|
327
327
|
}
|
|
328
328
|
function k() {
|
|
329
|
-
y.value = !1,
|
|
329
|
+
y.value = !1, i.value.length === 0 ? v(!0) : S();
|
|
330
330
|
}
|
|
331
|
-
async function
|
|
331
|
+
async function s() {
|
|
332
332
|
await v(!0);
|
|
333
333
|
}
|
|
334
|
-
return
|
|
335
|
-
() =>
|
|
334
|
+
return j(
|
|
335
|
+
() => l.params,
|
|
336
336
|
() => {
|
|
337
|
-
|
|
337
|
+
l.autoReload && s();
|
|
338
338
|
},
|
|
339
339
|
{ deep: !0 }
|
|
340
|
-
),
|
|
341
|
-
|
|
340
|
+
), j(
|
|
341
|
+
i,
|
|
342
342
|
async () => {
|
|
343
|
-
var
|
|
344
|
-
await I(), (
|
|
343
|
+
var n;
|
|
344
|
+
await I(), (n = a.value) == null || n.checkContentHeight();
|
|
345
345
|
},
|
|
346
346
|
{ deep: !0 }
|
|
347
|
-
),
|
|
348
|
-
|
|
349
|
-
}),
|
|
347
|
+
), fe(() => {
|
|
348
|
+
l.immediate && v(!0);
|
|
349
|
+
}), m({
|
|
350
350
|
/** 重新加载第一页 */
|
|
351
|
-
reload:
|
|
351
|
+
reload: s,
|
|
352
352
|
/** 兼容别名 */
|
|
353
|
-
refresh:
|
|
353
|
+
refresh: s,
|
|
354
354
|
/** 当前列表数据 */
|
|
355
|
-
list:
|
|
355
|
+
list: i,
|
|
356
356
|
/** 加载中状态 */
|
|
357
|
-
loading:
|
|
357
|
+
loading: R,
|
|
358
358
|
/** 是否已加载完 */
|
|
359
|
-
finished:
|
|
359
|
+
finished: o,
|
|
360
360
|
/** 是否空数据 */
|
|
361
361
|
isEmpty: h,
|
|
362
362
|
/** 总条数 */
|
|
363
|
-
total:
|
|
363
|
+
total: w,
|
|
364
364
|
/** 透传 v1 方法 */
|
|
365
365
|
finishLoad: () => {
|
|
366
|
-
var
|
|
367
|
-
return (
|
|
366
|
+
var n;
|
|
367
|
+
return (n = a.value) == null ? void 0 : n.finishLoad();
|
|
368
368
|
},
|
|
369
369
|
finishRefresh: () => {
|
|
370
|
-
var
|
|
371
|
-
return (
|
|
370
|
+
var n;
|
|
371
|
+
return (n = a.value) == null ? void 0 : n.finishRefresh();
|
|
372
372
|
},
|
|
373
373
|
checkContentHeight: () => {
|
|
374
|
-
var
|
|
375
|
-
return (
|
|
374
|
+
var n;
|
|
375
|
+
return (n = a.value) == null ? void 0 : n.checkContentHeight();
|
|
376
376
|
}
|
|
377
|
-
}), (
|
|
377
|
+
}), (n, u) => (f(), U(he, {
|
|
378
378
|
ref_key: "scrollRef",
|
|
379
379
|
ref: a,
|
|
380
|
-
loading:
|
|
381
|
-
finished:
|
|
380
|
+
loading: R.value,
|
|
381
|
+
finished: o.value,
|
|
382
382
|
"is-empty": h.value,
|
|
383
383
|
error: y.value,
|
|
384
384
|
"pull-refresh": t.pullRefresh,
|
|
@@ -392,37 +392,45 @@ const Ee = { class: "loading-content" }, Re = { class: "loading-text" }, Ce = /*
|
|
|
392
392
|
"finished-text": t.finishedText,
|
|
393
393
|
"error-text": t.errorText,
|
|
394
394
|
"content-loading": T.value,
|
|
395
|
-
onLoad:
|
|
396
|
-
onRefresh:
|
|
395
|
+
onLoad: S,
|
|
396
|
+
onRefresh: H,
|
|
397
397
|
onRetry: k
|
|
398
398
|
}, {
|
|
399
399
|
default: we(() => [
|
|
400
|
-
|
|
401
|
-
list:
|
|
402
|
-
loading:
|
|
403
|
-
finished:
|
|
400
|
+
K(n.$slots, "default", {
|
|
401
|
+
list: i.value,
|
|
402
|
+
loading: R.value,
|
|
403
|
+
finished: o.value,
|
|
404
404
|
isEmpty: h.value,
|
|
405
405
|
error: y.value,
|
|
406
|
-
total:
|
|
407
|
-
reload:
|
|
406
|
+
total: w.value,
|
|
407
|
+
reload: s
|
|
408
408
|
})
|
|
409
409
|
]),
|
|
410
410
|
_: 3
|
|
411
411
|
}, 8, ["loading", "finished", "is-empty", "error", "pull-refresh", "pull-threshold", "load-threshold", "empty-text", "pulling-text", "loosing-text", "refreshing-text", "loading-text", "finished-text", "error-text", "content-loading"]));
|
|
412
412
|
}
|
|
413
413
|
});
|
|
414
|
-
|
|
415
|
-
|
|
414
|
+
let ce = !1;
|
|
415
|
+
const qe = ".loading-content[data-v-d89150ba]{display:flex;align-items:center;justify-content:center;gap:8px;padding:6px 12px;border-radius:16px;color:var(--zx-primary-color, #1e5efd);font-size:14px}.loading-spinner[data-v-d89150ba]{width:18px;height:18px;border-radius:50%;border:2.5px solid var(--zx-primary-color, #1e5efd);border-top-color:transparent;animation:spin-d89150ba .8s linear infinite}@keyframes spin-d89150ba{to{transform:rotate(360deg)}}.loading-container.fullscreen[data-v-d89150ba]{position:fixed;top:0;left:0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;background-color:#ffffff80}.empty-wrap[data-v-3c452901]{display:flex;flex-direction:column;align-items:center}.empty-image[data-v-3c452901]{width:96px;height:80px}.empty-text[data-v-3c452901]{margin:12px 0 0;color:#8c8f97;font-size:12px;line-height:22px}.infinite-scroll[data-v-bf5ca1d9]{height:100%;position:relative;min-height:100%;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;touch-action:pan-y;-webkit-overflow-scrolling:touch}.pull-refresh-indicator[data-v-bf5ca1d9]{position:absolute;top:-50px;left:0;right:0;height:50px;transition:transform .25s}.pull-refresh-indicator.no-transition[data-v-bf5ca1d9]{transition:none}.pull-refresh-content[data-v-bf5ca1d9]{display:flex;align-items:center;justify-content:center;height:100%;font-size:14px;color:#969799}.pull-text[data-v-bf5ca1d9]{color:var(--zx-primary-color, #1989fa);font-size:14px}.infinite-scroll-content[data-v-bf5ca1d9]{position:relative;transition:transform .25s;min-height:100%}.infinite-scroll-content.no-transition[data-v-bf5ca1d9]{transition:none}.content-loading-mask[data-v-bf5ca1d9]{position:absolute;top:0;left:0;right:0;bottom:0;background-color:#fffc;display:flex;align-items:center;justify-content:center;z-index:10;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}.load-more-indicator[data-v-bf5ca1d9]{display:flex;align-items:center;justify-content:center;min-height:50px;padding:16px 0;font-size:14px;color:#8c8f97}.finished-text[data-v-bf5ca1d9]{color:#8c8f97;font-size:14px}.error-text[data-v-bf5ca1d9]{color:#ee0a24;font-size:14px;cursor:pointer}.error-text[data-v-bf5ca1d9]:active{opacity:.7}";
|
|
416
|
+
function je() {
|
|
417
|
+
if (ce || typeof document > "u") return;
|
|
418
|
+
const t = document.createElement("style");
|
|
419
|
+
t.setAttribute("data-source", "zx-infinite-scroll"), t.textContent = qe, document.head.appendChild(t), ce = !0;
|
|
420
|
+
}
|
|
421
|
+
je();
|
|
422
|
+
function Ye(t) {
|
|
423
|
+
t.component("InfiniteScroll", he), t.component("InfiniteScrollV2", Fe), t.component("RequestLoading", Z), t.component("EmptyComponent", de);
|
|
416
424
|
}
|
|
417
|
-
const
|
|
418
|
-
install:
|
|
425
|
+
const Oe = {
|
|
426
|
+
install: Ye
|
|
419
427
|
};
|
|
420
428
|
export {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
429
|
+
de as EmptyComponent,
|
|
430
|
+
he as InfiniteScroll,
|
|
431
|
+
Fe as InfiniteScrollV2,
|
|
432
|
+
Z as RequestLoading,
|
|
433
|
+
Oe as default,
|
|
434
|
+
Ye as install
|
|
427
435
|
};
|
|
428
436
|
//# sourceMappingURL=index.es.js.map
|