@duxweb/dvha-core 1.0.15 → 1.0.16
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("lodash-es"),p=require("vue"),a=require("vue-router");require("pinia");const g=require("../stores/manage.cjs");function P(u){const o=p.inject("dux.manage");if(u||(u=o==null?void 0:o.value),!u)throw new Error("manage name is not defined");const{config:t}=g.useManageStore(u),f=e=>`${t==null?void 0:t.routePrefix}/${c.trimStart(e||"","/")}`,l=(e,n)=>{var i,s;const r=(i=t==null?void 0:t.dataProvider)==null?void 0:i[n||"default"];return((s=r==null?void 0:r.apiUrl)==null?void 0:s.call(r,e,t==null?void 0:t.apiBasePath))||""},h=a.useRoute();return{config:t,getRoutePath:f,getApiUrl:l,getPath:()=>{const e=h.path,n=(t==null?void 0:t.routePrefix)||"";return c.trimStart(e.replace(n,""),"/")}}}exports.useManage=P;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("axios"),s=require("lodash-es");function P(c){const d=(a,t)=>{const l=`${s.trim(c.apiUrl,"/")}${t?`/${s.trim(t,"/")}`:""}`;return a?`${l}/${s.trim(a||"","/")}`:l};return{apiUrl:d,getList:(a,t,l)=>{const e={};return a.pagination&&typeof a.pagination=="object"&&(e.page=a.pagination.page,e.pageSize=a.pagination.pageSize),k.get(d(a.path,t==null?void 0:t.config.apiBasePath)||"",{params:{...e,...a.filters,...a.sorters},headers:{Authorization:l==null?void 0:l.token},...a.meta}).then(r=>c.successCallback?c.successCallback(r):b(r)).catch(r=>{throw c.errorCallback?c.errorCallback(r):C(r)})},create:(a,t,l)=>k.post(d(a.path,t==null?void 0:t.config.apiBasePath)||"",a.data,{headers:{Authorization:l==null?void 0:l.token},...a.meta}).then(e=>c.successCallback?c.successCallback(e):b(e)).catch(e=>{throw c.errorCallback?c.errorCallback(e):C(e)}),update:(a,t,l)=>k.put(d(a.id?`${a.path}/${a.id}`:a.path,t==null?void 0:t.config.apiBasePath)||"",a.data,{headers:{Authorization:l==null?void 0:l.token},...a.meta}).then(e=>c.successCallback?c.successCallback(e):b(e)).catch(e=>{throw c.errorCallback?c.errorCallback(e):C(e)}),deleteOne:(a,t,l)=>k.delete(d(a.id?`${a.path}/${a.id}`:a.path,t==null?void 0:t.config.apiBasePath)||"",{headers:{Authorization:l==null?void 0:l.token},...a.meta}).then(e=>c.successCallback?c.successCallback(e):b(e)).catch(e=>{throw c.errorCallback?c.errorCallback(e):C(e)}),getOne:(a,t,l)=>k.get(d(a.id?`${a.path}/${a.id}`:a.path,t==null?void 0:t.config.apiBasePath)||"",{headers:{Authorization:l==null?void 0:l.token},...a.meta}).then(e=>c.successCallback?c.successCallback(e):b(e)).catch(e=>{throw c.errorCallback?c.errorCallback(e):C(e)}),getMany:(a,t,l)=>k.get(d(a.path,t==null?void 0:t.config.apiBasePath)||"",{params:{ids:a.ids},headers:{Authorization:l==null?void 0:l.token},...a.meta}).then(e=>c.successCallback?c.successCallback(e):b(e)).catch(e=>{throw c.errorCallback?c.errorCallback(e):C(e)}),createMany:(a,t,l)=>k.post(d(a.path,t==null?void 0:t.config.apiBasePath)||"",a.data,{headers:{Authorization:l==null?void 0:l.token},...a.meta}).then(e=>c.successCallback?c.successCallback(e):b(e)).catch(e=>{throw c.errorCallback?c.errorCallback(e):C(e)}),updateMany:(a,t,l)=>k.put(d(a.path,t==null?void 0:t.config.apiBasePath)||"",{ids:a.ids,data:a.data},{headers:{Authorization:l==null?void 0:l.token},...a.meta}).then(e=>c.successCallback?c.successCallback(e):b(e)).catch(e=>{throw c.errorCallback?c.errorCallback(e):C(e)}),deleteMany:(a,t,l)=>k.delete(d(a.path,t==null?void 0:t.config.apiBasePath)||"",{params:{ids:a.ids},headers:{Authorization:l==null?void 0:l.token},...a.meta}).then(e=>c.successCallback?c.successCallback(e):b(e)).catch(e=>{throw c.errorCallback?c.errorCallback(e):C(e)}),custom:(a,t,l)=>{let e={...a.query};return a.sorters&&typeof a.sorters=="object"&&(e={...e,...a.sorters}),a.filters&&typeof a.filters=="object"&&(e={...e,...a.filters}),k.request({url:d(a.path,t==null?void 0:t.config.apiBasePath)||"",method:a.method||"GET",data:a.payload,params:e,signal:a.signal,headers:{Authorization:l==null?void 0:l.token,...a.headers},onUploadProgress:r=>{var h;const i=Math.round(r.loaded*100/(r.total||1));(h=a.onUploadProgress)==null||h.call(a,{loaded:r.loaded,total:r.total,percent:i})},onDownloadProgress:r=>{var h;const i=Math.round(r.loaded*100/(r.total||1));(h=a.onDownloadProgress)==null||h.call(a,{loaded:r.loaded,total:r.total,percent:i})},...a.meta}).then(r=>c.successCallback?c.successCallback(r):b(r)).catch(r=>{throw c.errorCallback?c.errorCallback(r):C(r)})},getTotal:a=>{var t;return c.getTotal?c.getTotal(a):((t=a.meta)==null?void 0:t.total)||0}}}function b(c){var d,a,t;return{message:(d=c.data)==null?void 0:d.message,data:(a=c.data)==null?void 0:a.data,meta:(t=c.data)==null?void 0:t.meta,raw:c.data}}function C(c){var d,a,t,l,e,r,i,h,u,f;return{message:((a=(d=c.response)==null?void 0:d.data)==null?void 0:a.message)||(c==null?void 0:c.message),data:(l=(t=c.response)==null?void 0:t.data)==null?void 0:l.data,meta:(r=(e=c.response)==null?void 0:e.data)==null?void 0:r.meta,status:((h=(i=c.response)==null?void 0:i.data)==null?void 0:h.code)||((u=c.response)==null?void 0:u.status)||500,raw:(f=c.response)==null?void 0:f.data}}exports.simpleDataProvider=P;
|
package/dist/esm/hooks/manage.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { trimStart as f } from "lodash-es";
|
|
2
|
-
import { inject as
|
|
2
|
+
import { inject as l } from "vue";
|
|
3
3
|
import { useRoute as x } from "vue-router";
|
|
4
4
|
import "pinia";
|
|
5
|
-
import { useManageStore as
|
|
5
|
+
import { useManageStore as P } from "../stores/manage.js";
|
|
6
6
|
function $(e) {
|
|
7
|
-
const i =
|
|
7
|
+
const i = l("dux.manage");
|
|
8
8
|
if (e || (e = i == null ? void 0 : i.value), !e)
|
|
9
9
|
throw new Error("manage name is not defined");
|
|
10
|
-
const { config: t } =
|
|
11
|
-
var
|
|
12
|
-
const o = (
|
|
13
|
-
return ((c = o == null ? void 0 : o.apiUrl) == null ? void 0 : c.call(o, r)) || "";
|
|
14
|
-
},
|
|
10
|
+
const { config: t } = P(e), s = (r) => `${t == null ? void 0 : t.routePrefix}/${f(r || "", "/")}`, p = (r, u) => {
|
|
11
|
+
var n, c;
|
|
12
|
+
const o = (n = t == null ? void 0 : t.dataProvider) == null ? void 0 : n[u || "default"];
|
|
13
|
+
return ((c = o == null ? void 0 : o.apiUrl) == null ? void 0 : c.call(o, r, t == null ? void 0 : t.apiBasePath)) || "";
|
|
14
|
+
}, h = x();
|
|
15
15
|
return {
|
|
16
16
|
config: t,
|
|
17
17
|
getRoutePath: s,
|
|
18
18
|
getApiUrl: p,
|
|
19
19
|
getPath: () => {
|
|
20
|
-
const r =
|
|
21
|
-
return f(r.replace(
|
|
20
|
+
const r = h.path, u = (t == null ? void 0 : t.routePrefix) || "";
|
|
21
|
+
return f(r.replace(u, ""), "/");
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
}
|
|
@@ -1,99 +1,102 @@
|
|
|
1
1
|
import k from "axios";
|
|
2
|
-
import {
|
|
3
|
-
function
|
|
4
|
-
const d = (a) =>
|
|
2
|
+
import { trim as i } from "lodash-es";
|
|
3
|
+
function z(c) {
|
|
4
|
+
const d = (a, t) => {
|
|
5
|
+
const l = `${i(c.apiUrl, "/")}${t ? `/${i(t, "/")}` : ""}`;
|
|
6
|
+
return a ? `${l}/${i(a || "", "/")}` : l;
|
|
7
|
+
};
|
|
5
8
|
return {
|
|
6
9
|
apiUrl: d,
|
|
7
|
-
getList: (a,
|
|
10
|
+
getList: (a, t, l) => {
|
|
8
11
|
const e = {};
|
|
9
|
-
return a.pagination && typeof a.pagination == "object" && (e.page = a.pagination.page, e.pageSize = a.pagination.pageSize), k.get(d(a.path) || "", {
|
|
12
|
+
return a.pagination && typeof a.pagination == "object" && (e.page = a.pagination.page, e.pageSize = a.pagination.pageSize), k.get(d(a.path, t == null ? void 0 : t.config.apiBasePath) || "", {
|
|
10
13
|
params: {
|
|
11
14
|
...e,
|
|
12
15
|
...a.filters,
|
|
13
16
|
...a.sorters
|
|
14
17
|
},
|
|
15
18
|
headers: {
|
|
16
|
-
Authorization:
|
|
19
|
+
Authorization: l == null ? void 0 : l.token
|
|
17
20
|
},
|
|
18
21
|
...a.meta
|
|
19
|
-
}).then((
|
|
20
|
-
throw
|
|
22
|
+
}).then((r) => c.successCallback ? c.successCallback(r) : b(r)).catch((r) => {
|
|
23
|
+
throw c.errorCallback ? c.errorCallback(r) : C(r);
|
|
21
24
|
});
|
|
22
25
|
},
|
|
23
|
-
create: (a,
|
|
26
|
+
create: (a, t, l) => k.post(d(a.path, t == null ? void 0 : t.config.apiBasePath) || "", a.data, {
|
|
24
27
|
headers: {
|
|
25
|
-
Authorization:
|
|
28
|
+
Authorization: l == null ? void 0 : l.token
|
|
26
29
|
},
|
|
27
30
|
...a.meta
|
|
28
|
-
}).then((e) =>
|
|
29
|
-
throw
|
|
31
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : b(e)).catch((e) => {
|
|
32
|
+
throw c.errorCallback ? c.errorCallback(e) : C(e);
|
|
30
33
|
}),
|
|
31
|
-
update: (a,
|
|
34
|
+
update: (a, t, l) => k.put(d(a.id ? `${a.path}/${a.id}` : a.path, t == null ? void 0 : t.config.apiBasePath) || "", a.data, {
|
|
32
35
|
headers: {
|
|
33
|
-
Authorization:
|
|
36
|
+
Authorization: l == null ? void 0 : l.token
|
|
34
37
|
},
|
|
35
38
|
...a.meta
|
|
36
|
-
}).then((e) =>
|
|
37
|
-
throw
|
|
39
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : b(e)).catch((e) => {
|
|
40
|
+
throw c.errorCallback ? c.errorCallback(e) : C(e);
|
|
38
41
|
}),
|
|
39
|
-
deleteOne: (a,
|
|
42
|
+
deleteOne: (a, t, l) => k.delete(d(a.id ? `${a.path}/${a.id}` : a.path, t == null ? void 0 : t.config.apiBasePath) || "", {
|
|
40
43
|
headers: {
|
|
41
|
-
Authorization:
|
|
44
|
+
Authorization: l == null ? void 0 : l.token
|
|
42
45
|
},
|
|
43
46
|
...a.meta
|
|
44
|
-
}).then((e) =>
|
|
45
|
-
throw
|
|
47
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : b(e)).catch((e) => {
|
|
48
|
+
throw c.errorCallback ? c.errorCallback(e) : C(e);
|
|
46
49
|
}),
|
|
47
|
-
getOne: (a,
|
|
50
|
+
getOne: (a, t, l) => k.get(d(a.id ? `${a.path}/${a.id}` : a.path, t == null ? void 0 : t.config.apiBasePath) || "", {
|
|
48
51
|
headers: {
|
|
49
|
-
Authorization:
|
|
52
|
+
Authorization: l == null ? void 0 : l.token
|
|
50
53
|
},
|
|
51
54
|
...a.meta
|
|
52
|
-
}).then((e) =>
|
|
53
|
-
throw
|
|
55
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : b(e)).catch((e) => {
|
|
56
|
+
throw c.errorCallback ? c.errorCallback(e) : C(e);
|
|
54
57
|
}),
|
|
55
|
-
getMany: (a,
|
|
58
|
+
getMany: (a, t, l) => k.get(d(a.path, t == null ? void 0 : t.config.apiBasePath) || "", {
|
|
56
59
|
params: {
|
|
57
60
|
ids: a.ids
|
|
58
61
|
},
|
|
59
62
|
headers: {
|
|
60
|
-
Authorization:
|
|
63
|
+
Authorization: l == null ? void 0 : l.token
|
|
61
64
|
},
|
|
62
65
|
...a.meta
|
|
63
|
-
}).then((e) =>
|
|
64
|
-
throw
|
|
66
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : b(e)).catch((e) => {
|
|
67
|
+
throw c.errorCallback ? c.errorCallback(e) : C(e);
|
|
65
68
|
}),
|
|
66
|
-
createMany: (a,
|
|
69
|
+
createMany: (a, t, l) => k.post(d(a.path, t == null ? void 0 : t.config.apiBasePath) || "", a.data, {
|
|
67
70
|
headers: {
|
|
68
|
-
Authorization:
|
|
71
|
+
Authorization: l == null ? void 0 : l.token
|
|
69
72
|
},
|
|
70
73
|
...a.meta
|
|
71
|
-
}).then((e) =>
|
|
72
|
-
throw
|
|
74
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : b(e)).catch((e) => {
|
|
75
|
+
throw c.errorCallback ? c.errorCallback(e) : C(e);
|
|
73
76
|
}),
|
|
74
|
-
updateMany: (a,
|
|
77
|
+
updateMany: (a, t, l) => k.put(d(a.path, t == null ? void 0 : t.config.apiBasePath) || "", {
|
|
75
78
|
ids: a.ids,
|
|
76
79
|
data: a.data
|
|
77
80
|
}, {
|
|
78
81
|
headers: {
|
|
79
|
-
Authorization:
|
|
82
|
+
Authorization: l == null ? void 0 : l.token
|
|
80
83
|
},
|
|
81
84
|
...a.meta
|
|
82
|
-
}).then((e) =>
|
|
83
|
-
throw
|
|
85
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : b(e)).catch((e) => {
|
|
86
|
+
throw c.errorCallback ? c.errorCallback(e) : C(e);
|
|
84
87
|
}),
|
|
85
|
-
deleteMany: (a,
|
|
88
|
+
deleteMany: (a, t, l) => k.delete(d(a.path, t == null ? void 0 : t.config.apiBasePath) || "", {
|
|
86
89
|
params: {
|
|
87
90
|
ids: a.ids
|
|
88
91
|
},
|
|
89
92
|
headers: {
|
|
90
|
-
Authorization:
|
|
93
|
+
Authorization: l == null ? void 0 : l.token
|
|
91
94
|
},
|
|
92
95
|
...a.meta
|
|
93
|
-
}).then((e) =>
|
|
94
|
-
throw
|
|
96
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : b(e)).catch((e) => {
|
|
97
|
+
throw c.errorCallback ? c.errorCallback(e) : C(e);
|
|
95
98
|
}),
|
|
96
|
-
custom: (a,
|
|
99
|
+
custom: (a, t, l) => {
|
|
97
100
|
let e = {
|
|
98
101
|
...a.query
|
|
99
102
|
};
|
|
@@ -104,63 +107,63 @@ function w(l) {
|
|
|
104
107
|
...e,
|
|
105
108
|
...a.filters
|
|
106
109
|
}), k.request({
|
|
107
|
-
url: d(a.path || ""
|
|
110
|
+
url: d(a.path, t == null ? void 0 : t.config.apiBasePath) || "",
|
|
108
111
|
method: a.method || "GET",
|
|
109
112
|
data: a.payload,
|
|
110
113
|
params: e,
|
|
111
114
|
signal: a.signal,
|
|
112
115
|
headers: {
|
|
113
|
-
Authorization:
|
|
116
|
+
Authorization: l == null ? void 0 : l.token,
|
|
114
117
|
...a.headers
|
|
115
118
|
},
|
|
116
|
-
onUploadProgress: (
|
|
117
|
-
var
|
|
118
|
-
const
|
|
119
|
-
(
|
|
120
|
-
loaded:
|
|
121
|
-
total:
|
|
122
|
-
percent:
|
|
119
|
+
onUploadProgress: (r) => {
|
|
120
|
+
var h;
|
|
121
|
+
const s = Math.round(r.loaded * 100 / (r.total || 1));
|
|
122
|
+
(h = a.onUploadProgress) == null || h.call(a, {
|
|
123
|
+
loaded: r.loaded,
|
|
124
|
+
total: r.total,
|
|
125
|
+
percent: s
|
|
123
126
|
});
|
|
124
127
|
},
|
|
125
|
-
onDownloadProgress: (
|
|
126
|
-
var
|
|
127
|
-
const
|
|
128
|
-
(
|
|
129
|
-
loaded:
|
|
130
|
-
total:
|
|
131
|
-
percent:
|
|
128
|
+
onDownloadProgress: (r) => {
|
|
129
|
+
var h;
|
|
130
|
+
const s = Math.round(r.loaded * 100 / (r.total || 1));
|
|
131
|
+
(h = a.onDownloadProgress) == null || h.call(a, {
|
|
132
|
+
loaded: r.loaded,
|
|
133
|
+
total: r.total,
|
|
134
|
+
percent: s
|
|
132
135
|
});
|
|
133
136
|
},
|
|
134
137
|
...a.meta
|
|
135
|
-
}).then((
|
|
136
|
-
throw
|
|
138
|
+
}).then((r) => c.successCallback ? c.successCallback(r) : b(r)).catch((r) => {
|
|
139
|
+
throw c.errorCallback ? c.errorCallback(r) : C(r);
|
|
137
140
|
});
|
|
138
141
|
},
|
|
139
142
|
getTotal: (a) => {
|
|
140
|
-
var
|
|
141
|
-
return
|
|
143
|
+
var t;
|
|
144
|
+
return c.getTotal ? c.getTotal(a) : ((t = a.meta) == null ? void 0 : t.total) || 0;
|
|
142
145
|
}
|
|
143
146
|
};
|
|
144
147
|
}
|
|
145
|
-
function
|
|
146
|
-
var d, a,
|
|
148
|
+
function b(c) {
|
|
149
|
+
var d, a, t;
|
|
147
150
|
return {
|
|
148
|
-
message: (d =
|
|
149
|
-
data: (a =
|
|
150
|
-
meta: (
|
|
151
|
-
raw:
|
|
151
|
+
message: (d = c.data) == null ? void 0 : d.message,
|
|
152
|
+
data: (a = c.data) == null ? void 0 : a.data,
|
|
153
|
+
meta: (t = c.data) == null ? void 0 : t.meta,
|
|
154
|
+
raw: c.data
|
|
152
155
|
};
|
|
153
156
|
}
|
|
154
|
-
function
|
|
155
|
-
var d, a,
|
|
157
|
+
function C(c) {
|
|
158
|
+
var d, a, t, l, e, r, s, h, u, f;
|
|
156
159
|
return {
|
|
157
|
-
message: ((a = (d =
|
|
158
|
-
data: (
|
|
159
|
-
meta: (
|
|
160
|
-
status: ((
|
|
161
|
-
raw: (
|
|
160
|
+
message: ((a = (d = c.response) == null ? void 0 : d.data) == null ? void 0 : a.message) || (c == null ? void 0 : c.message),
|
|
161
|
+
data: (l = (t = c.response) == null ? void 0 : t.data) == null ? void 0 : l.data,
|
|
162
|
+
meta: (r = (e = c.response) == null ? void 0 : e.data) == null ? void 0 : r.meta,
|
|
163
|
+
status: ((h = (s = c.response) == null ? void 0 : s.data) == null ? void 0 : h.code) || ((u = c.response) == null ? void 0 : u.status) || 500,
|
|
164
|
+
raw: (f = c.response) == null ? void 0 : f.data
|
|
162
165
|
};
|
|
163
166
|
}
|
|
164
167
|
export {
|
|
165
|
-
|
|
168
|
+
z as simpleDataProvider
|
|
166
169
|
};
|
|
@@ -5,7 +5,7 @@ import type { IUserState } from '../stores';
|
|
|
5
5
|
* 为全局或管理端提供自定义数据源处理服务
|
|
6
6
|
*/
|
|
7
7
|
export interface IDataProvider {
|
|
8
|
-
apiUrl?: (path?: string) => string;
|
|
8
|
+
apiUrl?: (path?: string, basePath?: string) => string;
|
|
9
9
|
getList: (options: IDataProviderListOptions, manage?: IManageHook, auth?: IUserState) => Promise<IDataProviderResponse>;
|
|
10
10
|
create: (options: IDataProviderCreateOptions, manage?: IManageHook, auth?: IUserState) => Promise<IDataProviderResponse>;
|
|
11
11
|
update: (options: IDataProviderUpdateOptions, manage?: IManageHook, auth?: IUserState) => Promise<IDataProviderResponse>;
|