@owocow/saber-ui 0.0.3 → 0.0.5
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/composables/use-table.d.ts +1 -1
- package/dist/composables/use-table.mjs +35 -35
- package/dist/index-BealGwXp.js +5020 -0
- package/dist/types/api.d.ts +0 -7
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/crypto.mjs +7 -7
- package/dist/utils/http.d.ts +10 -5
- package/dist/utils/storage.mjs +1 -1
- package/package.json +1 -1
|
@@ -27,7 +27,7 @@ export interface TableConfig<A extends ApiFn, T = any> {
|
|
|
27
27
|
apiParams?: Partial<ApiParams<A>>;
|
|
28
28
|
/** 转换已经附带 _index 的行数据。 */
|
|
29
29
|
transformer?: (rows: TableDataWithIndex<T>[]) => any[];
|
|
30
|
-
/**
|
|
30
|
+
/** 自定义响应归一化;默认解析 `data.rows / data.total`。 */
|
|
31
31
|
responseAdapter?: (response: Awaited<ReturnType<A>>) => NormalizedTableResponse<T>;
|
|
32
32
|
/** 获取并转换数据后的回调。 */
|
|
33
33
|
onFetched?: (data: any[]) => MaybePromise<void>;
|
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
import { reactive as
|
|
2
|
-
import { klona as
|
|
1
|
+
import { reactive as z, ref as N, watch as h, computed as R } from "vue";
|
|
2
|
+
import { klona as b } from "klona/json";
|
|
3
3
|
import { useBoolean as C } from "./use-boolean.mjs";
|
|
4
4
|
import { useLoading as D } from "./use-loading.mjs";
|
|
5
|
-
function I(
|
|
6
|
-
const
|
|
5
|
+
function I(n) {
|
|
6
|
+
const e = n == null ? void 0 : n.data;
|
|
7
7
|
return {
|
|
8
|
-
rows: Array.isArray(
|
|
9
|
-
total: Number((
|
|
8
|
+
rows: Array.isArray(e == null ? void 0 : e.rows) ? e.rows : [],
|
|
9
|
+
total: Number((e == null ? void 0 : e.total) ?? 0)
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
-
function H(
|
|
13
|
-
const { loading:
|
|
14
|
-
pageSizes:
|
|
15
|
-
pageSize:
|
|
12
|
+
function H(n) {
|
|
13
|
+
const { loading: e, startLoading: d, endLoading: g } = D(), { bool: y, setBool: w } = C(), { apiFn: j, apiParams: f, transformer: p, responseAdapter: P, immediate: O = !0, paginConfig: k } = n, s = z(b({ ...f })), S = N([]), { pageSizes: v, pageSize: x, disabled: A = !1 } = k || {}, t = z({
|
|
14
|
+
pageSizes: v || [10, 20, 50, 100],
|
|
15
|
+
pageSize: x || 10,
|
|
16
16
|
currentPage: 1,
|
|
17
17
|
total: 0
|
|
18
18
|
});
|
|
19
19
|
let u = !1;
|
|
20
|
-
|
|
20
|
+
h(
|
|
21
21
|
() => t.currentPage,
|
|
22
22
|
() => {
|
|
23
|
-
u ||
|
|
23
|
+
u || i();
|
|
24
24
|
},
|
|
25
25
|
{ flush: "sync" }
|
|
26
|
-
),
|
|
26
|
+
), h(
|
|
27
27
|
() => t.pageSize,
|
|
28
28
|
() => {
|
|
29
|
-
u = !0, t.currentPage = 1, u = !1,
|
|
29
|
+
u = !0, t.currentPage = 1, u = !1, i();
|
|
30
30
|
},
|
|
31
31
|
{ flush: "sync" }
|
|
32
32
|
);
|
|
33
|
-
function E(
|
|
33
|
+
function E(a) {
|
|
34
34
|
const o = t.currentPage || 1, c = t.pageSize > 0 ? t.pageSize : 10;
|
|
35
|
-
return
|
|
35
|
+
return a.map((m, r) => ({
|
|
36
36
|
...m,
|
|
37
|
-
_index: (o - 1) * c +
|
|
37
|
+
_index: (o - 1) * c + r + 1
|
|
38
38
|
}));
|
|
39
39
|
}
|
|
40
|
-
async function
|
|
41
|
-
var
|
|
40
|
+
async function i() {
|
|
41
|
+
var a;
|
|
42
42
|
d();
|
|
43
43
|
try {
|
|
44
|
-
const o = T(
|
|
45
|
-
return t.total = m.total, S.value = l, w(l.length === 0), await ((
|
|
44
|
+
const o = T(s), c = await j(o), m = P ? P(c) : I(c), r = E(m.rows), l = p ? p(r) : r;
|
|
45
|
+
return t.total = m.total, S.value = l, w(l.length === 0), await ((a = n.onFetched) == null ? void 0 : a.call(n, l)), l;
|
|
46
46
|
} finally {
|
|
47
47
|
g();
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
function L() {
|
|
51
|
-
return
|
|
51
|
+
return A ? {} : {
|
|
52
52
|
pageNum: t.currentPage,
|
|
53
53
|
pageSize: t.pageSize
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
-
function T(
|
|
57
|
-
const o = {}, c = { ...L(), ...
|
|
58
|
-
return Object.entries(c).forEach(([m,
|
|
59
|
-
|
|
56
|
+
function T(a) {
|
|
57
|
+
const o = {}, c = { ...L(), ...a };
|
|
58
|
+
return Object.entries(c).forEach(([m, r]) => {
|
|
59
|
+
r != null && r !== "" && (o[m] = r);
|
|
60
60
|
}), o;
|
|
61
61
|
}
|
|
62
|
-
function B(
|
|
63
|
-
return Object.assign(
|
|
62
|
+
function B(a) {
|
|
63
|
+
return Object.assign(s, a), i();
|
|
64
64
|
}
|
|
65
65
|
function F() {
|
|
66
66
|
u = !0, t.currentPage = 1, u = !1;
|
|
67
|
-
const
|
|
68
|
-
return Object.keys(
|
|
67
|
+
const a = b({ ...f });
|
|
68
|
+
return Object.keys(s).forEach((o) => delete s[o]), Object.assign(s, a), i();
|
|
69
69
|
}
|
|
70
|
-
return
|
|
71
|
-
loading:
|
|
72
|
-
empty:
|
|
70
|
+
return O && i(), {
|
|
71
|
+
loading: e,
|
|
72
|
+
empty: y,
|
|
73
73
|
data: S,
|
|
74
|
-
getData:
|
|
75
|
-
params:
|
|
74
|
+
getData: i,
|
|
75
|
+
params: s,
|
|
76
76
|
updateSearchParams: B,
|
|
77
77
|
resetSearchParams: F,
|
|
78
78
|
pagination: t,
|