@duxweb/dvha-core 1.0.18 → 1.0.20

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.
Files changed (38) hide show
  1. package/dist/cjs/components/loader/loader.cjs +1 -1
  2. package/dist/cjs/components/loader/remote/loader.cjs +1 -1
  3. package/dist/cjs/hooks/auth.cjs +1 -1
  4. package/dist/cjs/hooks/data.cjs +1 -1
  5. package/dist/cjs/hooks/export.cjs +1 -1
  6. package/dist/cjs/hooks/exportCsv.cjs +2 -2
  7. package/dist/cjs/hooks/form.cjs +1 -1
  8. package/dist/cjs/hooks/formExtend.cjs +1 -1
  9. package/dist/cjs/hooks/i18n.cjs +1 -1
  10. package/dist/cjs/hooks/list.cjs +1 -1
  11. package/dist/cjs/hooks/tree.cjs +1 -1
  12. package/dist/cjs/preset/i18nProvider.cjs +1 -1
  13. package/dist/cjs/provider/app.cjs +1 -1
  14. package/dist/cjs/stores/jsonSchema.cjs +1 -1
  15. package/dist/cjs/stores/route.cjs +1 -1
  16. package/dist/esm/components/loader/loader.js +19 -30
  17. package/dist/esm/components/loader/remote/loader.js +22 -24
  18. package/dist/esm/hooks/auth.js +26 -24
  19. package/dist/esm/hooks/data.js +272 -258
  20. package/dist/esm/hooks/export.js +12 -12
  21. package/dist/esm/hooks/exportCsv.js +16 -24
  22. package/dist/esm/hooks/form.js +48 -39
  23. package/dist/esm/hooks/formExtend.js +11 -9
  24. package/dist/esm/hooks/i18n.js +6 -2
  25. package/dist/esm/hooks/list.js +12 -12
  26. package/dist/esm/hooks/tree.js +20 -26
  27. package/dist/esm/preset/i18nProvider.js +14 -13
  28. package/dist/esm/provider/app.js +76 -77
  29. package/dist/esm/stores/jsonSchema.js +22 -26
  30. package/dist/esm/stores/route.js +26 -23
  31. package/dist/types/hooks/auth.d.ts +1 -1
  32. package/dist/types/hooks/export.d.ts +2 -3
  33. package/dist/types/hooks/form.d.ts +2 -2
  34. package/dist/types/hooks/formExtend.d.ts +1 -1
  35. package/dist/types/hooks/i18n.d.ts +1 -0
  36. package/dist/types/types/config.d.ts +0 -1
  37. package/dist/types/types/i18n.d.ts +1 -0
  38. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
- import { ref as h, computed as u } from "vue";
1
+ import { ref as h, computed as c } from "vue";
2
2
  import { useInfiniteList as w } from "./data.js";
3
3
  const y = (e) => new Promise((a) => setTimeout(a, e));
4
- function E(e) {
5
- const a = h(!1), r = u(() => {
6
- const { onSuccess: n, onProgress: i, interval: l, maxPage: s, ...f } = e;
4
+ function b(e) {
5
+ const a = h(!1), r = c(() => {
6
+ const { onSuccess: n, onProgress: i, interval: l, maxPage: u, ...f } = e;
7
7
  return {
8
8
  ...f,
9
9
  options: {
@@ -14,25 +14,25 @@ function E(e) {
14
14
  refetchOnReconnect: !1
15
15
  }
16
16
  };
17
- }), c = u(() => e.interval || 300), { data: o, isLoading: g, fetchNextPage: v, hasNextPage: m, refetch: P, pagination: t } = w(r.value), x = async () => {
17
+ }), o = c(() => e.interval || 300), { data: s, isLoading: g, fetchNextPage: v, hasNextPage: m, refetch: P, pagination: t } = w(r.value), x = async () => {
18
18
  var n, i, l;
19
19
  if (!a.value)
20
20
  try {
21
21
  a.value = !0, t.value.page = 1, (n = e.onProgress) == null || n.call(e, t.value), await P();
22
- const s = typeof e.maxPage == "function" ? e.maxPage() : e.maxPage || 100;
23
- for (; m.value && t.value.page < s; )
24
- c.value > 0 && await y(c.value), await v(), (i = e.onProgress) == null || i.call(e, t.value);
25
- (l = e.onSuccess) == null || l.call(e, o.value);
22
+ const u = typeof e.maxPage == "function" ? e.maxPage() : e.maxPage || 0;
23
+ for (; m.value && !(u > 0 && t.value.page >= u); )
24
+ o.value > 0 && await y(o.value), await v(), (i = e.onProgress) == null || i.call(e, t.value);
25
+ (l = e.onSuccess) == null || l.call(e, s.value);
26
26
  } finally {
27
27
  a.value = !1;
28
28
  }
29
- }, d = u(() => g.value || a.value);
29
+ }, d = c(() => g.value || a.value);
30
30
  return {
31
- data: o,
31
+ data: s,
32
32
  isLoading: d,
33
33
  trigger: x
34
34
  };
35
35
  }
36
36
  export {
37
- E as useExport
37
+ b as useExport
38
38
  };
@@ -1,37 +1,29 @@
1
1
  import { json2csv as v } from "json-2-csv";
2
- import { computed as u } from "vue";
3
- import { useExport as h } from "./export.js";
2
+ import { computed as s } from "vue";
3
+ import { useExport as f } from "./export.js";
4
4
  function b(e) {
5
- const d = u(() => {
6
- const { filename: t, headers: r, csvOptions: s, ...c } = e;
7
- return c;
8
- }), m = u(() => {
9
- const t = e.csvOptions || {}, r = t.quote;
5
+ const l = s(() => {
6
+ const { filename: t, headers: n, csvOptions: c, ...a } = e;
7
+ return a;
8
+ }), u = s(() => {
9
+ const t = e.csvOptions || {}, n = t.quote;
10
10
  return {
11
11
  prependHeader: e.headers !== !1,
12
12
  keys: Array.isArray(e.headers) ? e.headers : void 0,
13
13
  delimiter: {
14
14
  field: t.delimiter || ",",
15
- wrap: typeof r == "string" ? r : '"',
15
+ wrap: typeof n == "string" ? n : '"',
16
16
  eol: t.eol || `
17
17
  `
18
18
  },
19
19
  excelBOM: t.writeBOM || !1
20
20
  };
21
21
  });
22
- return h({
23
- ...d.value,
22
+ return f({
23
+ ...l.value,
24
24
  onSuccess: async (t) => {
25
- var s, c, a, i;
26
- if (!(t != null && t.pages)) {
27
- (s = e.onError) == null || s.call(e, {
28
- message: "No data to export",
29
- status: 400
30
- });
31
- return;
32
- }
33
- const r = t.pages.flatMap((n) => (n == null ? void 0 : n.data) || []);
34
- if (r.length === 0) {
25
+ var n, c, a, i;
26
+ if (!(t != null && t.data) || !((n = t == null ? void 0 : t.data) != null && n.length)) {
35
27
  (c = e.onError) == null || c.call(e, {
36
28
  message: "No data to export",
37
29
  status: 400
@@ -39,11 +31,11 @@ function b(e) {
39
31
  return;
40
32
  }
41
33
  try {
42
- const n = await v(r, m.value), f = new Blob([n], { type: "text/csv;charset=utf-8;" }), l = URL.createObjectURL(f), o = document.createElement("a");
43
- o.href = l, o.download = e.filename || "export.csv", o.style.display = "none", document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(l), (a = e.onSuccess) == null || a.call(e, t);
44
- } catch (n) {
34
+ const r = await v(t.data, u.value), m = new Blob([r], { type: "text/csv;charset=utf-8;" }), d = URL.createObjectURL(m), o = document.createElement("a");
35
+ o.href = d, o.download = e.filename || "export.csv", o.style.display = "none", document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(d), (a = e.onSuccess) == null || a.call(e, t);
36
+ } catch (r) {
45
37
  (i = e.onError) == null || i.call(e, {
46
- message: `CSV Export Error: ${n}`,
38
+ message: `CSV Export Error: ${r}`,
47
39
  status: 500
48
40
  });
49
41
  }
@@ -1,45 +1,54 @@
1
- import { cloneDeep as d } from "lodash-es";
2
- import { toRef as N, ref as b, computed as o, watch as E } from "vue";
1
+ import { cloneDeep as v } from "lodash-es";
2
+ import { toRef as m, ref as s, computed as f, watch as E } from "vue";
3
3
  import { useOne as L, useCreate as O, useUpdate as S } from "./data.js";
4
- function w(e) {
5
- const i = N(e, "form", {}), n = b(d(e.form || {})), c = o(() => e.action === "edit" || e.id), { data: v, isLoading: l, refetch: r } = L({
6
- path: e.path || "",
7
- id: e.id,
4
+ function x(e) {
5
+ const n = m(e, "form", {}), i = m(e, "id", void 0), c = s(v(n.value || {})), l = s(v(n.value || {})), u = f(() => e.action === "edit" || !!i.value), { data: g, isLoading: h, refetch: D } = L({
6
+ get path() {
7
+ return e.path || "";
8
+ },
9
+ get id() {
10
+ return i.value;
11
+ },
8
12
  options: {
9
- enabled: !!e.id
13
+ enabled: u.value
10
14
  },
11
15
  providerName: e.providerName
12
- });
13
- E([() => e.action, () => e.id], async () => {
16
+ }), d = () => {
17
+ let a = {};
18
+ u.value ? a = v(c.value) : a = v(l.value), Object.assign(n.value, a);
19
+ };
20
+ E([i, u], async () => {
14
21
  var t;
15
- if (!c.value)
22
+ if (!u.value) {
23
+ d();
16
24
  return;
17
- await r();
18
- const a = d(((t = v.value) == null ? void 0 : t.data) || {});
19
- Object.assign(i.value, a), Object.assign(n.value, a);
25
+ }
26
+ await D();
27
+ const a = v(((t = g.value) == null ? void 0 : t.data) || {});
28
+ Object.assign(n.value, a), Object.assign(c.value, a);
20
29
  }, {
21
- immediate: !0,
22
- deep: !0
30
+ immediate: !0
23
31
  });
24
- const f = () => {
25
- const a = d(n.value);
26
- Object.assign(i.value, a);
27
- }, u = O({
32
+ const o = O({
28
33
  path: e.path ?? "",
29
- data: i.value,
34
+ data: n.value,
30
35
  onSuccess: (a) => {
31
36
  var t;
32
- (t = e.onSuccess) == null || t.call(e, a);
37
+ d(), (t = e.onSuccess) == null || t.call(e, a);
33
38
  },
34
39
  onError: (a) => {
35
40
  var t;
36
41
  (t = e.onError) == null || t.call(e, a);
37
42
  },
38
43
  providerName: e.providerName
39
- }), m = S({
40
- path: e.path ?? "",
41
- id: e.id,
42
- data: i.value,
44
+ }), r = S({
45
+ get path() {
46
+ return e.path ?? "";
47
+ },
48
+ get id() {
49
+ return i.value;
50
+ },
51
+ data: n.value,
43
52
  onSuccess: (a) => {
44
53
  var t;
45
54
  (t = e.onSuccess) == null || t.call(e, a);
@@ -49,23 +58,23 @@ function w(e) {
49
58
  (t = e.onError) == null || t.call(e, a);
50
59
  },
51
60
  providerName: e.providerName
52
- }), g = (a) => {
53
- e.action === "create" ? u.mutate({
54
- data: a || i.value
55
- }) : m.mutate({
56
- id: e.id,
57
- data: a || i.value
61
+ }), N = (a) => {
62
+ u.value ? r.mutate({
63
+ id: i.value,
64
+ data: a || n.value
65
+ }) : o.mutate({
66
+ data: a || n.value
58
67
  });
59
- }, h = o(() => l.value || u.isLoading.value || m.isLoading.value);
68
+ }, b = f(() => h.value || o.isLoading.value || r.isLoading.value);
60
69
  return {
61
- form: i,
62
- initData: n,
63
- isLoading: h,
64
- isEdit: c,
65
- onSubmit: g,
66
- onReset: f
70
+ form: n,
71
+ initData: u.value ? c.value : l.value,
72
+ isLoading: b,
73
+ isEdit: u,
74
+ onSubmit: N,
75
+ onReset: d
67
76
  };
68
77
  }
69
78
  export {
70
- w as useForm
79
+ x as useForm
71
80
  };
@@ -1,17 +1,19 @@
1
1
  import { toRef as d, computed as c } from "vue";
2
2
  import { useForm as l } from "./form.js";
3
- import { useValidateForm as E } from "./formValidate.js";
3
+ import { useValidateForm as v } from "./formValidate.js";
4
4
  function F(t) {
5
- const n = d(t, "form", {}), { validate: m, reset: s } = E({
6
- data: n,
5
+ const o = d(t, "form", {}), { validate: m, reset: s } = v({
6
+ data: o,
7
7
  rules: t.rules
8
8
  }), u = c(() => {
9
- const { form: o, ...r } = t;
9
+ const { form: n, ...r } = t;
10
10
  return {
11
- ...r,
12
- form: o
11
+ ...r
13
12
  };
14
- }), e = l(u.value), a = (o) => {
13
+ }), e = l({
14
+ ...u.value,
15
+ form: o.value
16
+ }), a = (n) => {
15
17
  m().then((r) => {
16
18
  var i;
17
19
  if (!r.valid) {
@@ -20,7 +22,7 @@ function F(t) {
20
22
  });
21
23
  return;
22
24
  }
23
- e.onSubmit(o);
25
+ e.onSubmit(n);
24
26
  });
25
27
  }, f = () => {
26
28
  e.onReset(), s();
@@ -28,7 +30,7 @@ function F(t) {
28
30
  return {
29
31
  isLoading: e.isLoading,
30
32
  isEdit: e.isEdit,
31
- form: n,
33
+ form: o,
32
34
  onSubmit: a,
33
35
  onReset: f
34
36
  };
@@ -3,7 +3,7 @@ import "vue";
3
3
  import { useI18nStore as i } from "../stores/i18n.js";
4
4
  import "lodash-es";
5
5
  import { useManage as g } from "./manage.js";
6
- function h() {
6
+ function I() {
7
7
  const a = i(), c = g();
8
8
  return {
9
9
  t: (e, o, r) => {
@@ -25,9 +25,13 @@ function h() {
25
25
  mergeLocale: (e, o) => {
26
26
  var r, n;
27
27
  return (n = (r = c.config) == null ? void 0 : r.i18nProvider) == null ? void 0 : n.mergeLocale(e, o);
28
+ },
29
+ getLocales: () => {
30
+ var e, o;
31
+ return (o = (e = c.config) == null ? void 0 : e.i18nProvider) == null ? void 0 : o.getLocales();
28
32
  }
29
33
  };
30
34
  }
31
35
  export {
32
- h as useI18n
36
+ I as useI18n
33
37
  };
@@ -1,5 +1,5 @@
1
1
  import { reactiveComputed as V, useCountdown as W } from "@vueuse/core";
2
- import { toRef as f, ref as r, watch as P, computed as o } from "vue";
2
+ import { toRef as f, ref as v, watch as P, computed as o } from "vue";
3
3
  import { useList as X } from "./data.js";
4
4
  import { useExportCsv as I } from "./exportCsv.js";
5
5
  import { useImportCsv as Y } from "./importCsv.js";
@@ -9,7 +9,7 @@ function ae(t) {
9
9
  pageSize: 20
10
10
  }), h = [10, 20, 30, 40, 50, 100], x = (e) => h.includes(e) ? h : Array.from({
11
11
  length: 5
12
- }, (a, u) => e * (u + 1)), s = r(x(l.value.pageSize));
12
+ }, (a, u) => e * (u + 1)), s = v(x(l.value.pageSize));
13
13
  P(() => l.value.pageSize, (e) => {
14
14
  s.value.includes(e) || (s.value = x(e));
15
15
  });
@@ -39,7 +39,7 @@ function ae(t) {
39
39
  c.value = e;
40
40
  }, y = (e) => {
41
41
  g.value = e;
42
- }, n = r([]), z = o(() => {
42
+ }, n = v([]), C = o(() => {
43
43
  var e, a;
44
44
  return n.value.length > 0 && n.value.length === ((a = (e = i.value) == null ? void 0 : e.data) == null ? void 0 : a.length);
45
45
  }), M = o(() => {
@@ -52,7 +52,7 @@ function ae(t) {
52
52
  n.value = e;
53
53
  }, O = (e) => n.value.includes(e), _ = () => {
54
54
  var e, a;
55
- z.value ? n.value = [] : n.value = ((a = (e = i.value) == null ? void 0 : e.data) == null ? void 0 : a.map((u) => u[t.key || "id"]).filter((u) => u != null)) || [];
55
+ C.value ? n.value = [] : n.value = ((a = (e = i.value) == null ? void 0 : e.data) == null ? void 0 : a.map((u) => u[t.key || "id"]).filter((u) => u != null)) || [];
56
56
  };
57
57
  P(() => {
58
58
  var e;
@@ -62,7 +62,7 @@ function ae(t) {
62
62
  });
63
63
  const d = () => {
64
64
  n.value = [], w();
65
- }, m = r({
65
+ }, m = v({
66
66
  page: 1,
67
67
  pageSize: 100
68
68
  }), {
@@ -72,7 +72,7 @@ function ae(t) {
72
72
  path: t.path,
73
73
  filters: c.value || {},
74
74
  sorters: g.value || {},
75
- maxPage: () => l.value.pageSize || t.exportMaxPage || 10,
75
+ maxPage: () => t.exportMaxPage || 0,
76
76
  pagination: m.value,
77
77
  filename: t.exportFilename || "data.csv",
78
78
  onSuccess: (e) => {
@@ -122,16 +122,16 @@ function ae(t) {
122
122
  var a;
123
123
  (a = t.onImportError) == null || a.call(t, e);
124
124
  }
125
- }), v = r(!1), {
125
+ }), r = v(!1), {
126
126
  remaining: N,
127
- start: C,
127
+ start: z,
128
128
  stop: Q
129
129
  } = W(10, {
130
130
  onComplete: () => {
131
- d(), C();
131
+ d(), z();
132
132
  }
133
133
  }), T = () => {
134
- v.value = !v.value, v.value ? (d(), C()) : Q();
134
+ r.value = !r.value, r.value ? (d(), z()) : Q();
135
135
  };
136
136
  return {
137
137
  // 数据
@@ -146,7 +146,7 @@ function ae(t) {
146
146
  onUpdateSorters: y,
147
147
  // 选中
148
148
  checkeds: n,
149
- isAllChecked: z,
149
+ isAllChecked: C,
150
150
  isIndeterminate: M,
151
151
  toggleChecked: b,
152
152
  isChecked: O,
@@ -169,7 +169,7 @@ function ae(t) {
169
169
  onImport: J,
170
170
  isImporting: K,
171
171
  // 自动刷新
172
- autoRefetch: v,
172
+ autoRefetch: r,
173
173
  onAutoRefetch: T,
174
174
  autoCountdown: N
175
175
  };
@@ -1,42 +1,36 @@
1
- import { computed as a } from "vue";
1
+ import { toRef as o, computed as a } from "vue";
2
2
  import "../utils/bus.js";
3
- import { arrayToTree as m, treeToArr as y } from "../utils/tree.js";
4
- import { useList as p } from "./data.js";
5
- function T(e) {
6
- const { data: o, isLoading: c } = p({
7
- get path() {
8
- return e.path || "";
9
- },
10
- get filters() {
11
- return e.params;
12
- },
13
- get providerName() {
14
- return e.providerName;
15
- }
16
- }), d = a(() => {
17
- var r, n, i, t, l, s;
18
- return e.converTree ? m(((n = o.value) == null ? void 0 : n.data) || [], {
3
+ import { arrayToTree as K, treeToArr as f } from "../utils/tree.js";
4
+ import { useList as O } from "./data.js";
5
+ function D(e) {
6
+ const u = o(e, "path"), m = o(e, "params"), h = o(e, "providerName"), { data: d, isLoading: v } = O({
7
+ path: u.value || "",
8
+ filters: m.value,
9
+ providerName: h.value
10
+ }), s = a(() => {
11
+ var r, n, i, t, l, c;
12
+ return e.converTree ? K(((n = d.value) == null ? void 0 : n.data) || [], {
19
13
  idKey: ((i = e.treeOptions) == null ? void 0 : i.valueKey) || "id",
20
14
  parentKey: ((t = e.treeOptions) == null ? void 0 : t.parentKey) || "parent_id",
21
15
  sortKey: ((l = e.treeOptions) == null ? void 0 : l.sortKey) || "sort",
22
- childrenKey: ((s = e.treeOptions) == null ? void 0 : s.childrenKey) || "children"
23
- }) : ((r = o.value) == null ? void 0 : r.data) || [];
24
- }), u = a(() => {
16
+ childrenKey: ((c = e.treeOptions) == null ? void 0 : c.childrenKey) || "children"
17
+ }) : ((r = d.value) == null ? void 0 : r.data) || [];
18
+ }), p = a(() => {
25
19
  var r, n;
26
- return y(d.value, ((r = e.treeOptions) == null ? void 0 : r.valueKey) || "id", ((n = e.treeOptions) == null ? void 0 : n.childrenKey) || "children");
27
- }), h = a(() => c.value);
20
+ return f(s.value, ((r = e.treeOptions) == null ? void 0 : r.valueKey) || "id", ((n = e.treeOptions) == null ? void 0 : n.childrenKey) || "children");
21
+ }), y = a(() => v.value);
28
22
  return {
29
23
  options: a(() => {
30
24
  const r = (n) => n.map((i) => {
31
25
  const t = { ...i };
32
26
  return Array.isArray(t.children) && (t.children.length === 0 ? delete t.children : t.children = r(t.children)), t;
33
27
  });
34
- return r(d.value || []);
28
+ return r(s.value || []);
35
29
  }),
36
- loading: h,
37
- expanded: u
30
+ loading: y,
31
+ expanded: p
38
32
  };
39
33
  }
40
34
  export {
41
- T as useTree
35
+ D as useTree
42
36
  };
@@ -1,6 +1,6 @@
1
1
  import { createI18n as o } from "vue-i18n";
2
- function i(l) {
3
- const n = o({
2
+ function r(l) {
3
+ const a = o({
4
4
  legacy: !1,
5
5
  locale: l == null ? void 0 : l.locale,
6
6
  fallbackLocale: l == null ? void 0 : l.fallbackLocale,
@@ -9,22 +9,23 @@ function i(l) {
9
9
  fallbackWarn: !1
10
10
  });
11
11
  return {
12
- t: (e, a, c) => {
13
- const t = n.global.t(e, a);
14
- return t === e && c ? c : t;
12
+ t: (e, c, n) => {
13
+ const t = a.global.t(e, c);
14
+ return t === e && n ? n : t;
15
15
  },
16
- changeLocale: (e, a) => new Promise((c) => {
17
- n.global.locale.value = e, c(e);
16
+ changeLocale: (e, c) => new Promise((n) => {
17
+ a.global.locale.value = e, n(e);
18
18
  }),
19
- loadLocale: (e, a) => new Promise((c) => {
20
- n.global.setLocaleMessage(e, a), c(e);
19
+ loadLocale: (e, c) => new Promise((n) => {
20
+ a.global.setLocaleMessage(e, c), n(e);
21
21
  }),
22
- mergeLocale: (e, a) => {
23
- n.global.mergeLocaleMessage(e, a);
22
+ mergeLocale: (e, c) => {
23
+ a.global.mergeLocaleMessage(e, c);
24
24
  },
25
- getLocale: () => n.global.locale.value
25
+ getLocale: () => a.global.locale.value,
26
+ getLocales: () => a.global.availableLocales.map((e) => e)
26
27
  };
27
28
  }
28
29
  export {
29
- i as i18nProvider
30
+ r as i18nProvider
30
31
  };