vome-core 0.0.13 → 0.0.14
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/admin/api/client.js +147 -1
- package/dist/admin/config/plugin-dev.js +1 -1
- package/dist/admin/crud/config.js +1 -1
- package/dist/admin/crud/confirm.js +1 -1
- package/dist/admin/crud/dict.js +1 -1
- package/dist/admin/crud/index.js +1 -1
- package/dist/admin/crud/key.js +1 -1
- package/dist/admin/crud/mitt.js +1 -1
- package/dist/admin/crud/plugins.js +1 -1
- package/dist/admin/crud/span.js +1 -1
- package/dist/admin/crud/style.js +1 -1
- package/dist/admin/crud/useCrud.js +1 -1
- package/dist/admin/crud/validate.js +1 -1
- package/dist/admin/directives/perm.js +1 -1
- package/dist/admin/hooks/useBrowser.js +1 -1
- package/dist/admin/hooks/useUpload.js +1 -1
- package/dist/admin/hooks/useVome.js +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/lib/browser.js +1 -1
- package/dist/admin/lib/cn.js +1 -1
- package/dist/admin/lib/dialog-float.js +1 -1
- package/dist/admin/lib/eps.js +33 -1
- package/dist/admin/lib/menu.js +1 -1
- package/dist/admin/lib/module.js +1 -1
- package/dist/admin/lib/tree.js +1 -1
- package/dist/admin/lib/upload.js +1 -1
- package/dist/admin/router/index.js +65 -1
- package/dist/admin/router/menu-routes.js +113 -1
- package/dist/admin/service/base.js +76 -1
- package/dist/admin/service/index.js +263 -1
- package/dist/admin/stores/app.js +1 -1
- package/dist/admin/stores/tags.js +1 -1
- package/dist/admin/stores/user.js +64 -1
- package/dist/index.js +1 -1
- package/dist/server/index.js +1 -1
- package/dist/shared/index.js +1 -1
- package/dist/shared/tree.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1,113 @@
|
|
|
1
|
-
|
|
1
|
+
import { defineComponent, h } from "vue";
|
|
2
|
+
import { resolveView, viewPathToName } from "../lib/module";
|
|
3
|
+
import MissingView from "#vome-host/pages/missing/index.vue";
|
|
4
|
+
import MicroAppView from "#vome-host/pages/micro/index.vue";
|
|
5
|
+
const addedNames = new Set;
|
|
6
|
+
function isMicroMenu(m) {
|
|
7
|
+
return Boolean(m.appKey && m.router);
|
|
8
|
+
}
|
|
9
|
+
function walk(nodes, out) {
|
|
10
|
+
for (const n of nodes) {
|
|
11
|
+
if (Number(n.type) === 1 && n.router)
|
|
12
|
+
out.push(n);
|
|
13
|
+
if (n.children?.length)
|
|
14
|
+
walk(n.children, out);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function missingView(viewPath) {
|
|
18
|
+
return defineComponent({
|
|
19
|
+
name: "MissingViewPage",
|
|
20
|
+
setup() {
|
|
21
|
+
return () => h(MissingView, { path: viewPath });
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function routeNameOf(id) {
|
|
26
|
+
return `menu-${id}`;
|
|
27
|
+
}
|
|
28
|
+
function buildRoute(item) {
|
|
29
|
+
const full = item.router;
|
|
30
|
+
const childPath = full.replace(/^\//, "");
|
|
31
|
+
let component;
|
|
32
|
+
const componentName = viewPathToName(item.viewPath);
|
|
33
|
+
const meta = {
|
|
34
|
+
title: item.name,
|
|
35
|
+
keepAlive: item.keepAlive !== false,
|
|
36
|
+
viewPath: item.viewPath,
|
|
37
|
+
perms: item.perms,
|
|
38
|
+
componentName
|
|
39
|
+
};
|
|
40
|
+
if (isMicroMenu(item)) {
|
|
41
|
+
component = MicroAppView;
|
|
42
|
+
meta.appKey = item.appKey;
|
|
43
|
+
meta.componentName = `micro-${item.appKey}`;
|
|
44
|
+
meta.keepAlive = false;
|
|
45
|
+
} else if (item.viewPath) {
|
|
46
|
+
const loader = resolveView(item.viewPath);
|
|
47
|
+
component = loader || missingView(item.viewPath);
|
|
48
|
+
} else {
|
|
49
|
+
component = missingView(full);
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
path: childPath,
|
|
53
|
+
name: routeNameOf(item.id),
|
|
54
|
+
component,
|
|
55
|
+
meta
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export async function ensureMenuRoutes(router, menus) {
|
|
59
|
+
const items = [];
|
|
60
|
+
walk(menus, items);
|
|
61
|
+
for (const item of items) {
|
|
62
|
+
const name = routeNameOf(item.id);
|
|
63
|
+
if (addedNames.has(name))
|
|
64
|
+
continue;
|
|
65
|
+
addedNames.add(name);
|
|
66
|
+
router.addRoute("layout", buildRoute(item));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export async function syncMenuRoutes(router, menus) {
|
|
70
|
+
const items = [];
|
|
71
|
+
walk(menus, items);
|
|
72
|
+
const nextNames = new Set(items.map((i) => routeNameOf(i.id)));
|
|
73
|
+
for (const name of [...addedNames]) {
|
|
74
|
+
if (!nextNames.has(name)) {
|
|
75
|
+
if (router.hasRoute(name))
|
|
76
|
+
router.removeRoute(name);
|
|
77
|
+
addedNames.delete(name);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
for (const item of items) {
|
|
81
|
+
const name = routeNameOf(item.id);
|
|
82
|
+
const childPath = item.router.replace(/^\//, "");
|
|
83
|
+
if (addedNames.has(name) && router.hasRoute(name)) {
|
|
84
|
+
const existing = router.getRoutes().find((r) => r.name === name);
|
|
85
|
+
if (existing && existing.path.replace(/^\//, "") !== childPath) {
|
|
86
|
+
router.removeRoute(name);
|
|
87
|
+
addedNames.delete(name);
|
|
88
|
+
} else if (existing?.meta) {
|
|
89
|
+
existing.meta.title = item.name;
|
|
90
|
+
existing.meta.keepAlive = item.keepAlive !== false;
|
|
91
|
+
existing.meta.viewPath = item.viewPath;
|
|
92
|
+
existing.meta.perms = item.perms;
|
|
93
|
+
if (item.appKey)
|
|
94
|
+
existing.meta.appKey = item.appKey;
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (!addedNames.has(name)) {
|
|
99
|
+
addedNames.add(name);
|
|
100
|
+
router.addRoute("layout", buildRoute(item));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export function clearMenuRoutesFlag() {
|
|
105
|
+
addedNames.clear();
|
|
106
|
+
}
|
|
107
|
+
export function removeAllMenuRoutes(router) {
|
|
108
|
+
for (const name of [...addedNames]) {
|
|
109
|
+
if (router.hasRoute(name))
|
|
110
|
+
router.removeRoute(name);
|
|
111
|
+
}
|
|
112
|
+
addedNames.clear();
|
|
113
|
+
}
|
|
@@ -1 +1,76 @@
|
|
|
1
|
-
|
|
1
|
+
import { request } from "../api/client";
|
|
2
|
+
function stripTimeMeta(data) {
|
|
3
|
+
if (Array.isArray(data))
|
|
4
|
+
return data.map((item) => stripTimeMeta(item));
|
|
5
|
+
if (data && typeof data === "object") {
|
|
6
|
+
const out = { ...data };
|
|
7
|
+
delete out.createTime;
|
|
8
|
+
delete out.updateTime;
|
|
9
|
+
return out;
|
|
10
|
+
}
|
|
11
|
+
return data;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class BaseService {
|
|
15
|
+
namespace;
|
|
16
|
+
constructor(namespace) {
|
|
17
|
+
if (namespace)
|
|
18
|
+
this.namespace = namespace.replace(/^\//, "");
|
|
19
|
+
}
|
|
20
|
+
async request(options = {}) {
|
|
21
|
+
let url = options.url || "";
|
|
22
|
+
if (url && !/^https?:\/\//.test(url)) {
|
|
23
|
+
if (this.namespace) {
|
|
24
|
+
const ns = this.namespace.startsWith("/") ? this.namespace : `/${this.namespace}`;
|
|
25
|
+
url = url.startsWith("/") ? `${ns}${url}` : `${ns}/${url}`;
|
|
26
|
+
}
|
|
27
|
+
if (!url.startsWith("/"))
|
|
28
|
+
url = `/${url}`;
|
|
29
|
+
}
|
|
30
|
+
const method = (options.method || "GET").toUpperCase();
|
|
31
|
+
if (method === "GET") {
|
|
32
|
+
const params = options.params || {};
|
|
33
|
+
const q = new URLSearchParams;
|
|
34
|
+
for (const [k, v] of Object.entries(params)) {
|
|
35
|
+
if (v == null)
|
|
36
|
+
continue;
|
|
37
|
+
q.set(k, String(v));
|
|
38
|
+
}
|
|
39
|
+
const qs = q.toString();
|
|
40
|
+
return request(qs ? `${url}?${qs}` : url);
|
|
41
|
+
}
|
|
42
|
+
return request(url, {
|
|
43
|
+
method,
|
|
44
|
+
body: JSON.stringify(stripTimeMeta(options.data ?? {}))
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
page(data = {}) {
|
|
48
|
+
return this.request({ url: "/page", method: "POST", data });
|
|
49
|
+
}
|
|
50
|
+
list(data = {}) {
|
|
51
|
+
return this.request({
|
|
52
|
+
url: "/list",
|
|
53
|
+
method: "POST",
|
|
54
|
+
data
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
info(params) {
|
|
58
|
+
return this.request({
|
|
59
|
+
url: "/info",
|
|
60
|
+
method: "GET",
|
|
61
|
+
params
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
add(data) {
|
|
65
|
+
return this.request({ url: "/add", method: "POST", data });
|
|
66
|
+
}
|
|
67
|
+
update(data) {
|
|
68
|
+
return this.request({ url: "/update", method: "POST", data });
|
|
69
|
+
}
|
|
70
|
+
delete(data) {
|
|
71
|
+
return this.request({ url: "/delete", method: "POST", data });
|
|
72
|
+
}
|
|
73
|
+
restore(data) {
|
|
74
|
+
return this.request({ url: "/restore", method: "POST", data });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -1 +1,263 @@
|
|
|
1
|
-
(function(_0x26fd20,_0x1804f4){const _0x11113d=_0x1384,_0x4fa750=_0x26fd20();while(!![]){try{const _0x906a8f=parseInt(_0x11113d(0xf6))/0x1+-parseInt(_0x11113d(0x107))/0x2+-parseInt(_0x11113d(0xee))/0x3+-parseInt(_0x11113d(0xdd))/0x4+parseInt(_0x11113d(0xe9))/0x5*(-parseInt(_0x11113d(0xe8))/0x6)+-parseInt(_0x11113d(0xf9))/0x7*(parseInt(_0x11113d(0xd9))/0x8)+parseInt(_0x11113d(0x101))/0x9;if(_0x906a8f===_0x1804f4)break;else _0x4fa750['push'](_0x4fa750['shift']());}catch(_0x19d917){_0x4fa750['push'](_0x4fa750['shift']());}}}(_0x5233,0x45c4f));import{loadEps}from'../lib/eps';import{BaseService}from'./base';const SIDE_ID='admin';function toCamel(_0x3a5cd1){const _0x1791db=_0x1384;return _0x3a5cd1[_0x1791db(0x10a)](/([^-])(?:-+([^-]))/g,(_0x567699,_0x2a2a1e,_0x3b5091)=>_0x2a2a1e+String(_0x3b5091)['toUpperCase']());}function methodName(_0x596363){const _0x261e1c=_0x1384;return _0x596363['replace'](/^\//,'')[_0x261e1c(0x10a)](/[:,\s/-]/g,'');}function isValidName(_0x4b4579){const _0x1aa1d9=_0x1384;return Boolean(_0x4b4579)&&!['{','}',':'][_0x1aa1d9(0x10b)](_0x46aa6f=>_0x4b4579[_0x1aa1d9(0xfa)](_0x46aa6f));}function resolvePermCode(_0x370823,_0x27045d){const _0x18511b=_0x1384,_0x1cd85a=_0x370823['replace'](/^\//,'')[_0x18511b(0xdb)]('/')['filter'](Boolean),_0x341d6a=_0x1cd85a[0x1]||_0x1cd85a[0x0]||_0x18511b(0xeb);let _0x3af84f=_0x1cd85a[_0x18511b(0xef)](0x2)[_0x18511b(0x105)](':');if(_0x3af84f===_0x341d6a)_0x3af84f=_0x341d6a;else _0x3af84f[_0x18511b(0xd6)](_0x341d6a+':')&&(_0x3af84f=_0x3af84f[_0x18511b(0xef)](_0x341d6a[_0x18511b(0xdf)]+0x1));const _0x21c17b=_0x341d6a+'-';if(_0x3af84f[_0x18511b(0xd6)](_0x21c17b))_0x3af84f=_0x3af84f[_0x18511b(0xef)](_0x21c17b[_0x18511b(0xdf)]);_0x3af84f=_0x3af84f[_0x18511b(0x10a)](/-/g,':');if(!_0x3af84f)_0x3af84f=_0x341d6a;return _0x341d6a+':'+_0x3af84f+':'+_0x27045d;}function prefixToParts(_0x48addf){const _0x4f30d2=_0x1384,_0x23ab9a=_0x48addf[_0x4f30d2(0x10a)](/^\//,'');return _0x23ab9a['replace'](new RegExp('^'+SIDE_ID+'/?'),'')['split']('/')['filter'](Boolean)[_0x4f30d2(0xf3)](toCamel);}function bindCrud(_0x32db9a,_0x32ac6d){const _0x52b6df=_0x1384,_0x4ce3fe=BaseService[_0x52b6df(0xda)];for(const _0x1dd75f of[_0x52b6df(0x103),'page',_0x52b6df(0xd8),_0x52b6df(0xf0),_0x52b6df(0x106),_0x52b6df(0xfc),_0x52b6df(0x102),_0x52b6df(0xe4)]){const _0x572fc9=_0x4ce3fe[_0x1dd75f];typeof _0x572fc9===_0x52b6df(0xe7)&&(_0x32db9a[_0x1dd75f]=_0x572fc9['bind'](_0x32ac6d));}}function bindApis(_0x896f65,_0x585895,_0x5e4aa6){const _0x48d4e1=_0x1384;_0x896f65[_0x48d4e1(0xf1)]||={};for(const _0x3dce88 of _0x5e4aa6){const _0x5d5670=methodName(_0x3dce88[_0x48d4e1(0xd4)]);if(!isValidName(_0x5d5670)||/[-:]/g[_0x48d4e1(0xf7)](_0x5d5670))continue;const _0x3c5e80=(_0x3dce88[_0x48d4e1(0x100)]||_0x48d4e1(0xf4))['toLowerCase']();_0x896f65[_0x5d5670]=function(_0xf8c907){const _0x431d2b=_0x48d4e1;return this['request']({'url':_0x3dce88[_0x431d2b(0xd4)][_0x431d2b(0xd6)]('/')?_0x3dce88[_0x431d2b(0xd4)]:'/'+_0x3dce88['path'],'method':_0x3c5e80,[_0x3c5e80===_0x431d2b(0xec)?_0x431d2b(0xfe):_0x431d2b(0xe3)]:_0xf8c907});}[_0x48d4e1(0xed)](_0x585895),_0x896f65[_0x48d4e1(0xf1)][_0x5d5670]=_0x3dce88['perms']?.[0x0]||resolvePermCode('/'+_0x896f65['namespace'],_0x5d5670);}}function createLeaf(_0x5019bb,_0x4644b8=[]){const _0x3f30e5=_0x1384,_0x1f93dd=_0x5019bb[_0x3f30e5(0x10a)](/^\//,''),_0x2a6ea4=new BaseService(_0x1f93dd),_0x2a86fb=_0x2a6ea4;return _0x2a86fb[_0x3f30e5(0xd5)]=_0x1f93dd,_0x2a86fb[_0x3f30e5(0xf1)]={},_0x2a86fb[_0x3f30e5(0xe2)]={},bindCrud(_0x2a86fb,_0x2a6ea4),bindApis(_0x2a86fb,_0x2a6ea4,_0x4644b8),_0x2a86fb;}function attachLeaf(_0x1b529b,_0x36320b,_0xcd59eb=[]){const _0x5c89a1=_0x1384,_0x365e83=_0x36320b['replace'](/^\//,''),_0x65e2bc=prefixToParts(_0x36320b);if(!_0x65e2bc[_0x5c89a1(0xdf)])return;let _0x2207e7=_0x1b529b;for(let _0x3c539d=0x0;_0x3c539d<_0x65e2bc[_0x5c89a1(0xdf)];_0x3c539d++){const _0x52a976=_0x65e2bc[_0x3c539d],_0x2caedf=_0x3c539d===_0x65e2bc['length']-0x1;if(!_0x2caedf){const _0x5ee7ce=_0x2207e7[_0x52a976];(!_0x5ee7ce||typeof _0x5ee7ce!==_0x5c89a1(0xf8)||_0x5c89a1(0xd5)in _0x5ee7ce)&&(_0x2207e7[_0x52a976]={});_0x2207e7=_0x2207e7[_0x52a976];continue;}const _0x95d9a0=createLeaf(_0x365e83,_0xcd59eb);return _0x2207e7[_0x52a976]=_0x95d9a0,_0x95d9a0;}return;}function buildFromEps(_0x3b7a4a){const _0xf046b6=_0x1384,_0x281e23=getOrCreateRoot(),_0x340862=Object[_0xf046b6(0xdc)](_0x3b7a4a)[_0xf046b6(0x104)]();for(const _0x507006 of _0x340862){if(!_0x507006?.[_0xf046b6(0xfb)])continue;const _0x3da748=attachLeaf(_0x281e23,_0x507006[_0xf046b6(0xfb)],_0x507006[_0xf046b6(0x10d)]||[]);if(_0x3da748){const _0x4127d5=_0x507006[_0xf046b6(0xde)];_0x4127d5&&(_0x3da748[_0xf046b6(0xfd)]={'fieldEq':_0x4127d5[_0xf046b6(0xe0)],'fieldLike':_0x4127d5[_0xf046b6(0x10c)],'fieldArray':_0x4127d5[_0xf046b6(0xe5)],'fieldRange':_0x4127d5['fieldRange'],'keyWordLikeFields':_0x4127d5['keyWordLikeFields']});}}}function _0x1384(_0x36e2ad,_0x878b3){_0x36e2ad=_0x36e2ad-0xd4;const _0x523366=_0x5233();let _0x138448=_0x523366[_0x36e2ad];if(_0x1384['KSwAjZ']===undefined){var _0x9fd907=function(_0xad57c){const _0xcdee04='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x3a5cd1='',_0x567699='';for(let _0x2a2a1e=0x0,_0x3b5091,_0x596363,_0x4b4579=0x0;_0x596363=_0xad57c['charAt'](_0x4b4579++);~_0x596363&&(_0x3b5091=_0x2a2a1e%0x4?_0x3b5091*0x40+_0x596363:_0x596363,_0x2a2a1e++%0x4)?_0x3a5cd1+=String['fromCharCode'](0xff&_0x3b5091>>(-0x2*_0x2a2a1e&0x6)):0x0){_0x596363=_0xcdee04['indexOf'](_0x596363);}for(let _0x46aa6f=0x0,_0x370823=_0x3a5cd1['length'];_0x46aa6f<_0x370823;_0x46aa6f++){_0x567699+='%'+('00'+_0x3a5cd1['charCodeAt'](_0x46aa6f)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x567699);};_0x1384['NwThLo']=_0x9fd907,_0x1384['POgfrV']={},_0x1384['KSwAjZ']=!![];}const _0x3372a4=_0x523366[0x0],_0x56b138=_0x36e2ad+_0x3372a4,_0x2dfdd8=_0x1384['POgfrV'][_0x56b138];return!_0x2dfdd8?(_0x138448=_0x1384['NwThLo'](_0x138448),_0x1384['POgfrV'][_0x56b138]=_0x138448):_0x138448=_0x2dfdd8,_0x138448;}function normalizeEpsMap(_0x4baaca){const _0x9d639a=_0x1384;if(!_0x4baaca||typeof _0x4baaca!==_0x9d639a(0xf8))return{};const _0x5ea657=_0x4baaca;if(_0x9d639a(0x10e)in _0x5ea657&&_0x9d639a(0xfe)in _0x5ea657&&_0x5ea657['data']&&typeof _0x5ea657[_0x9d639a(0xfe)]===_0x9d639a(0xf8)&&!Array[_0x9d639a(0x108)](_0x5ea657[_0x9d639a(0xfe)]))return _0x5ea657['data'];return _0x4baaca;}function countPrefixedEntities(_0xf31283){const _0x5f53ef=_0x1384;return Object[_0x5f53ef(0xdc)](_0xf31283)[_0x5f53ef(0x104)]()['filter'](_0x152283=>_0x152283&&typeof _0x152283===_0x5f53ef(0xf8)&&Boolean(_0x152283[_0x5f53ef(0xfb)]))[_0x5f53ef(0xdf)];}const SERVICE_ROOT_KEY='__vome_admin_service__',EPS_PROMISE_KEY='__vome_admin_eps__';function createServiceRoot(){const _0x18036a=_0x1384,_0x3d10a4=new BaseService();return{'request':_0x3d10a4['request'][_0x18036a(0xed)](_0x3d10a4)};}function getOrCreateRoot(){const _0x3ab26b=globalThis;return!_0x3ab26b[SERVICE_ROOT_KEY]&&(_0x3ab26b[SERVICE_ROOT_KEY]=createServiceRoot()),_0x3ab26b[SERVICE_ROOT_KEY];}function resetServiceModules(){const _0x3f440b=_0x1384,_0x5db0b9=getOrCreateRoot();for(const _0x107b63 of Object[_0x3f440b(0xea)](_0x5db0b9)){if(_0x107b63===_0x3f440b(0x103))continue;delete _0x5db0b9[_0x107b63];}}export const service=new Proxy({},{'get'(_0x1f81ce,_0x82e62,_0x13634a){const _0x3f81fe=_0x1384,_0x4e0600=getOrCreateRoot(),_0x4a98b0=Reflect[_0x3f81fe(0xf4)](_0x4e0600,_0x82e62,_0x4e0600);return typeof _0x4a98b0===_0x3f81fe(0xe7)?_0x4a98b0[_0x3f81fe(0xed)](_0x4e0600):_0x4a98b0;},'set'(_0x24c54c,_0x1f3d9c,_0x2ae7ca){const _0x17d87d=_0x1384;return Reflect[_0x17d87d(0xe1)](getOrCreateRoot(),_0x1f3d9c,_0x2ae7ca);},'has'(_0x457030,_0x25f8de){const _0x1302b5=_0x1384;return Reflect[_0x1302b5(0xf2)](getOrCreateRoot(),_0x25f8de);},'ownKeys'(){const _0x5d5cc5=_0x1384;return Reflect[_0x5d5cc5(0xd7)](getOrCreateRoot());},'getOwnPropertyDescriptor'(_0xea60f0,_0x21d0c7){const _0x52f7f8=_0x1384,_0x3e25fc=Reflect['getOwnPropertyDescriptor'](getOrCreateRoot(),_0x21d0c7);if(_0x3e25fc)_0x3e25fc[_0x52f7f8(0xf5)]=!![];return _0x3e25fc;}});export async function createEps(_0xee2a41=![]){const _0x47d3b6=globalThis;if(!_0xee2a41&&_0x47d3b6[EPS_PROMISE_KEY])return _0x47d3b6[EPS_PROMISE_KEY];const _0x219911=((async()=>{const _0xcbe51d=_0x1384,_0x470c47=await loadEps(_0xee2a41)||{},_0x3c6b65=normalizeEpsMap(_0x470c47),_0x30b134=countPrefixedEntities(_0x3c6b65);if(!_0x30b134)throw new Error(_0xcbe51d(0x109));resetServiceModules(),buildFromEps(_0x3c6b65);const _0x27e4e1=getOrCreateRoot(),_0x1b18d7=_0x27e4e1[_0xcbe51d(0xeb)];if(!_0x1b18d7||typeof _0x1b18d7!==_0xcbe51d(0xf8))throw new Error('[vome-eps]\x20mount\x20failed:\x20service.base\x20missing\x20after\x20EPS\x20apply');return _0x27e4e1;})());_0x47d3b6[EPS_PROMISE_KEY]=_0x219911;try{return await _0x219911;}catch(_0xf5093f){_0x47d3b6[EPS_PROMISE_KEY]=null;throw _0xf5093f;}}if(undefined){}export function setServicePerms(_0x4c2f3b,_0x1e868=![]){const _0x3338da=_0x4c2f3b||[],_0x3528da=getOrCreateRoot();function _0x4554c7(_0x55b8c6){const _0x9e232a=_0x1384;if(!_0x55b8c6||typeof _0x55b8c6!==_0x9e232a(0xf8))return;const _0x11b092=_0x55b8c6;if(_0x11b092['permission']&&_0x11b092[_0x9e232a(0xd5)]){_0x11b092['_permission']={};for(const _0x4c1bd5 of Object[_0x9e232a(0xea)](_0x11b092[_0x9e232a(0xf1)])){if(_0x1e868){_0x11b092['_permission'][_0x4c1bd5]=!![];continue;}const _0x34993d=_0x11b092[_0x9e232a(0xf1)][_0x4c1bd5];_0x11b092['_permission'][_0x4c1bd5]=_0x3338da['includes'](_0x34993d)||_0x3338da[_0x9e232a(0x10b)](_0x239b92=>_0x239b92[_0x9e232a(0x10a)](/:/g,'/')['includes'](_0x11b092[_0x9e232a(0xd5)][_0x9e232a(0x10a)](/^admin\//,'')+'/'+_0x4c1bd5));}return;}for(const _0x1358b5 of Object[_0x9e232a(0xea)](_0x11b092)){if(_0x1358b5===_0x9e232a(0x103))continue;_0x4554c7(_0x11b092[_0x1358b5]);}}_0x4554c7(_0x3528da);}export function resolveService(_0x55366c){const _0x328805=_0x1384,_0x554a7e=_0x55366c[_0x328805(0x10a)](/^\//,'')[_0x328805(0xdb)]('.')[_0x328805(0xff)](Boolean);let _0x1246d8=getOrCreateRoot();for(const _0x5dcc43 of _0x554a7e){if(!_0x1246d8||typeof _0x1246d8!==_0x328805(0xf8))return;_0x1246d8=_0x1246d8[_0x5dcc43];}if(_0x1246d8&&typeof _0x1246d8==='object'&&_0x328805(0xd5)in _0x1246d8)return _0x1246d8;return;}export function serviceOf(_0x20ff9d){const _0x4e7d26=_0x1384,_0x57f5ba=_0x20ff9d[_0x4e7d26(0x10a)](/\/$/,''),_0x249ece=prefixToParts(_0x57f5ba)[_0x4e7d26(0x105)]('.'),_0x159289=resolveService(_0x249ece);if(!_0x159289)throw new Error(_0x4e7d26(0xe6)+_0x20ff9d+'\x20(await\x20createEps\x20first)');return _0x159289;}function _0x5233(){const _0x103fc8=['CgvYBwLZC2LVBG','AgfZ','BwfW','z2v0','y29UzMLNDxjHyMXL','ndCZnZmZwhrps1fP','DgvZDa','B2jQzwn0','mtyXChvYrMjX','Aw5JBhvKzxm','ChjLzML4','DxbKyxrL','C2vHCMnO','zgf0yq','zMLSDgvY','Bwv0Ag9K','odGXmZi3n0jlBevnDG','zgvSzxrL','CMvXDwvZDa','zMXHDa','AM9PBG','ywrK','mJG0ntq4ugPYve1T','AxnbCNjHEq','w3zVBwuTzxbZxsbLBxb0EsbVCIbPBNzHBgLKiokaLcbLBMfIBguGDM9Tzs5LChmGyw5KignOzwnRieDfvcaVywrTAw4VyMfZzs9VCgvUl2vWCYaOzxHWzwn0ig1VzhvSzsbTyxaGD2L0AcbWCMvMAxGP','CMvWBgfJzq','C29Tzq','zMLLBgrmAwTL','yxbP','y29Kzq','Cgf0Aa','BMfTzxnWywnL','C3rHCNrZv2L0Aa','B3DUs2v5CW','BgLZDa','mtqYmJu2qKnfBevn','ChjVDg90ExbL','C3bSAxq','DMfSDwvZ','mtaYnJGZmLbjAMLxBG','CgfNzvf1zxj5t3a','BgvUz3rO','zMLLBgrfCq','C2v0','x3bLCM1PC3nPB24','CgfYyw1Z','CMvZDg9Yzq','zMLLBgrbCNjHEq','w3zVBwuTzxbZxsbZzxj2AwnLig1PC3nPBMC6ia','zNvUy3rPB24','mtGYnZblvMDoqu8','mZG1z0DAy2TQ','A2v5CW','yMfZzq','Cg9ZDa','yMLUza','mZC0mZm0DeH1s1zt','C2XPy2u','Aw5MBW'];_0x5233=function(){return _0x103fc8;};return _0x5233();}export function createEpsService(_0x360edb){return serviceOf(_0x360edb);}export{BaseService};
|
|
1
|
+
import { loadEps } from "../lib/eps";
|
|
2
|
+
import { BaseService } from "./base";
|
|
3
|
+
const SIDE_ID = "admin";
|
|
4
|
+
function toCamel(str) {
|
|
5
|
+
return str.replace(/([^-])(?:-+([^-]))/g, (_m, a, b) => a + String(b).toUpperCase());
|
|
6
|
+
}
|
|
7
|
+
function methodName(path) {
|
|
8
|
+
return path.replace(/^\//, "").replace(/[:,\s/-]/g, "");
|
|
9
|
+
}
|
|
10
|
+
function isValidName(name) {
|
|
11
|
+
return Boolean(name) && !["{", "}", ":"].some((c) => name.includes(c));
|
|
12
|
+
}
|
|
13
|
+
function resolvePermCode(prefix, action) {
|
|
14
|
+
const parts = prefix.replace(/^\//, "").split("/").filter(Boolean);
|
|
15
|
+
const module = parts[1] || parts[0] || "base";
|
|
16
|
+
let resource = parts.slice(2).join(":");
|
|
17
|
+
if (resource === module) {
|
|
18
|
+
resource = module;
|
|
19
|
+
} else if (resource.startsWith(`${module}:`)) {
|
|
20
|
+
resource = resource.slice(module.length + 1);
|
|
21
|
+
}
|
|
22
|
+
const head = `${module}-`;
|
|
23
|
+
if (resource.startsWith(head))
|
|
24
|
+
resource = resource.slice(head.length);
|
|
25
|
+
resource = resource.replace(/-/g, ":");
|
|
26
|
+
if (!resource)
|
|
27
|
+
resource = module;
|
|
28
|
+
return `${module}:${resource}:${action}`;
|
|
29
|
+
}
|
|
30
|
+
function prefixToParts(prefix) {
|
|
31
|
+
const raw = prefix.replace(/^\//, "");
|
|
32
|
+
return raw.replace(new RegExp(`^${SIDE_ID}/?`), "").split("/").filter(Boolean).map(toCamel);
|
|
33
|
+
}
|
|
34
|
+
function bindCrud(leaf, base) {
|
|
35
|
+
const proto = BaseService.prototype;
|
|
36
|
+
for (const name of [
|
|
37
|
+
"request",
|
|
38
|
+
"page",
|
|
39
|
+
"list",
|
|
40
|
+
"info",
|
|
41
|
+
"add",
|
|
42
|
+
"update",
|
|
43
|
+
"delete",
|
|
44
|
+
"restore"
|
|
45
|
+
]) {
|
|
46
|
+
const fn = proto[name];
|
|
47
|
+
if (typeof fn === "function") {
|
|
48
|
+
leaf[name] = fn.bind(base);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function bindApis(leaf, base, apis) {
|
|
53
|
+
leaf.permission ||= {};
|
|
54
|
+
for (const api of apis) {
|
|
55
|
+
const name = methodName(api.path);
|
|
56
|
+
if (!isValidName(name) || /[-:]/g.test(name))
|
|
57
|
+
continue;
|
|
58
|
+
const method = (api.method || "get").toLowerCase();
|
|
59
|
+
leaf[name] = function(data) {
|
|
60
|
+
return this.request({
|
|
61
|
+
url: api.path.startsWith("/") ? api.path : `/${api.path}`,
|
|
62
|
+
method,
|
|
63
|
+
[method === "post" ? "data" : "params"]: data
|
|
64
|
+
});
|
|
65
|
+
}.bind(base);
|
|
66
|
+
leaf.permission[name] = api.perms?.[0] || resolvePermCode(`/${leaf.namespace}`, name);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function createLeaf(namespace, apis = []) {
|
|
70
|
+
const ns = namespace.replace(/^\//, "");
|
|
71
|
+
const base = new BaseService(ns);
|
|
72
|
+
const leaf = base;
|
|
73
|
+
leaf.namespace = ns;
|
|
74
|
+
leaf.permission = {};
|
|
75
|
+
leaf._permission = {};
|
|
76
|
+
bindCrud(leaf, base);
|
|
77
|
+
bindApis(leaf, base, apis);
|
|
78
|
+
return leaf;
|
|
79
|
+
}
|
|
80
|
+
function attachLeaf(tree, prefix, apis = []) {
|
|
81
|
+
const raw = prefix.replace(/^\//, "");
|
|
82
|
+
const arr = prefixToParts(prefix);
|
|
83
|
+
if (!arr.length)
|
|
84
|
+
return;
|
|
85
|
+
let node = tree;
|
|
86
|
+
for (let i = 0;i < arr.length; i++) {
|
|
87
|
+
const key = arr[i];
|
|
88
|
+
const isLast = i === arr.length - 1;
|
|
89
|
+
if (!isLast) {
|
|
90
|
+
const cur = node[key];
|
|
91
|
+
if (!cur || typeof cur !== "object" || "namespace" in cur) {
|
|
92
|
+
node[key] = {};
|
|
93
|
+
}
|
|
94
|
+
node = node[key];
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const leaf = createLeaf(raw, apis);
|
|
98
|
+
node[key] = leaf;
|
|
99
|
+
return leaf;
|
|
100
|
+
}
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
function buildFromEps(map) {
|
|
104
|
+
const root = getOrCreateRoot();
|
|
105
|
+
const list = Object.values(map).flat();
|
|
106
|
+
for (const e of list) {
|
|
107
|
+
if (!e?.prefix)
|
|
108
|
+
continue;
|
|
109
|
+
const leaf = attachLeaf(root, e.prefix, e.api || []);
|
|
110
|
+
if (leaf) {
|
|
111
|
+
const op = e.pageQueryOp;
|
|
112
|
+
if (op) {
|
|
113
|
+
leaf.search = {
|
|
114
|
+
fieldEq: op.fieldEq,
|
|
115
|
+
fieldLike: op.fieldLike,
|
|
116
|
+
fieldArray: op.fieldArray,
|
|
117
|
+
fieldRange: op.fieldRange,
|
|
118
|
+
keyWordLikeFields: op.keyWordLikeFields
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function normalizeEpsMap(input) {
|
|
125
|
+
if (!input || typeof input !== "object")
|
|
126
|
+
return {};
|
|
127
|
+
const m = input;
|
|
128
|
+
if ("code" in m && "data" in m && m.data && typeof m.data === "object" && !Array.isArray(m.data)) {
|
|
129
|
+
return m.data;
|
|
130
|
+
}
|
|
131
|
+
return input;
|
|
132
|
+
}
|
|
133
|
+
function countPrefixedEntities(map) {
|
|
134
|
+
return Object.values(map).flat().filter((e) => e && typeof e === "object" && Boolean(e.prefix)).length;
|
|
135
|
+
}
|
|
136
|
+
const SERVICE_ROOT_KEY = "__vome_admin_service__";
|
|
137
|
+
const EPS_PROMISE_KEY = "__vome_admin_eps__";
|
|
138
|
+
function createServiceRoot() {
|
|
139
|
+
const root = new BaseService;
|
|
140
|
+
return {
|
|
141
|
+
request: root.request.bind(root)
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function getOrCreateRoot() {
|
|
145
|
+
const g = globalThis;
|
|
146
|
+
if (!g[SERVICE_ROOT_KEY]) {
|
|
147
|
+
g[SERVICE_ROOT_KEY] = createServiceRoot();
|
|
148
|
+
}
|
|
149
|
+
return g[SERVICE_ROOT_KEY];
|
|
150
|
+
}
|
|
151
|
+
function resetServiceModules() {
|
|
152
|
+
const root = getOrCreateRoot();
|
|
153
|
+
for (const key of Object.keys(root)) {
|
|
154
|
+
if (key === "request")
|
|
155
|
+
continue;
|
|
156
|
+
delete root[key];
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
export const service = new Proxy({}, {
|
|
160
|
+
get(_t, prop, _r) {
|
|
161
|
+
const root = getOrCreateRoot();
|
|
162
|
+
const val = Reflect.get(root, prop, root);
|
|
163
|
+
return typeof val === "function" ? val.bind(root) : val;
|
|
164
|
+
},
|
|
165
|
+
set(_t, prop, value) {
|
|
166
|
+
return Reflect.set(getOrCreateRoot(), prop, value);
|
|
167
|
+
},
|
|
168
|
+
has(_t, prop) {
|
|
169
|
+
return Reflect.has(getOrCreateRoot(), prop);
|
|
170
|
+
},
|
|
171
|
+
ownKeys() {
|
|
172
|
+
return Reflect.ownKeys(getOrCreateRoot());
|
|
173
|
+
},
|
|
174
|
+
getOwnPropertyDescriptor(_t, prop) {
|
|
175
|
+
const desc = Reflect.getOwnPropertyDescriptor(getOrCreateRoot(), prop);
|
|
176
|
+
if (desc)
|
|
177
|
+
desc.configurable = true;
|
|
178
|
+
return desc;
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
export async function createEps(force = false) {
|
|
182
|
+
const g = globalThis;
|
|
183
|
+
if (!force && g[EPS_PROMISE_KEY])
|
|
184
|
+
return g[EPS_PROMISE_KEY];
|
|
185
|
+
const run = (async () => {
|
|
186
|
+
const raw = await loadEps(force) || {};
|
|
187
|
+
const map = normalizeEpsMap(raw);
|
|
188
|
+
const n = countPrefixedEntities(map);
|
|
189
|
+
if (!n) {
|
|
190
|
+
throw new Error("[vome-eps] empty or invalid — enable vome.eps and check GET /admin/base/open/eps (expect module map with prefix)");
|
|
191
|
+
}
|
|
192
|
+
resetServiceModules();
|
|
193
|
+
buildFromEps(map);
|
|
194
|
+
const root = getOrCreateRoot();
|
|
195
|
+
const base = root.base;
|
|
196
|
+
if (!base || typeof base !== "object") {
|
|
197
|
+
throw new Error("[vome-eps] mount failed: service.base missing after EPS apply");
|
|
198
|
+
}
|
|
199
|
+
return root;
|
|
200
|
+
})();
|
|
201
|
+
g[EPS_PROMISE_KEY] = run;
|
|
202
|
+
try {
|
|
203
|
+
return await run;
|
|
204
|
+
} catch (e) {
|
|
205
|
+
g[EPS_PROMISE_KEY] = null;
|
|
206
|
+
throw e;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (undefined) {}
|
|
210
|
+
export function setServicePerms(perms, isSuper = false) {
|
|
211
|
+
const list = perms || [];
|
|
212
|
+
const root = getOrCreateRoot();
|
|
213
|
+
function deep(d) {
|
|
214
|
+
if (!d || typeof d !== "object")
|
|
215
|
+
return;
|
|
216
|
+
const obj = d;
|
|
217
|
+
if (obj.permission && obj.namespace) {
|
|
218
|
+
obj._permission = {};
|
|
219
|
+
for (const key of Object.keys(obj.permission)) {
|
|
220
|
+
if (isSuper) {
|
|
221
|
+
obj._permission[key] = true;
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
const code = obj.permission[key];
|
|
225
|
+
obj._permission[key] = list.includes(code) || list.some((p) => p.replace(/:/g, "/").includes(`${obj.namespace.replace(/^admin\//, "")}/${key}`));
|
|
226
|
+
}
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
for (const k of Object.keys(obj)) {
|
|
230
|
+
if (k === "request")
|
|
231
|
+
continue;
|
|
232
|
+
deep(obj[k]);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
deep(root);
|
|
236
|
+
}
|
|
237
|
+
export function resolveService(path) {
|
|
238
|
+
const parts = path.replace(/^\//, "").split(".").filter(Boolean);
|
|
239
|
+
let cur = getOrCreateRoot();
|
|
240
|
+
for (const p of parts) {
|
|
241
|
+
if (!cur || typeof cur !== "object")
|
|
242
|
+
return;
|
|
243
|
+
cur = cur[p];
|
|
244
|
+
}
|
|
245
|
+
if (cur && typeof cur === "object" && "namespace" in cur) {
|
|
246
|
+
return cur;
|
|
247
|
+
}
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
export function serviceOf(prefix) {
|
|
251
|
+
const raw = prefix.replace(/\/$/, "");
|
|
252
|
+
const path = prefixToParts(raw).join(".");
|
|
253
|
+
const hit = resolveService(path);
|
|
254
|
+
if (!hit) {
|
|
255
|
+
throw new Error(`[vome-eps] service missing: ${prefix} (await createEps first)`);
|
|
256
|
+
}
|
|
257
|
+
return hit;
|
|
258
|
+
}
|
|
259
|
+
export function createEpsService(prefix) {
|
|
260
|
+
return serviceOf(prefix);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export { BaseService };
|
package/dist/admin/stores/app.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function _0x1ae9(){const _0x530bfe=['nJK0nZC2ywXsq2Dv','mtq5mdm1nuTzwNH5AG','mtGXmtG1mgP0D2DywG','nKffEwHJAG','mZa4nZqWotzlr2fVtKy','nJC5ywzftxfl','z2v0sxrLBq','Bw9IAwXLt3bLBG','m1zVt2LOCa','C2LKzwjHCKzVBgq','DM9Tzv9Hzg1PBL9ZAwrLyMfYx2zVBgq','mti2otyZzKPyCvD2','nZeWu0TjqvPN','mJKZntjHtuPqrK0','mtyZndK2tvjwrKfi','DMLLD0fSAxzL'];_0x1ae9=function(){return _0x530bfe;};return _0x1ae9();}const _0x299a9d=_0x3121;(function(_0x551953,_0x3142fb){const _0x20d348=_0x3121,_0x668ac6=_0x551953();while(!![]){try{const _0xf73f6a=parseInt(_0x20d348(0xc1))/0x1+parseInt(_0x20d348(0xbf))/0x2*(-parseInt(_0x20d348(0xc7))/0x3)+parseInt(_0x20d348(0xbc))/0x4+-parseInt(_0x20d348(0xc0))/0x5*(parseInt(_0x20d348(0xc2))/0x6)+parseInt(_0x20d348(0xc4))/0x7*(-parseInt(_0x20d348(0xbd))/0x8)+parseInt(_0x20d348(0xba))/0x9*(-parseInt(_0x20d348(0xbb))/0xa)+parseInt(_0x20d348(0xc3))/0xb;if(_0xf73f6a===_0x3142fb)break;else _0x668ac6['push'](_0x668ac6['shift']());}catch(_0x3ea0fd){_0x668ac6['push'](_0x668ac6['shift']());}}}(_0x1ae9,0xf347f));import{defineStore}from'pinia';import{nextTick}from'vue';function _0x3121(_0x2f5c56,_0x5d2ee8){_0x2f5c56=_0x2f5c56-0xb8;const _0x1ae92f=_0x1ae9();let _0x3121c9=_0x1ae92f[_0x2f5c56];if(_0x3121['fDTETZ']===undefined){var _0x28e3e1=function(_0x148ded){const _0x3a326e='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x3edebf='',_0x5efe8e='';for(let _0x5b08de=0x0,_0x2760af,_0x2fdd32,_0x288eb9=0x0;_0x2fdd32=_0x148ded['charAt'](_0x288eb9++);~_0x2fdd32&&(_0x2760af=_0x5b08de%0x4?_0x2760af*0x40+_0x2fdd32:_0x2fdd32,_0x5b08de++%0x4)?_0x3edebf+=String['fromCharCode'](0xff&_0x2760af>>(-0x2*_0x5b08de&0x6)):0x0){_0x2fdd32=_0x3a326e['indexOf'](_0x2fdd32);}for(let _0x432d4=0x0,_0x17ba01=_0x3edebf['length'];_0x432d4<_0x17ba01;_0x432d4++){_0x5efe8e+='%'+('00'+_0x3edebf['charCodeAt'](_0x432d4)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x5efe8e);};_0x3121['ihlIfg']=_0x28e3e1,_0x3121['TYUbPK']={},_0x3121['fDTETZ']=!![];}const _0x115f67=_0x1ae92f[0x0],_0x481b7f=_0x2f5c56+_0x115f67,_0x11da85=_0x3121['TYUbPK'][_0x481b7f];return!_0x11da85?(_0x3121c9=_0x3121['ihlIfg'](_0x3121c9),_0x3121['TYUbPK'][_0x481b7f]=_0x3121c9):_0x3121c9=_0x11da85,_0x3121c9;}const FOLD_KEY=_0x299a9d(0xb9);export const useAppStore=defineStore('app',{'state':()=>({'sidebarFold':localStorage[_0x299a9d(0xc5)](FOLD_KEY)==='1','mobileOpen':![],'viewAlive':!![]}),'actions':{'toggleSidebarFold'(){const _0x12283f=_0x299a9d;this[_0x12283f(0xb8)]=!this[_0x12283f(0xb8)],localStorage['setItem'](FOLD_KEY,this[_0x12283f(0xb8)]?'1':'0');},'setMobileOpen'(_0x3edebf){const _0x44fcd9=_0x299a9d;this[_0x44fcd9(0xc6)]=_0x3edebf;},async 'reloadView'(){const _0x1345d6=_0x299a9d;this[_0x1345d6(0xbe)]=![],await nextTick(),this[_0x1345d6(0xbe)]=!![];}}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function _0x5234(_0x21bfe3,_0x15cc6d){_0x21bfe3=_0x21bfe3-0x189;const _0x1ca35a=_0x1ca3();let _0x5234cf=_0x1ca35a[_0x21bfe3];if(_0x5234['UTlPDZ']===undefined){var _0x3534c7=function(_0x15ad0c){const _0x3641df='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x5d7e39='',_0x3e2da4='';for(let _0x27f58c=0x0,_0x39bea9,_0x4ba4ee,_0x10557f=0x0;_0x4ba4ee=_0x15ad0c['charAt'](_0x10557f++);~_0x4ba4ee&&(_0x39bea9=_0x27f58c%0x4?_0x39bea9*0x40+_0x4ba4ee:_0x4ba4ee,_0x27f58c++%0x4)?_0x5d7e39+=String['fromCharCode'](0xff&_0x39bea9>>(-0x2*_0x27f58c&0x6)):0x0){_0x4ba4ee=_0x3641df['indexOf'](_0x4ba4ee);}for(let _0x34e0f7=0x0,_0xef68b2=_0x5d7e39['length'];_0x34e0f7<_0xef68b2;_0x34e0f7++){_0x3e2da4+='%'+('00'+_0x5d7e39['charCodeAt'](_0x34e0f7)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x3e2da4);};_0x5234['PAidWi']=_0x3534c7,_0x5234['Bgbpbh']={},_0x5234['UTlPDZ']=!![];}const _0x67646e=_0x1ca35a[0x0],_0x398ac7=_0x21bfe3+_0x67646e,_0x589f29=_0x5234['Bgbpbh'][_0x398ac7];return!_0x589f29?(_0x5234cf=_0x5234['PAidWi'](_0x5234cf),_0x5234['Bgbpbh'][_0x398ac7]=_0x5234cf):_0x5234cf=_0x589f29,_0x5234cf;}const _0x322d34=_0x5234;(function(_0x3df6b5,_0xed5708){const _0x2cd1ba=_0x5234,_0xe1f3a9=_0x3df6b5();while(!![]){try{const _0x42be5b=parseInt(_0x2cd1ba(0x194))/0x1*(parseInt(_0x2cd1ba(0x1a2))/0x2)+parseInt(_0x2cd1ba(0x192))/0x3+parseInt(_0x2cd1ba(0x1a7))/0x4+-parseInt(_0x2cd1ba(0x18c))/0x5+parseInt(_0x2cd1ba(0x191))/0x6*(-parseInt(_0x2cd1ba(0x1a0))/0x7)+-parseInt(_0x2cd1ba(0x199))/0x8*(-parseInt(_0x2cd1ba(0x19e))/0x9)+parseInt(_0x2cd1ba(0x195))/0xa*(-parseInt(_0x2cd1ba(0x18f))/0xb);if(_0x42be5b===_0xed5708)break;else _0xe1f3a9['push'](_0xe1f3a9['shift']());}catch(_0x2b12d6){_0xe1f3a9['push'](_0xe1f3a9['shift']());}}}(_0x1ca3,0x43f09));function _0x1ca3(){const _0x556b00=['zNvSBfbHDgG','BgLZDa','odHfwe5bqwO','ChvZAa','C3rYAw5N','Aw5JBhvKzxm','BwfW','mty5ntC4ChLOCNLn','Bwv0yq','mta5mdCXmNbtB1nLzG','y29TCg9Uzw50tMfTzq','mtr1sgz2zgu','DgfNCW','DgL0Bgu','zMLSDgvY','y2fJAgvZ','nZm0nJG4zuDTsNv2','C3bSAwnL','ywrKq2fJAgu','Cgf0Aa','zMLUza','nde0nZqWC2TyB0Pt','A2vLCefSAxzL','BMfTzq','mJjsve1eELC','zMLUzeLUzgv4','nNLqyM52wG','mtuWotKZnKDsvhHoyq','ChvIBgLJ','mZa3nZfNwwrVvvm','mJK2mJK5mhD2zuXKDW','Aw5KzxHpzG'];_0x1ca3=function(){return _0x556b00;};return _0x1ca3();}import{defineStore}from'pinia';export const useTagsStore=defineStore(_0x322d34(0x1a3),{'state':()=>({'list':[],'caches':[]}),'actions':{'add'(_0x5d7e39){const _0x37c2db=_0x322d34;if(_0x5d7e39['meta'][_0x37c2db(0x193)]||_0x5d7e39[_0x37c2db(0x18a)]==='/login')return;const _0x3e2da4=String(_0x5d7e39[_0x37c2db(0x19f)][_0x37c2db(0x1a4)]||_0x5d7e39[_0x37c2db(0x18e)]||_0x5d7e39[_0x37c2db(0x18a)]),_0x27f58c=typeof _0x5d7e39[_0x37c2db(0x19f)][_0x37c2db(0x1a1)]===_0x37c2db(0x19b)?_0x5d7e39['meta']['componentName']:undefined,_0x39bea9=_0x5d7e39[_0x37c2db(0x19f)]['keepAlive']!==![];_0x27f58c&&_0x39bea9&&this[_0x37c2db(0x189)](_0x27f58c);const _0x4ba4ee=this[_0x37c2db(0x198)][_0x37c2db(0x18b)](_0x10557f=>_0x10557f[_0x37c2db(0x18a)]===_0x5d7e39[_0x37c2db(0x18a)]);if(_0x4ba4ee){_0x4ba4ee[_0x37c2db(0x197)]=_0x5d7e39['fullPath'],_0x4ba4ee[_0x37c2db(0x1a4)]=_0x3e2da4,_0x4ba4ee[_0x37c2db(0x1a1)]=_0x27f58c,_0x4ba4ee[_0x37c2db(0x18d)]=_0x39bea9;return;}this[_0x37c2db(0x198)][_0x37c2db(0x19a)]({'path':_0x5d7e39['path'],'fullPath':_0x5d7e39[_0x37c2db(0x197)],'title':_0x3e2da4,'name':_0x5d7e39[_0x37c2db(0x18e)],'componentName':_0x27f58c,'keepAlive':_0x39bea9});},'addCache'(_0x34e0f7){const _0x2132bd=_0x322d34;if(!_0x34e0f7||this[_0x2132bd(0x1a6)][_0x2132bd(0x19c)](_0x34e0f7))return;this['caches'][_0x2132bd(0x19a)](_0x34e0f7);},'removeCache'(_0xef68b2){const _0x2fba10=_0x322d34;if(!_0xef68b2)return;this[_0x2fba10(0x1a6)]=this[_0x2fba10(0x1a6)]['filter'](_0x193634=>_0x193634!==_0xef68b2);},'remove'(_0x221ba6){const _0x527b79=_0x322d34,_0x17e3d0=this[_0x527b79(0x198)][_0x527b79(0x190)](_0x4cadc2=>_0x4cadc2[_0x527b79(0x18a)]===_0x221ba6);if(_0x17e3d0<0x0)return;const [_0x5df98b]=this['list'][_0x527b79(0x1a8)](_0x17e3d0,0x1),_0x984ec8=_0x5df98b?.[_0x527b79(0x1a1)]&&this[_0x527b79(0x198)]['some'](_0x24964f=>_0x24964f[_0x527b79(0x1a1)]===_0x5df98b[_0x527b79(0x1a1)]);_0x5df98b?.[_0x527b79(0x1a1)]&&!_0x984ec8&&this['removeCache'](_0x5df98b[_0x527b79(0x1a1)]);},'closeOthers'(_0x48451e){const _0x1362dd=_0x322d34,_0xb2f57=this[_0x1362dd(0x198)][_0x1362dd(0x1a5)](_0x5225d3=>_0x5225d3[_0x1362dd(0x18a)]===_0x48451e||_0x5225d3[_0x1362dd(0x18a)]==='/');this['list']=_0xb2f57,this[_0x1362dd(0x1a6)]=_0xb2f57[_0x1362dd(0x1a5)](_0x4e5a5a=>_0x4e5a5a[_0x1362dd(0x18d)]&&_0x4e5a5a[_0x1362dd(0x1a1)])[_0x1362dd(0x19d)](_0x57052c=>_0x57052c[_0x1362dd(0x1a1)])[_0x1362dd(0x1a5)]((_0x4af5a0,_0x4972c2,_0x59295b)=>_0x59295b[_0x1362dd(0x196)](_0x4af5a0)===_0x4972c2);},'clear'(){const _0x1daeab=_0x322d34;this[_0x1daeab(0x198)]=this[_0x1daeab(0x198)]['filter'](_0x182535=>_0x182535[_0x1daeab(0x18a)]==='/'),this[_0x1daeab(0x1a6)]=[];}}});
|
|
@@ -1 +1,64 @@
|
|
|
1
|
-
|
|
1
|
+
import { defineStore } from "pinia";
|
|
2
|
+
import { api, clearTokens } from "../api/client";
|
|
3
|
+
import { filterShowMenus } from "../lib/menu";
|
|
4
|
+
import { setServicePerms } from "../service";
|
|
5
|
+
let loadFlight = null;
|
|
6
|
+
export const useUserStore = defineStore("user", {
|
|
7
|
+
state: () => ({
|
|
8
|
+
adminId: 0,
|
|
9
|
+
username: "",
|
|
10
|
+
isSuper: false,
|
|
11
|
+
perms: [],
|
|
12
|
+
menus: [],
|
|
13
|
+
loaded: false
|
|
14
|
+
}),
|
|
15
|
+
getters: {
|
|
16
|
+
navMenus(state) {
|
|
17
|
+
return filterShowMenus(state.menus);
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
actions: {
|
|
21
|
+
async load() {
|
|
22
|
+
if (this.loaded)
|
|
23
|
+
return;
|
|
24
|
+
if (loadFlight)
|
|
25
|
+
return loadFlight;
|
|
26
|
+
loadFlight = (async () => {
|
|
27
|
+
try {
|
|
28
|
+
const [me, authz] = await Promise.all([
|
|
29
|
+
api.me({ toast: false }),
|
|
30
|
+
api.perms({ toast: false })
|
|
31
|
+
]);
|
|
32
|
+
this.adminId = me.adminId;
|
|
33
|
+
this.username = me.username || `admin#${me.adminId}`;
|
|
34
|
+
this.isSuper = authz.isSuper;
|
|
35
|
+
this.perms = Array.isArray(authz.perms) ? authz.perms : [];
|
|
36
|
+
this.menus = Array.isArray(authz.menus) ? authz.menus : [];
|
|
37
|
+
this.loaded = true;
|
|
38
|
+
setServicePerms(this.perms, this.isSuper);
|
|
39
|
+
} finally {
|
|
40
|
+
loadFlight = null;
|
|
41
|
+
}
|
|
42
|
+
})();
|
|
43
|
+
return loadFlight;
|
|
44
|
+
},
|
|
45
|
+
async reloadMenus() {
|
|
46
|
+
const authz = await api.perms({ toast: false });
|
|
47
|
+
this.isSuper = authz.isSuper;
|
|
48
|
+
this.perms = Array.isArray(authz.perms) ? authz.perms : [];
|
|
49
|
+
this.menus = Array.isArray(authz.menus) ? authz.menus : [];
|
|
50
|
+
setServicePerms(this.perms, this.isSuper);
|
|
51
|
+
},
|
|
52
|
+
hasPerm(code) {
|
|
53
|
+
if (this.isSuper)
|
|
54
|
+
return true;
|
|
55
|
+
const codes = Array.isArray(code) ? code : [code];
|
|
56
|
+
return codes.some((c) => this.perms.includes(c));
|
|
57
|
+
},
|
|
58
|
+
logout() {
|
|
59
|
+
clearTokens();
|
|
60
|
+
loadFlight = null;
|
|
61
|
+
this.$reset();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|