@duxweb/dvha-core 1.0.23 → 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
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { trim as
|
|
3
|
-
function
|
|
4
|
-
const
|
|
5
|
-
const l = `${
|
|
6
|
-
return a ? `${l}/${
|
|
1
|
+
import d from "axios";
|
|
2
|
+
import { trim as b } from "lodash-es";
|
|
3
|
+
function i(t) {
|
|
4
|
+
const h = (a, c) => {
|
|
5
|
+
const l = `${b(t.apiUrl, "/")}${c ? `/${b(c, "/")}` : ""}`;
|
|
6
|
+
return a ? `${l}/${b(a || "", "/")}` : l;
|
|
7
7
|
};
|
|
8
8
|
return {
|
|
9
|
-
apiUrl:
|
|
10
|
-
getList: (a,
|
|
9
|
+
apiUrl: h,
|
|
10
|
+
getList: (a, c, l) => {
|
|
11
11
|
const e = {};
|
|
12
|
-
return a.pagination && typeof a.pagination == "object" && (e.page = a.pagination.page, e.pageSize = a.pagination.pageSize),
|
|
12
|
+
return a.pagination && typeof a.pagination == "object" && (e.page = a.pagination.page, e.pageSize = a.pagination.pageSize), d.get(h(a.path, c?.config.apiBasePath) || "", {
|
|
13
13
|
params: {
|
|
14
14
|
...e,
|
|
15
15
|
...a.filters,
|
|
16
16
|
...a.sorters
|
|
17
17
|
},
|
|
18
18
|
headers: {
|
|
19
|
-
Authorization: l
|
|
19
|
+
Authorization: l?.token
|
|
20
20
|
},
|
|
21
21
|
...a.meta
|
|
22
|
-
}).then((r) =>
|
|
23
|
-
throw
|
|
22
|
+
}).then((r) => t.successCallback ? t.successCallback(r) : u(r)).catch((r) => {
|
|
23
|
+
throw t.errorCallback ? t.errorCallback(r) : n(r);
|
|
24
24
|
});
|
|
25
25
|
},
|
|
26
|
-
create: (a,
|
|
26
|
+
create: (a, c, l) => d.post(h(a.path, c?.config.apiBasePath) || "", a.data, {
|
|
27
27
|
headers: {
|
|
28
|
-
Authorization: l
|
|
28
|
+
Authorization: l?.token
|
|
29
29
|
},
|
|
30
30
|
...a.meta
|
|
31
|
-
}).then((e) =>
|
|
32
|
-
throw
|
|
31
|
+
}).then((e) => t.successCallback ? t.successCallback(e) : u(e)).catch((e) => {
|
|
32
|
+
throw t.errorCallback ? t.errorCallback(e) : n(e);
|
|
33
33
|
}),
|
|
34
|
-
update: (a,
|
|
34
|
+
update: (a, c, l) => d.put(h(a.id ? `${a.path}/${a.id}` : a.path, c?.config.apiBasePath) || "", a.data, {
|
|
35
35
|
headers: {
|
|
36
|
-
Authorization: l
|
|
36
|
+
Authorization: l?.token
|
|
37
37
|
},
|
|
38
38
|
...a.meta
|
|
39
|
-
}).then((e) =>
|
|
40
|
-
throw
|
|
39
|
+
}).then((e) => t.successCallback ? t.successCallback(e) : u(e)).catch((e) => {
|
|
40
|
+
throw t.errorCallback ? t.errorCallback(e) : n(e);
|
|
41
41
|
}),
|
|
42
|
-
deleteOne: (a,
|
|
42
|
+
deleteOne: (a, c, l) => d.delete(h(a.id ? `${a.path}/${a.id}` : a.path, c?.config.apiBasePath) || "", {
|
|
43
43
|
headers: {
|
|
44
|
-
Authorization: l
|
|
44
|
+
Authorization: l?.token
|
|
45
45
|
},
|
|
46
46
|
...a.meta
|
|
47
|
-
}).then((e) =>
|
|
48
|
-
throw
|
|
47
|
+
}).then((e) => t.successCallback ? t.successCallback(e) : u(e)).catch((e) => {
|
|
48
|
+
throw t.errorCallback ? t.errorCallback(e) : n(e);
|
|
49
49
|
}),
|
|
50
|
-
getOne: (a,
|
|
50
|
+
getOne: (a, c, l) => d.get(h(a.id ? `${a.path}/${a.id}` : a.path, c?.config.apiBasePath) || "", {
|
|
51
51
|
headers: {
|
|
52
|
-
Authorization: l
|
|
52
|
+
Authorization: l?.token
|
|
53
53
|
},
|
|
54
54
|
...a.meta
|
|
55
|
-
}).then((e) =>
|
|
56
|
-
throw
|
|
55
|
+
}).then((e) => t.successCallback ? t.successCallback(e) : u(e)).catch((e) => {
|
|
56
|
+
throw t.errorCallback ? t.errorCallback(e) : n(e);
|
|
57
57
|
}),
|
|
58
|
-
getMany: (a,
|
|
58
|
+
getMany: (a, c, l) => d.get(h(a.path, c?.config.apiBasePath) || "", {
|
|
59
59
|
params: {
|
|
60
60
|
ids: a.ids
|
|
61
61
|
},
|
|
62
62
|
headers: {
|
|
63
|
-
Authorization: l
|
|
63
|
+
Authorization: l?.token
|
|
64
64
|
},
|
|
65
65
|
...a.meta
|
|
66
|
-
}).then((e) =>
|
|
67
|
-
throw
|
|
66
|
+
}).then((e) => t.successCallback ? t.successCallback(e) : u(e)).catch((e) => {
|
|
67
|
+
throw t.errorCallback ? t.errorCallback(e) : n(e);
|
|
68
68
|
}),
|
|
69
|
-
createMany: (a,
|
|
69
|
+
createMany: (a, c, l) => d.post(h(a.path, c?.config.apiBasePath) || "", a.data, {
|
|
70
70
|
headers: {
|
|
71
|
-
Authorization: l
|
|
71
|
+
Authorization: l?.token
|
|
72
72
|
},
|
|
73
73
|
...a.meta
|
|
74
|
-
}).then((e) =>
|
|
75
|
-
throw
|
|
74
|
+
}).then((e) => t.successCallback ? t.successCallback(e) : u(e)).catch((e) => {
|
|
75
|
+
throw t.errorCallback ? t.errorCallback(e) : n(e);
|
|
76
76
|
}),
|
|
77
|
-
updateMany: (a,
|
|
77
|
+
updateMany: (a, c, l) => d.put(h(a.path, c?.config.apiBasePath) || "", {
|
|
78
78
|
ids: a.ids,
|
|
79
79
|
data: a.data
|
|
80
80
|
}, {
|
|
81
81
|
headers: {
|
|
82
|
-
Authorization: l
|
|
82
|
+
Authorization: l?.token
|
|
83
83
|
},
|
|
84
84
|
...a.meta
|
|
85
|
-
}).then((e) =>
|
|
86
|
-
throw
|
|
85
|
+
}).then((e) => t.successCallback ? t.successCallback(e) : u(e)).catch((e) => {
|
|
86
|
+
throw t.errorCallback ? t.errorCallback(e) : n(e);
|
|
87
87
|
}),
|
|
88
|
-
deleteMany: (a,
|
|
88
|
+
deleteMany: (a, c, l) => d.delete(h(a.path, c?.config.apiBasePath) || "", {
|
|
89
89
|
params: {
|
|
90
90
|
ids: a.ids
|
|
91
91
|
},
|
|
92
92
|
headers: {
|
|
93
|
-
Authorization: l
|
|
93
|
+
Authorization: l?.token
|
|
94
94
|
},
|
|
95
95
|
...a.meta
|
|
96
|
-
}).then((e) =>
|
|
97
|
-
throw
|
|
96
|
+
}).then((e) => t.successCallback ? t.successCallback(e) : u(e)).catch((e) => {
|
|
97
|
+
throw t.errorCallback ? t.errorCallback(e) : n(e);
|
|
98
98
|
}),
|
|
99
|
-
custom: (a,
|
|
99
|
+
custom: (a, c, l) => {
|
|
100
100
|
let e = {
|
|
101
101
|
...a.query
|
|
102
102
|
};
|
|
@@ -106,64 +106,57 @@ function z(c) {
|
|
|
106
106
|
}), a.filters && typeof a.filters == "object" && (e = {
|
|
107
107
|
...e,
|
|
108
108
|
...a.filters
|
|
109
|
-
}),
|
|
110
|
-
url:
|
|
109
|
+
}), d.request({
|
|
110
|
+
url: h(a.path, c?.config.apiBasePath) || "",
|
|
111
111
|
method: a.method || "GET",
|
|
112
112
|
data: a.payload,
|
|
113
113
|
params: e,
|
|
114
114
|
signal: a.signal,
|
|
115
115
|
headers: {
|
|
116
|
-
Authorization: l
|
|
116
|
+
Authorization: l?.token,
|
|
117
117
|
...a.headers
|
|
118
118
|
},
|
|
119
119
|
onUploadProgress: (r) => {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
(h = a.onUploadProgress) == null || h.call(a, {
|
|
120
|
+
const k = Math.round(r.loaded * 100 / (r.total || 1));
|
|
121
|
+
a.onUploadProgress?.({
|
|
123
122
|
loaded: r.loaded,
|
|
124
123
|
total: r.total,
|
|
125
|
-
percent:
|
|
124
|
+
percent: k
|
|
126
125
|
});
|
|
127
126
|
},
|
|
128
127
|
onDownloadProgress: (r) => {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
(h = a.onDownloadProgress) == null || h.call(a, {
|
|
128
|
+
const k = Math.round(r.loaded * 100 / (r.total || 1));
|
|
129
|
+
a.onDownloadProgress?.({
|
|
132
130
|
loaded: r.loaded,
|
|
133
131
|
total: r.total,
|
|
134
|
-
percent:
|
|
132
|
+
percent: k
|
|
135
133
|
});
|
|
136
134
|
},
|
|
137
135
|
...a.meta
|
|
138
|
-
}).then((r) =>
|
|
139
|
-
throw
|
|
136
|
+
}).then((r) => t.successCallback ? t.successCallback(r) : u(r)).catch((r) => {
|
|
137
|
+
throw t.errorCallback ? t.errorCallback(r) : n(r);
|
|
140
138
|
});
|
|
141
139
|
},
|
|
142
|
-
getTotal: (a) =>
|
|
143
|
-
var t;
|
|
144
|
-
return c.getTotal ? c.getTotal(a) : ((t = a.meta) == null ? void 0 : t.total) || 0;
|
|
145
|
-
}
|
|
140
|
+
getTotal: (a) => t.getTotal ? t.getTotal(a) : a.meta?.total || 0
|
|
146
141
|
};
|
|
147
142
|
}
|
|
148
|
-
function
|
|
149
|
-
var d, a, t;
|
|
143
|
+
function u(t) {
|
|
150
144
|
return {
|
|
151
|
-
message:
|
|
152
|
-
data:
|
|
153
|
-
meta:
|
|
154
|
-
raw:
|
|
145
|
+
message: t.data?.message,
|
|
146
|
+
data: t.data?.data,
|
|
147
|
+
meta: t.data?.meta,
|
|
148
|
+
raw: t.data
|
|
155
149
|
};
|
|
156
150
|
}
|
|
157
|
-
function
|
|
158
|
-
var d, a, t, l, e, r, s, h, u, f;
|
|
151
|
+
function n(t) {
|
|
159
152
|
return {
|
|
160
|
-
message:
|
|
161
|
-
data:
|
|
162
|
-
meta:
|
|
163
|
-
status:
|
|
164
|
-
raw:
|
|
153
|
+
message: t.response?.data?.message || t?.message,
|
|
154
|
+
data: t.response?.data?.data,
|
|
155
|
+
meta: t.response?.data?.meta,
|
|
156
|
+
status: t.response?.data?.code || t.response?.status || 500,
|
|
157
|
+
raw: t.response?.data
|
|
165
158
|
};
|
|
166
159
|
}
|
|
167
160
|
export {
|
|
168
|
-
|
|
161
|
+
i as simpleDataProvider
|
|
169
162
|
};
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { createI18n as
|
|
2
|
-
function r
|
|
3
|
-
const
|
|
1
|
+
import { createI18n as s } from "vue-i18n";
|
|
2
|
+
function t(r) {
|
|
3
|
+
const l = s({
|
|
4
4
|
legacy: !1,
|
|
5
|
-
locale:
|
|
6
|
-
fallbackLocale:
|
|
7
|
-
messages:
|
|
5
|
+
locale: r?.locale,
|
|
6
|
+
fallbackLocale: r?.fallbackLocale,
|
|
7
|
+
messages: r?.messages,
|
|
8
8
|
missingWarn: !1,
|
|
9
9
|
fallbackWarn: !1
|
|
10
10
|
});
|
|
11
11
|
return {
|
|
12
|
-
t: (e,
|
|
13
|
-
const
|
|
14
|
-
return
|
|
12
|
+
t: (e, a, o) => {
|
|
13
|
+
const c = l.global.t(e, a);
|
|
14
|
+
return c === e && o ? o : c;
|
|
15
15
|
},
|
|
16
|
-
changeLocale: (e,
|
|
17
|
-
|
|
16
|
+
changeLocale: (e, a) => new Promise((o) => {
|
|
17
|
+
l.global.locale.value = e, o(e);
|
|
18
18
|
}),
|
|
19
|
-
loadLocale: (e,
|
|
20
|
-
|
|
19
|
+
loadLocale: (e, a) => new Promise((o) => {
|
|
20
|
+
l.global.setLocaleMessage(e, a), o(e);
|
|
21
21
|
}),
|
|
22
|
-
mergeLocale: (e,
|
|
23
|
-
|
|
22
|
+
mergeLocale: (e, a) => {
|
|
23
|
+
l.global.mergeLocaleMessage(e, a);
|
|
24
24
|
},
|
|
25
|
-
getLocale: () =>
|
|
26
|
-
getLocales: () =>
|
|
25
|
+
getLocale: () => l.global.locale.value,
|
|
26
|
+
getLocales: () => l.global.availableLocales.map((e) => e)
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
export {
|
|
30
|
-
|
|
30
|
+
t as i18nProvider
|
|
31
31
|
};
|
package/dist/esm/provider/app.js
CHANGED
|
@@ -1,159 +1,152 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { OverlaysProvider as
|
|
3
|
-
import { useRouter as
|
|
4
|
-
import { useCan as
|
|
5
|
-
import { useConfig as
|
|
1
|
+
import { defineComponent as A, inject as S, createVNode as $ } from "vue";
|
|
2
|
+
import { OverlaysProvider as k } from "@overlastic/vue";
|
|
3
|
+
import { useRouter as M } from "vue-router";
|
|
4
|
+
import { useCan as w } from "../hooks/auth.js";
|
|
5
|
+
import { useConfig as z } from "../hooks/config.js";
|
|
6
6
|
import "@tanstack/vue-query";
|
|
7
|
-
import { useManage as
|
|
7
|
+
import { useManage as D } from "../hooks/manage.js";
|
|
8
8
|
import "json-2-csv";
|
|
9
9
|
import "lodash-es";
|
|
10
10
|
import "@vee-validate/rules";
|
|
11
11
|
import "vee-validate";
|
|
12
|
-
import { useAuthStore as
|
|
13
|
-
import { useI18nStore as
|
|
12
|
+
import { useAuthStore as C } from "../stores/auth.js";
|
|
13
|
+
import { useI18nStore as E } from "../stores/i18n.js";
|
|
14
14
|
import "pinia";
|
|
15
|
-
import { useManageStore as
|
|
16
|
-
import { useRouteStore as
|
|
15
|
+
import { useManageStore as I } from "../stores/manage.js";
|
|
16
|
+
import { useRouteStore as N } from "../stores/route.js";
|
|
17
17
|
import "@vueuse/core";
|
|
18
|
-
import { initJsonSchemaComponents as
|
|
18
|
+
import { initJsonSchemaComponents as x } from "../hooks/json.js";
|
|
19
19
|
import "../hooks/json/index.js";
|
|
20
20
|
import "../utils/bus.js";
|
|
21
21
|
import "colorizr";
|
|
22
22
|
import "axios";
|
|
23
23
|
import "clsx";
|
|
24
|
-
import { DuxError as
|
|
25
|
-
import { DuxNotAuthorized as
|
|
26
|
-
import { DuxNotFound as
|
|
27
|
-
const
|
|
24
|
+
import { DuxError as F } from "../components/status/error.js";
|
|
25
|
+
import { DuxNotAuthorized as L } from "../components/status/notAuthorized.js";
|
|
26
|
+
import { DuxNotFound as _ } from "../components/status/notFound.js";
|
|
27
|
+
const se = /* @__PURE__ */ A({
|
|
28
28
|
name: "DuxAppProvider",
|
|
29
29
|
props: {},
|
|
30
|
-
setup(
|
|
31
|
-
slots:
|
|
30
|
+
setup(y, {
|
|
31
|
+
slots: P
|
|
32
32
|
}) {
|
|
33
|
-
const
|
|
34
|
-
return
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const t = f.defaultManage || ((S = (A = f.manages) == null ? void 0 : A[0]) == null ? void 0 : S.name) || "";
|
|
33
|
+
const f = S("dux.manage"), p = z(), c = M();
|
|
34
|
+
return c.beforeEach(async (a, j, i) => {
|
|
35
|
+
const e = a.meta.manageName, v = a.meta.authorization === !1;
|
|
36
|
+
if (!e) {
|
|
37
|
+
const t = p.defaultManage || p.manages?.[0]?.name || "";
|
|
39
38
|
return i({
|
|
40
39
|
path: `/${t}`,
|
|
41
40
|
replace: !0
|
|
42
41
|
});
|
|
43
42
|
}
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
49
|
-
const t =
|
|
50
|
-
t &&
|
|
43
|
+
f && (f.value = e);
|
|
44
|
+
const h = I(e);
|
|
45
|
+
h.isInit() || h.setConfig(p.manages?.find((t) => t.name === e), p);
|
|
46
|
+
const m = N(e), o = D(e), s = C(e), d = E(e);
|
|
47
|
+
if (o.config?.i18nProvider && !d.isInit()) {
|
|
48
|
+
const t = d.getLocale();
|
|
49
|
+
t && o.config?.i18nProvider.changeLocale(t);
|
|
51
50
|
}
|
|
52
|
-
if (
|
|
53
|
-
return
|
|
54
|
-
path:
|
|
51
|
+
if (x(p, e), !s.isLogin())
|
|
52
|
+
return v ? i() : i({
|
|
53
|
+
path: o.getRoutePath("login"),
|
|
55
54
|
replace: !0
|
|
56
55
|
});
|
|
57
|
-
const
|
|
58
|
-
...
|
|
59
|
-
path:
|
|
56
|
+
const l = (t) => t?.map((u) => ({
|
|
57
|
+
...u,
|
|
58
|
+
path: u.path ? o.getRoutePath(u.path) : void 0
|
|
60
59
|
}));
|
|
61
|
-
if (!
|
|
62
|
-
const t =
|
|
63
|
-
return
|
|
64
|
-
name: `${
|
|
60
|
+
if (!m.getRouteInit()) {
|
|
61
|
+
const t = o.config?.components || {}, u = [];
|
|
62
|
+
return u.push({
|
|
63
|
+
name: `${e}.notFound`,
|
|
65
64
|
label: "404",
|
|
66
65
|
path: ":pathMatch(.*)*",
|
|
67
|
-
component: t.notFound ||
|
|
66
|
+
component: t.notFound || _,
|
|
68
67
|
hidden: !0,
|
|
69
68
|
meta: {
|
|
70
69
|
can: !1
|
|
71
70
|
}
|
|
72
|
-
}),
|
|
73
|
-
name: `${
|
|
71
|
+
}), u.push({
|
|
72
|
+
name: `${e}.notAuthorized`,
|
|
74
73
|
label: "403",
|
|
75
74
|
path: "notAuthorized",
|
|
76
|
-
component: t.notAuthorized ||
|
|
75
|
+
component: t.notAuthorized || L,
|
|
77
76
|
hidden: !0,
|
|
78
77
|
meta: {
|
|
79
78
|
can: !1
|
|
80
79
|
}
|
|
81
|
-
}),
|
|
82
|
-
name: `${
|
|
80
|
+
}), u.push({
|
|
81
|
+
name: `${e}.error`,
|
|
83
82
|
label: "500",
|
|
84
83
|
path: "error",
|
|
85
|
-
component: t.error ||
|
|
84
|
+
component: t.error || F,
|
|
86
85
|
hidden: !0,
|
|
87
86
|
meta: {
|
|
88
87
|
can: !1
|
|
89
88
|
}
|
|
90
|
-
}),
|
|
91
|
-
path:
|
|
89
|
+
}), m.setRoutes(l(o.config?.menus || [])), o.config?.apiRoutePath && await o.config?.dataProvider?.default?.custom({
|
|
90
|
+
path: o.config.apiRoutePath,
|
|
92
91
|
meta: {
|
|
93
92
|
timeout: 5e3
|
|
94
93
|
}
|
|
95
|
-
},
|
|
96
|
-
|
|
94
|
+
}, o, s.getUser()).then((r) => {
|
|
95
|
+
m.appendRoutes(l(r.data || []));
|
|
97
96
|
}).catch((r) => {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
u != null && u.logout && (g.logout(), d.push(e.getRoutePath(u.redirectTo || "/login")));
|
|
97
|
+
throw o.config?.authProvider?.onError?.(r).then((n) => {
|
|
98
|
+
n?.logout && (s.logout(), c.push(o.getRoutePath(n.redirectTo || "/login")));
|
|
101
99
|
}), r;
|
|
102
|
-
})
|
|
103
|
-
var m, s, u, _;
|
|
100
|
+
}), m.appendRoutes(u), m.getRoutes().forEach((r) => {
|
|
104
101
|
if (!r.path)
|
|
105
102
|
return;
|
|
106
|
-
const
|
|
103
|
+
const n = {
|
|
107
104
|
name: r.name,
|
|
108
105
|
path: r.path,
|
|
109
106
|
meta: r.meta
|
|
110
107
|
};
|
|
111
108
|
switch (r.loader) {
|
|
112
109
|
case "iframe":
|
|
113
|
-
|
|
110
|
+
n.component = o.config?.components?.iframe || (() => import("../components/loader/iframe.js"));
|
|
114
111
|
break;
|
|
115
112
|
case "remote":
|
|
116
|
-
|
|
113
|
+
n.component = o.config?.components?.remote || (() => import("../components/loader/loader.js"));
|
|
117
114
|
break;
|
|
118
115
|
case "link":
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}, a.component = () => Promise.resolve({
|
|
116
|
+
n.beforeEnter = () => {
|
|
117
|
+
const R = r.meta?.url || r.path;
|
|
118
|
+
return R && window.open(R, "_blank"), !1;
|
|
119
|
+
}, n.component = () => Promise.resolve({
|
|
124
120
|
template: "<div></div>"
|
|
125
121
|
});
|
|
126
122
|
break;
|
|
127
123
|
default:
|
|
128
|
-
r.component && (
|
|
124
|
+
r.component && (n.component = r.component);
|
|
129
125
|
break;
|
|
130
126
|
}
|
|
131
|
-
|
|
127
|
+
c.addRoute(`${e}.auth`, n);
|
|
132
128
|
}), i({
|
|
133
|
-
path:
|
|
129
|
+
path: a.redirectedFrom?.path || a.path,
|
|
134
130
|
replace: !0
|
|
135
131
|
});
|
|
136
132
|
}
|
|
137
|
-
const
|
|
138
|
-
if (
|
|
139
|
-
const t =
|
|
140
|
-
return !
|
|
141
|
-
path:
|
|
133
|
+
const g = ["", "/", `/${e}`, `/${e}/`];
|
|
134
|
+
if (g.includes(a.path)) {
|
|
135
|
+
const t = m.getIndexRoute();
|
|
136
|
+
return !t?.path || g.includes(t?.path) ? (console.warn("[Dux] index route not found, skip redirect"), i()) : i({
|
|
137
|
+
path: t?.path || "/",
|
|
142
138
|
replace: !0
|
|
143
139
|
});
|
|
144
140
|
}
|
|
145
|
-
const
|
|
146
|
-
return (
|
|
147
|
-
name: `${
|
|
141
|
+
const b = w(e);
|
|
142
|
+
return (a.meta?.can === void 0 || a.meta?.can === !0) && !b(a.name) ? i({
|
|
143
|
+
name: `${e}.notAuthorized`
|
|
148
144
|
}) : i();
|
|
149
|
-
}), () =>
|
|
150
|
-
default: () =>
|
|
151
|
-
var n;
|
|
152
|
-
return [(n = h.default) == null ? void 0 : n.call(h)];
|
|
153
|
-
}
|
|
145
|
+
}), () => $(k, null, {
|
|
146
|
+
default: () => [P.default?.()]
|
|
154
147
|
});
|
|
155
148
|
}
|
|
156
149
|
});
|
|
157
150
|
export {
|
|
158
|
-
|
|
151
|
+
se as DuxAppProvider
|
|
159
152
|
};
|
package/dist/esm/router/route.js
CHANGED
|
@@ -1,49 +1,41 @@
|
|
|
1
|
-
import { createRouter as
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
...o.routes || [],
|
|
1
|
+
import { createRouter as u, createWebHashHistory as h } from "vue-router";
|
|
2
|
+
function i(e) {
|
|
3
|
+
const a = [
|
|
4
|
+
...e.routes || [],
|
|
6
5
|
{
|
|
7
6
|
name: "default",
|
|
8
7
|
path: "/:catchAll(.*)",
|
|
9
|
-
redirect: `/${
|
|
8
|
+
redirect: `/${e.defaultManage || e.manages?.[0]?.name || ""}`
|
|
10
9
|
}
|
|
11
10
|
];
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var e, p;
|
|
16
|
-
return ((e = a.meta) == null ? void 0 : e.authorization) === !0 || ((p = a.meta) == null ? void 0 : p.authorization) === void 0;
|
|
17
|
-
})) || [], d = ((i = t.routes) == null ? void 0 : i.filter((a) => {
|
|
18
|
-
var e;
|
|
19
|
-
return ((e = a.meta) == null ? void 0 : e.authorization) === !1;
|
|
20
|
-
})) || [];
|
|
21
|
-
r.push({
|
|
11
|
+
return e.manages?.forEach((t) => {
|
|
12
|
+
const r = t.routes?.filter((o) => o.meta?.authorization === !0 || o.meta?.authorization === void 0) || [], n = t.routes?.filter((o) => o.meta?.authorization === !1) || [];
|
|
13
|
+
a.push({
|
|
22
14
|
name: t.name,
|
|
23
15
|
path: t.routePrefix || "",
|
|
24
16
|
children: [
|
|
25
17
|
{
|
|
26
18
|
path: "",
|
|
27
19
|
name: `${t.name}.auth`,
|
|
28
|
-
component:
|
|
29
|
-
children:
|
|
20
|
+
component: t.components?.authLayout,
|
|
21
|
+
children: r
|
|
30
22
|
},
|
|
31
23
|
{
|
|
32
24
|
path: "",
|
|
33
25
|
name: `${t.name}.noAuth`,
|
|
34
|
-
component:
|
|
35
|
-
children:
|
|
26
|
+
component: t.components?.noAuthLayout,
|
|
27
|
+
children: n
|
|
36
28
|
}
|
|
37
29
|
],
|
|
38
30
|
meta: {
|
|
39
31
|
manageName: t.name
|
|
40
32
|
}
|
|
41
33
|
});
|
|
42
|
-
}),
|
|
43
|
-
history:
|
|
44
|
-
routes:
|
|
34
|
+
}), u({
|
|
35
|
+
history: h(),
|
|
36
|
+
routes: a
|
|
45
37
|
});
|
|
46
38
|
}
|
|
47
39
|
export {
|
|
48
|
-
|
|
40
|
+
i as initRouter
|
|
49
41
|
};
|