@duxweb/dvha-core 1.0.22 → 1.0.24
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/cjs/components/auth/can.cjs +1 -1
- package/dist/cjs/components/loader/iframe.cjs +1 -1
- package/dist/cjs/components/loader/remote/loader.cjs +1 -1
- package/dist/cjs/components/loader/remote/render.cjs +1 -1
- package/dist/cjs/components/overlay/overlay.cjs +1 -1
- package/dist/cjs/components/status/exception.cjs +1 -1
- package/dist/cjs/directive/permission.cjs +1 -1
- package/dist/cjs/hooks/auth.cjs +1 -1
- package/dist/cjs/hooks/data.cjs +1 -1
- package/dist/cjs/hooks/export.cjs +1 -1
- package/dist/cjs/hooks/exportCsv.cjs +2 -2
- package/dist/cjs/hooks/form.cjs +1 -1
- package/dist/cjs/hooks/formExtend.cjs +1 -1
- package/dist/cjs/hooks/i18n.cjs +1 -1
- package/dist/cjs/hooks/import.cjs +1 -1
- package/dist/cjs/hooks/importCsv.cjs +2 -2
- package/dist/cjs/hooks/json/utils/expressionParser.cjs +1 -1
- package/dist/cjs/hooks/json/vFor.cjs +1 -1
- package/dist/cjs/hooks/json/vOn.cjs +1 -1
- package/dist/cjs/hooks/json/vShow.cjs +1 -1
- package/dist/cjs/hooks/json.cjs +1 -1
- package/dist/cjs/hooks/list.cjs +1 -1
- package/dist/cjs/hooks/manage.cjs +1 -1
- package/dist/cjs/hooks/menu.cjs +1 -1
- package/dist/cjs/hooks/select.cjs +1 -1
- package/dist/cjs/hooks/theme.cjs +3 -3
- package/dist/cjs/hooks/tree.cjs +1 -1
- package/dist/cjs/hooks/upload/s3.cjs +1 -1
- package/dist/cjs/hooks/upload.cjs +1 -1
- package/dist/cjs/preset/authProvider.cjs +1 -1
- package/dist/cjs/preset/dataProvider.cjs +1 -1
- package/dist/cjs/preset/i18nProvider.cjs +1 -1
- package/dist/cjs/provider/app.cjs +1 -1
- package/dist/cjs/router/route.cjs +1 -1
- package/dist/cjs/stores/auth.cjs +1 -1
- package/dist/cjs/stores/i18n.cjs +1 -1
- package/dist/cjs/stores/jsonSchema.cjs +1 -1
- package/dist/cjs/stores/manage.cjs +1 -1
- package/dist/cjs/stores/route.cjs +1 -1
- package/dist/cjs/stores/tab.cjs +1 -1
- package/dist/cjs/stores/theme.cjs +1 -1
- package/dist/cjs/utils/tree.cjs +1 -1
- package/dist/esm/components/auth/can.js +8 -11
- package/dist/esm/components/loader/iframe.js +14 -17
- package/dist/esm/components/loader/remote/loader.js +103 -105
- package/dist/esm/components/loader/remote/render.js +10 -11
- package/dist/esm/components/overlay/overlay.js +7 -7
- package/dist/esm/components/status/exception.js +10 -13
- package/dist/esm/directive/permission.js +6 -7
- package/dist/esm/hooks/auth.js +73 -83
- package/dist/esm/hooks/data.js +290 -345
- package/dist/esm/hooks/export.js +16 -17
- package/dist/esm/hooks/exportCsv.js +26 -27
- package/dist/esm/hooks/form.js +49 -54
- package/dist/esm/hooks/formExtend.js +24 -25
- package/dist/esm/hooks/i18n.js +11 -29
- package/dist/esm/hooks/import.js +31 -32
- package/dist/esm/hooks/importCsv.js +24 -25
- package/dist/esm/hooks/json/utils/expressionParser.js +36 -42
- package/dist/esm/hooks/json/vFor.js +15 -16
- package/dist/esm/hooks/json/vOn.js +17 -18
- package/dist/esm/hooks/json/vShow.js +9 -10
- package/dist/esm/hooks/json.js +88 -94
- package/dist/esm/hooks/list.js +100 -127
- package/dist/esm/hooks/manage.js +13 -17
- package/dist/esm/hooks/menu.js +39 -52
- package/dist/esm/hooks/select.js +35 -40
- package/dist/esm/hooks/theme.js +127 -141
- package/dist/esm/hooks/tree.js +22 -28
- package/dist/esm/hooks/upload/s3.js +22 -23
- package/dist/esm/hooks/upload.js +152 -159
- package/dist/esm/preset/authProvider.js +63 -117
- package/dist/esm/preset/dataProvider.js +69 -76
- package/dist/esm/preset/i18nProvider.js +18 -18
- package/dist/esm/provider/app.js +74 -81
- package/dist/esm/router/route.js +16 -24
- package/dist/esm/stores/auth.js +17 -20
- package/dist/esm/stores/i18n.js +10 -10
- package/dist/esm/stores/jsonSchema.js +20 -23
- package/dist/esm/stores/manage.js +33 -33
- package/dist/esm/stores/route.js +38 -50
- package/dist/esm/stores/tab.js +38 -54
- package/dist/esm/stores/theme.js +28 -29
- package/dist/esm/utils/tree.js +23 -24
- package/package.json +1 -1
package/dist/esm/hooks/theme.js
CHANGED
|
@@ -1,47 +1,43 @@
|
|
|
1
|
-
import { useColorMode as
|
|
2
|
-
import { hex2rgb as
|
|
3
|
-
import { storeToRefs as
|
|
4
|
-
import { watchEffect as
|
|
5
|
-
import { themeColor as
|
|
1
|
+
import { useColorMode as H, useCycleList as J } from "@vueuse/core";
|
|
2
|
+
import { hex2rgb as K } from "colorizr";
|
|
3
|
+
import { storeToRefs as P } from "pinia";
|
|
4
|
+
import { watchEffect as Q, computed as f, watch as W, readonly as j } from "vue";
|
|
5
|
+
import { themeColor as X } from "../config/color.js";
|
|
6
6
|
import "lodash-es";
|
|
7
|
-
import { useThemeStore as
|
|
8
|
-
import { useManage as
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
initialValue: C.store.value
|
|
7
|
+
import { useThemeStore as Y } from "../stores/theme.js";
|
|
8
|
+
import { useManage as Z } from "./manage.js";
|
|
9
|
+
function ie() {
|
|
10
|
+
const s = Y(), { mode: B } = P(s), $ = H({
|
|
11
|
+
storageRef: B
|
|
12
|
+
}), b = Z(), { state: S, next: V, go: v } = J(["dark", "light", "auto"], {
|
|
13
|
+
initialValue: $.store.value
|
|
15
14
|
});
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
Q(() => {
|
|
16
|
+
$.value = S.value;
|
|
18
17
|
});
|
|
19
|
-
const
|
|
18
|
+
const M = (t) => {
|
|
20
19
|
switch (t) {
|
|
21
20
|
case "auto":
|
|
22
|
-
|
|
21
|
+
v(2);
|
|
23
22
|
break;
|
|
24
23
|
case "light":
|
|
25
|
-
|
|
24
|
+
v(1);
|
|
26
25
|
break;
|
|
27
26
|
case "dark":
|
|
28
|
-
|
|
27
|
+
v(0);
|
|
29
28
|
break;
|
|
30
29
|
}
|
|
31
|
-
},
|
|
32
|
-
const { system: t, store: e } =
|
|
30
|
+
}, u = f(() => {
|
|
31
|
+
const { system: t, store: e } = $;
|
|
33
32
|
return e.value === "auto" ? t.value === "dark" : e.value === "dark";
|
|
34
|
-
}),
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
-
}), n = { ...{
|
|
44
|
-
colors: N,
|
|
33
|
+
}), y = f(() => u.value ? {
|
|
34
|
+
logo: b.config?.theme?.darkLogo,
|
|
35
|
+
banner: b.config?.theme?.darkBanner
|
|
36
|
+
} : {
|
|
37
|
+
logo: b.config?.theme?.logo,
|
|
38
|
+
banner: b.config?.theme?.banner
|
|
39
|
+
}), r = { ...{
|
|
40
|
+
colors: X,
|
|
45
41
|
// 色彩类型
|
|
46
42
|
colorTypes: ["primary", "info", "success", "warning", "error", "gray"],
|
|
47
43
|
// 色彩色阶
|
|
@@ -69,164 +65,154 @@ function de() {
|
|
|
69
65
|
}
|
|
70
66
|
},
|
|
71
67
|
colorBase: { white: "#ffffff", black: "#000000" }
|
|
72
|
-
}, ...
|
|
73
|
-
function
|
|
74
|
-
return
|
|
68
|
+
}, ...b.config?.theme?.config }, { colorShades: C, colorTypes: x } = r, d = f(() => s.theme), h = f(() => Object.keys(r.colors)), k = ["default", "hover", "pressed", "focus", "disabled"];
|
|
69
|
+
function I() {
|
|
70
|
+
return u.value ? r.colorScenes.dark : r.colorScenes.light;
|
|
75
71
|
}
|
|
76
|
-
function
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return r;
|
|
72
|
+
function w(t, e) {
|
|
73
|
+
const o = I(), l = o.default;
|
|
74
|
+
if (o.overrides?.[t]) {
|
|
75
|
+
const i = o.overrides[t]?.[e];
|
|
76
|
+
if (i)
|
|
77
|
+
return i;
|
|
83
78
|
}
|
|
84
|
-
return
|
|
79
|
+
return l[e] || "500";
|
|
85
80
|
}
|
|
86
|
-
function
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return ((c = n.colors[o]) == null ? void 0 : c[e]) || "";
|
|
81
|
+
function T(t, e) {
|
|
82
|
+
const o = d.value[t];
|
|
83
|
+
return r.colors[o]?.[e] || "";
|
|
90
84
|
}
|
|
91
|
-
function
|
|
92
|
-
const
|
|
93
|
-
return
|
|
85
|
+
function n(t, e, o) {
|
|
86
|
+
const c = (u.value ? r.colorSemantic.dark : r.colorSemantic.light)[t][e];
|
|
87
|
+
return c === "white" || c === "black" ? `var(--ui-color-${c})` : `var(--base-color-${o}-${c})`;
|
|
94
88
|
}
|
|
95
|
-
const
|
|
96
|
-
const e =
|
|
89
|
+
const p = (t) => {
|
|
90
|
+
const e = K(t);
|
|
97
91
|
return `${e.r} ${e.g} ${e.b}`;
|
|
98
92
|
};
|
|
99
|
-
function
|
|
100
|
-
var i, l;
|
|
93
|
+
function L() {
|
|
101
94
|
const t = [];
|
|
102
|
-
Object.entries(
|
|
103
|
-
typeof
|
|
95
|
+
Object.entries(r.colors).forEach(([c, i]) => {
|
|
96
|
+
typeof i == "object" && Object.entries(i).forEach(([a, g]) => {
|
|
104
97
|
try {
|
|
105
|
-
t.push(`--base-color-${
|
|
98
|
+
t.push(`--base-color-${c}-${a}: ${p(g)};`);
|
|
106
99
|
} catch {
|
|
107
|
-
t.push(`--base-color-${
|
|
100
|
+
t.push(`--base-color-${c}-${a}: ${g};`);
|
|
108
101
|
}
|
|
109
102
|
});
|
|
110
103
|
});
|
|
111
104
|
const e = [];
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
e.push(`--ui-color-${
|
|
116
|
-
}),
|
|
117
|
-
const
|
|
118
|
-
|
|
105
|
+
x.forEach((c) => {
|
|
106
|
+
const i = d.value[c];
|
|
107
|
+
C.forEach((a) => {
|
|
108
|
+
e.push(`--ui-color-${c}-${a}: var(--base-color-${i}-${a});`);
|
|
109
|
+
}), k.forEach((a) => {
|
|
110
|
+
const g = w(c, a);
|
|
111
|
+
a === "default" ? e.push(`--ui-color-${c}: var(--base-color-${i}-${g});`) : e.push(`--ui-color-${c}-${a}: var(--base-color-${i}-${g});`);
|
|
119
112
|
});
|
|
120
113
|
});
|
|
121
|
-
const o =
|
|
122
|
-
`--ui-color-white: ${
|
|
123
|
-
`--ui-color-black: ${
|
|
124
|
-
`--ui-text-dimmed: ${
|
|
125
|
-
`--ui-text-muted: ${
|
|
126
|
-
`--ui-text-toned: ${
|
|
127
|
-
`--ui-text: ${
|
|
128
|
-
`--ui-text-highlighted: ${
|
|
129
|
-
`--ui-text-inverted: ${
|
|
130
|
-
`--ui-bg: ${
|
|
131
|
-
`--ui-bg-muted: ${
|
|
132
|
-
`--ui-bg-elevated: ${
|
|
133
|
-
`--ui-bg-accented: ${
|
|
134
|
-
`--ui-bg-inverted: ${
|
|
135
|
-
`--ui-border: ${
|
|
136
|
-
`--ui-border-muted: ${
|
|
137
|
-
`--ui-border-accented: ${
|
|
138
|
-
`--ui-border-inverted: ${
|
|
114
|
+
const o = d.value.gray, l = [
|
|
115
|
+
`--ui-color-white: ${p(r.colorBase?.white || "#ffffff")};`,
|
|
116
|
+
`--ui-color-black: ${p(r.colorBase?.black || "#000000")};`,
|
|
117
|
+
`--ui-text-dimmed: ${n("text", "dimmed", o)};`,
|
|
118
|
+
`--ui-text-muted: ${n("text", "muted", o)};`,
|
|
119
|
+
`--ui-text-toned: ${n("text", "toned", o)};`,
|
|
120
|
+
`--ui-text: ${n("text", "base", o)};`,
|
|
121
|
+
`--ui-text-highlighted: ${n("text", "highlighted", o)};`,
|
|
122
|
+
`--ui-text-inverted: ${n("text", "inverted", o)};`,
|
|
123
|
+
`--ui-bg: ${n("bg", "base", o)};`,
|
|
124
|
+
`--ui-bg-muted: ${n("bg", "muted", o)};`,
|
|
125
|
+
`--ui-bg-elevated: ${n("bg", "elevated", o)};`,
|
|
126
|
+
`--ui-bg-accented: ${n("bg", "accented", o)};`,
|
|
127
|
+
`--ui-bg-inverted: ${n("bg", "inverted", o)};`,
|
|
128
|
+
`--ui-border: ${n("border", "base", o)};`,
|
|
129
|
+
`--ui-border-muted: ${n("border", "muted", o)};`,
|
|
130
|
+
`--ui-border-accented: ${n("border", "accented", o)};`,
|
|
131
|
+
`--ui-border-inverted: ${n("border", "inverted", o)};`
|
|
139
132
|
];
|
|
140
133
|
return `:root {
|
|
141
134
|
${t.join(`
|
|
142
135
|
`)}
|
|
143
136
|
${e.join(`
|
|
144
137
|
`)}
|
|
145
|
-
${
|
|
138
|
+
${l.join(`
|
|
146
139
|
`)}
|
|
147
140
|
}`;
|
|
148
141
|
}
|
|
149
|
-
let
|
|
150
|
-
function
|
|
151
|
-
const t =
|
|
152
|
-
|
|
142
|
+
let m = null;
|
|
143
|
+
function E() {
|
|
144
|
+
const t = L();
|
|
145
|
+
m || (m = document.createElement("style"), m.id = "dvha-variables", document.head.appendChild(m)), m.textContent = t;
|
|
153
146
|
}
|
|
154
|
-
function
|
|
155
|
-
|
|
147
|
+
function O() {
|
|
148
|
+
s.cssInit || (s.setCssInit(), E());
|
|
156
149
|
}
|
|
157
|
-
|
|
158
|
-
|
|
150
|
+
W([d, u], () => {
|
|
151
|
+
s.cssInit && E();
|
|
159
152
|
}, { deep: !0, immediate: !1 });
|
|
160
|
-
function
|
|
161
|
-
|
|
153
|
+
function R(t, e) {
|
|
154
|
+
h.value.includes(e) ? s.setThemeColor(t, e) : console.warn(`Color "${e}" is not available`);
|
|
162
155
|
}
|
|
163
|
-
function
|
|
164
|
-
|
|
156
|
+
function z(t) {
|
|
157
|
+
s.setThemeColors(t);
|
|
165
158
|
}
|
|
166
|
-
function
|
|
167
|
-
|
|
159
|
+
function D() {
|
|
160
|
+
s.resetTheme();
|
|
168
161
|
}
|
|
169
|
-
function
|
|
170
|
-
return o ? `--ui-color-${t}-${e}` :
|
|
162
|
+
function G(t, e, o = !1) {
|
|
163
|
+
return o ? `--ui-color-${t}-${e}` : T(t, e);
|
|
171
164
|
}
|
|
172
|
-
function
|
|
165
|
+
function U(t, e, o = !1) {
|
|
173
166
|
if (e || (e = "default"), o)
|
|
174
167
|
return e === "default" ? `--ui-color-${t})` : `--ui-color-${t}-${e})`;
|
|
175
|
-
const
|
|
176
|
-
return
|
|
168
|
+
const l = w(t, e);
|
|
169
|
+
return T(t, l);
|
|
177
170
|
}
|
|
178
|
-
function
|
|
179
|
-
var r, s, u;
|
|
171
|
+
function q(t, e, o = !1) {
|
|
180
172
|
if (o) {
|
|
181
|
-
let
|
|
173
|
+
let a;
|
|
182
174
|
switch (t) {
|
|
183
175
|
case "text":
|
|
184
|
-
|
|
176
|
+
a = e === "base" ? "--ui-text" : `--ui-text-${e}`;
|
|
185
177
|
break;
|
|
186
178
|
case "bg":
|
|
187
|
-
|
|
179
|
+
a = e === "base" ? "--ui-bg" : `--ui-bg-${e}`;
|
|
188
180
|
break;
|
|
189
181
|
case "border":
|
|
190
|
-
|
|
182
|
+
a = e === "base" ? "--ui-border" : `--ui-border-${e}`;
|
|
191
183
|
break;
|
|
192
184
|
default:
|
|
193
|
-
|
|
185
|
+
a = `--ui-${t}-${e}`;
|
|
194
186
|
}
|
|
195
|
-
return `${
|
|
187
|
+
return `${a}`;
|
|
196
188
|
}
|
|
197
|
-
const
|
|
198
|
-
return
|
|
189
|
+
const l = d.value.gray, i = (u.value ? r.colorSemantic.dark : r.colorSemantic.light)[t][e];
|
|
190
|
+
return i === "white" ? r.colorBase?.white || "#ffffff" : i === "black" ? r.colorBase?.black || "#000000" : r.colors[l]?.[i] || "";
|
|
199
191
|
}
|
|
200
|
-
const
|
|
201
|
-
var t;
|
|
202
|
-
return (t = v.value) == null ? void 0 : t.filter((e) => ["slate", "gray", "zinc", "neutral", "stone"].includes(e));
|
|
203
|
-
}), P = g(() => {
|
|
204
|
-
var t;
|
|
205
|
-
return (t = v.value) == null ? void 0 : t.filter((e) => !["slate", "gray", "zinc", "neutral", "stone"].includes(e));
|
|
206
|
-
});
|
|
192
|
+
const A = f(() => h.value?.filter((t) => ["slate", "gray", "zinc", "neutral", "stone"].includes(t))), F = f(() => h.value?.filter((t) => !["slate", "gray", "zinc", "neutral", "stone"].includes(t)));
|
|
207
193
|
return {
|
|
208
|
-
toggle:
|
|
209
|
-
mode:
|
|
210
|
-
setMode:
|
|
211
|
-
isDark:
|
|
212
|
-
resources:
|
|
213
|
-
config:
|
|
214
|
-
colorMapping:
|
|
215
|
-
colors:
|
|
216
|
-
neutralColors:
|
|
217
|
-
primaryColors:
|
|
218
|
-
colorShades:
|
|
219
|
-
colorTypes:
|
|
220
|
-
colorScenes:
|
|
221
|
-
cssInit:
|
|
222
|
-
cssReset:
|
|
223
|
-
setColor:
|
|
224
|
-
setColors:
|
|
225
|
-
getSceneColor:
|
|
226
|
-
getShadeColor:
|
|
227
|
-
getSemanticColor:
|
|
194
|
+
toggle: V,
|
|
195
|
+
mode: S,
|
|
196
|
+
setMode: M,
|
|
197
|
+
isDark: u,
|
|
198
|
+
resources: y,
|
|
199
|
+
config: j(r),
|
|
200
|
+
colorMapping: j(d),
|
|
201
|
+
colors: h,
|
|
202
|
+
neutralColors: A,
|
|
203
|
+
primaryColors: F,
|
|
204
|
+
colorShades: C,
|
|
205
|
+
colorTypes: x,
|
|
206
|
+
colorScenes: k,
|
|
207
|
+
cssInit: O,
|
|
208
|
+
cssReset: D,
|
|
209
|
+
setColor: R,
|
|
210
|
+
setColors: z,
|
|
211
|
+
getSceneColor: U,
|
|
212
|
+
getShadeColor: G,
|
|
213
|
+
getSemanticColor: q
|
|
228
214
|
};
|
|
229
215
|
}
|
|
230
216
|
export {
|
|
231
|
-
|
|
217
|
+
ie as useTheme
|
|
232
218
|
};
|
package/dist/esm/hooks/tree.js
CHANGED
|
@@ -1,36 +1,30 @@
|
|
|
1
|
-
import { toRef as
|
|
1
|
+
import { toRef as n, computed as r } from "vue";
|
|
2
2
|
import "../utils/bus.js";
|
|
3
|
-
import { arrayToTree as
|
|
4
|
-
import { useList as
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
-
path:
|
|
8
|
-
filters:
|
|
9
|
-
providerName:
|
|
10
|
-
}),
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
childrenKey: ((c = e.treeOptions) == null ? void 0 : c.childrenKey) || "children"
|
|
17
|
-
}) : ((r = d.value) == null ? void 0 : r.data) || [];
|
|
18
|
-
}), p = a(() => {
|
|
19
|
-
var r, n;
|
|
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);
|
|
3
|
+
import { arrayToTree as p, treeToArr as y } from "../utils/tree.js";
|
|
4
|
+
import { useList as K } from "./data.js";
|
|
5
|
+
function N(e) {
|
|
6
|
+
const d = n(e, "path"), s = n(e, "params"), l = n(e, "providerName"), { data: i, isLoading: c } = K({
|
|
7
|
+
path: d.value || "",
|
|
8
|
+
filters: s.value,
|
|
9
|
+
providerName: l.value
|
|
10
|
+
}), a = r(() => e.converTree ? p(i.value?.data || [], {
|
|
11
|
+
idKey: e.treeOptions?.valueKey || "id",
|
|
12
|
+
parentKey: e.treeOptions?.parentKey || "parent_id",
|
|
13
|
+
sortKey: e.treeOptions?.sortKey || "sort",
|
|
14
|
+
childrenKey: e.treeOptions?.childrenKey || "children"
|
|
15
|
+
}) : i.value?.data || []), u = r(() => y(a.value, e.treeOptions?.valueKey || "id", e.treeOptions?.childrenKey || "children")), m = r(() => c.value);
|
|
22
16
|
return {
|
|
23
|
-
options:
|
|
24
|
-
const
|
|
25
|
-
const t = { ...
|
|
26
|
-
return Array.isArray(t.children) && (t.children.length === 0 ? delete t.children : t.children =
|
|
17
|
+
options: r(() => {
|
|
18
|
+
const o = (h) => h.map((v) => {
|
|
19
|
+
const t = { ...v };
|
|
20
|
+
return Array.isArray(t.children) && (t.children.length === 0 ? delete t.children : t.children = o(t.children)), t;
|
|
27
21
|
});
|
|
28
|
-
return
|
|
22
|
+
return o(a.value || []);
|
|
29
23
|
}),
|
|
30
|
-
loading:
|
|
31
|
-
expanded:
|
|
24
|
+
loading: m,
|
|
25
|
+
expanded: u
|
|
32
26
|
};
|
|
33
27
|
}
|
|
34
28
|
export {
|
|
35
|
-
|
|
29
|
+
N as useTree
|
|
36
30
|
};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { useClient as
|
|
2
|
-
import
|
|
3
|
-
function
|
|
4
|
-
const
|
|
1
|
+
import { useClient as c } from "../data.js";
|
|
2
|
+
import U from "axios";
|
|
3
|
+
function w(n) {
|
|
4
|
+
const i = c();
|
|
5
5
|
return {
|
|
6
6
|
async upload(a, t) {
|
|
7
|
-
|
|
8
|
-
const o = await h.request({
|
|
7
|
+
const o = await i.request({
|
|
9
8
|
method: "GET",
|
|
10
|
-
path:
|
|
9
|
+
path: n.signPath,
|
|
11
10
|
query: {
|
|
12
11
|
name: a.name,
|
|
13
12
|
size: a.size,
|
|
@@ -16,45 +15,45 @@ function q(s) {
|
|
|
16
15
|
},
|
|
17
16
|
signal: t.signal,
|
|
18
17
|
onUploadProgress: t.onUploadProgress
|
|
19
|
-
}), r =
|
|
20
|
-
uploadUrl:
|
|
21
|
-
url:
|
|
22
|
-
params:
|
|
18
|
+
}), r = n.signCallback?.(o) || {
|
|
19
|
+
uploadUrl: o.data?.uploadUrl,
|
|
20
|
+
url: o.data?.url,
|
|
21
|
+
params: o.data?.params
|
|
23
22
|
};
|
|
24
23
|
if (!r.uploadUrl)
|
|
25
24
|
throw new Error("Upload URL is required");
|
|
26
25
|
if (!r.url)
|
|
27
26
|
throw new Error("File URL is required");
|
|
28
27
|
const p = t.method || "POST";
|
|
29
|
-
let
|
|
28
|
+
let s = null;
|
|
30
29
|
const u = t.headers || {};
|
|
31
30
|
if (p === "PUT")
|
|
32
|
-
|
|
31
|
+
s = a, u["Content-Type"] = a.type || "application/octet-stream";
|
|
33
32
|
else {
|
|
34
33
|
const e = new FormData();
|
|
35
|
-
e.append("Content-Type", a.type || "application/octet-stream"), e.append("file", a), r.params && Object.entries(r.params).forEach(([
|
|
36
|
-
e.append(
|
|
37
|
-
}),
|
|
34
|
+
e.append("Content-Type", a.type || "application/octet-stream"), e.append("file", a), r.params && Object.entries(r.params).forEach(([d, m]) => {
|
|
35
|
+
e.append(d, String(m));
|
|
36
|
+
}), s = e;
|
|
38
37
|
}
|
|
39
|
-
const
|
|
38
|
+
const l = await U.request({
|
|
40
39
|
method: p,
|
|
41
40
|
url: r.uploadUrl,
|
|
42
|
-
data:
|
|
41
|
+
data: s,
|
|
43
42
|
signal: t.signal,
|
|
44
43
|
headers: u,
|
|
45
44
|
onUploadProgress: (e) => {
|
|
46
45
|
if (t.onUploadProgress && e.total) {
|
|
47
|
-
const
|
|
46
|
+
const d = Math.round(e.loaded * 100 / e.total);
|
|
48
47
|
t.onUploadProgress({
|
|
49
48
|
loaded: e.loaded,
|
|
50
49
|
total: e.total,
|
|
51
|
-
percent:
|
|
50
|
+
percent: d
|
|
52
51
|
});
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
54
|
});
|
|
56
|
-
if (
|
|
57
|
-
throw new Error(`S3 upload failed: ${
|
|
55
|
+
if (l.status < 200 || l.status >= 300)
|
|
56
|
+
throw new Error(`S3 upload failed: ${l.statusText}`);
|
|
58
57
|
return {
|
|
59
58
|
data: {
|
|
60
59
|
url: r.url,
|
|
@@ -68,5 +67,5 @@ function q(s) {
|
|
|
68
67
|
};
|
|
69
68
|
}
|
|
70
69
|
export {
|
|
71
|
-
|
|
70
|
+
w as createS3UploadDriver
|
|
72
71
|
};
|