vome-core 0.0.12 → 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.d.ts +4 -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
|
+
}
|
|
@@ -2,7 +2,10 @@ import { BaseService } from './base';
|
|
|
2
2
|
type ServiceRoot = Eps.Service & {
|
|
3
3
|
request: BaseService['request'];
|
|
4
4
|
};
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Proxy:任意模块读 service.xxx 都落到 globalThis 根上。
|
|
7
|
+
* 避免 Vite 多实例下 `export const service = serviceRoot` 绑到不同对象。
|
|
8
|
+
*/
|
|
6
9
|
export declare const service: ServiceRoot;
|
|
7
10
|
/** 从 EPS 全量重建 service 树(无写死业务路由) */
|
|
8
11
|
export declare function createEps(force?: boolean): Promise<any>;
|
|
@@ -1 +1,263 @@
|
|
|
1
|
-
const _0x1a6344=_0x48ef;(function(_0x66325e,_0x3a4183){const _0x11e64f=_0x48ef,_0x1898d1=_0x66325e();while(!![]){try{const _0x2212a6=parseInt(_0x11e64f(0x14f))/0x1+parseInt(_0x11e64f(0x143))/0x2+parseInt(_0x11e64f(0x152))/0x3+parseInt(_0x11e64f(0x13d))/0x4+parseInt(_0x11e64f(0x162))/0x5*(parseInt(_0x11e64f(0x14a))/0x6)+-parseInt(_0x11e64f(0x15c))/0x7+-parseInt(_0x11e64f(0x163))/0x8;if(_0x2212a6===_0x3a4183)break;else _0x1898d1['push'](_0x1898d1['shift']());}catch(_0x295d5b){_0x1898d1['push'](_0x1898d1['shift']());}}}(_0x46d6,0xde0ad));import{loadEps}from'../lib/eps';import{BaseService}from'./base';const SIDE_ID=_0x1a6344(0x13c);function toCamel(_0x1a5aad){const _0x28d2a0=_0x1a6344;return _0x1a5aad[_0x28d2a0(0x155)](/([^-])(?:-+([^-]))/g,(_0x3600dc,_0x43c434,_0x14c453)=>_0x43c434+String(_0x14c453)[_0x28d2a0(0x160)]());}function methodName(_0x1c5c95){const _0x8bf99b=_0x1a6344;return _0x1c5c95[_0x8bf99b(0x155)](/^\//,'')[_0x8bf99b(0x155)](/[:,\s/-]/g,'');}function isValidName(_0x52fa07){const _0x146fa7=_0x1a6344;return Boolean(_0x52fa07)&&!['{','}',':'][_0x146fa7(0x138)](_0x491f2c=>_0x52fa07[_0x146fa7(0x165)](_0x491f2c));}function resolvePermCode(_0x3f5bf3,_0x1bf9fd){const _0x4a3cbd=_0x1a6344,_0x146bec=_0x3f5bf3[_0x4a3cbd(0x155)](/^\//,'')['split']('/')[_0x4a3cbd(0x16c)](Boolean),_0x3db4d1=_0x146bec[0x1]||_0x146bec[0x0]||_0x4a3cbd(0x144);let _0x4a919e=_0x146bec[_0x4a3cbd(0x14d)](0x2)[_0x4a3cbd(0x16f)](':');if(_0x4a919e===_0x3db4d1)_0x4a919e=_0x3db4d1;else _0x4a919e[_0x4a3cbd(0x15a)](_0x3db4d1+':')&&(_0x4a919e=_0x4a919e['slice'](_0x3db4d1[_0x4a3cbd(0x15d)]+0x1));const _0x35d89d=_0x3db4d1+'-';if(_0x4a919e[_0x4a3cbd(0x15a)](_0x35d89d))_0x4a919e=_0x4a919e[_0x4a3cbd(0x14d)](_0x35d89d[_0x4a3cbd(0x15d)]);_0x4a919e=_0x4a919e[_0x4a3cbd(0x155)](/-/g,':');if(!_0x4a919e)_0x4a919e=_0x3db4d1;return _0x3db4d1+':'+_0x4a919e+':'+_0x1bf9fd;}function prefixToParts(_0x7f2e17){const _0x35da2a=_0x1a6344,_0x4a370b=_0x7f2e17[_0x35da2a(0x155)](/^\//,'');return _0x4a370b[_0x35da2a(0x155)](new RegExp('^'+SIDE_ID+'/?'),'')[_0x35da2a(0x15e)]('/')['filter'](Boolean)[_0x35da2a(0x158)](toCamel);}function bindCrud(_0x1da546,_0x247cb0){const _0xec930d=_0x1a6344,_0x4a3628=BaseService[_0xec930d(0x16a)];for(const _0x102eb1 of[_0xec930d(0x154),'page',_0xec930d(0x146),_0xec930d(0x164),_0xec930d(0x148),_0xec930d(0x139),'delete',_0xec930d(0x13b)]){const _0x4f7b33=_0x4a3628[_0x102eb1];typeof _0x4f7b33===_0xec930d(0x145)&&(_0x1da546[_0x102eb1]=_0x4f7b33[_0xec930d(0x140)](_0x247cb0));}}function bindApis(_0x2dee57,_0x31471f,_0x5cca6a){const _0x1ed431=_0x1a6344;_0x2dee57[_0x1ed431(0x157)]||={};for(const _0x48db09 of _0x5cca6a){const _0xd36646=methodName(_0x48db09[_0x1ed431(0x171)]);if(!isValidName(_0xd36646)||/[-:]/g[_0x1ed431(0x156)](_0xd36646))continue;const _0x6c9549=(_0x48db09['method']||_0x1ed431(0x16e))[_0x1ed431(0x166)]();_0x2dee57[_0xd36646]=function(_0x143c6e){const _0x2a9948=_0x1ed431;return this[_0x2a9948(0x154)]({'url':_0x48db09['path'][_0x2a9948(0x15a)]('/')?_0x48db09['path']:'/'+_0x48db09['path'],'method':_0x6c9549,[_0x6c9549===_0x2a9948(0x14c)?_0x2a9948(0x15f):_0x2a9948(0x13e)]:_0x143c6e});}[_0x1ed431(0x140)](_0x31471f),_0x2dee57[_0x1ed431(0x157)][_0xd36646]=_0x48db09['perms']?.[0x0]||resolvePermCode('/'+_0x2dee57[_0x1ed431(0x167)],_0xd36646);}}function createLeaf(_0x3d5ca3,_0x35b44f=[]){const _0x27de7c=_0x1a6344,_0x103b7f=_0x3d5ca3['replace'](/^\//,''),_0x2a345d=new BaseService(_0x103b7f),_0x2587e8=_0x2a345d;return _0x2587e8[_0x27de7c(0x167)]=_0x103b7f,_0x2587e8[_0x27de7c(0x157)]={},_0x2587e8[_0x27de7c(0x150)]={},bindCrud(_0x2587e8,_0x2a345d),bindApis(_0x2587e8,_0x2a345d,_0x35b44f),_0x2587e8;}function attachLeaf(_0x23bde3,_0x3d5dcb,_0x1bd8f0=[]){const _0x436c77=_0x1a6344,_0x4f976f=_0x3d5dcb[_0x436c77(0x155)](/^\//,''),_0x2f7578=prefixToParts(_0x3d5dcb);if(!_0x2f7578['length'])return;let _0x4aeb56=_0x23bde3;for(let _0x25027f=0x0;_0x25027f<_0x2f7578['length'];_0x25027f++){const _0x1e712e=_0x2f7578[_0x25027f],_0x2d7c12=_0x25027f===_0x2f7578[_0x436c77(0x15d)]-0x1;if(!_0x2d7c12){const _0x7b95ef=_0x4aeb56[_0x1e712e];(!_0x7b95ef||typeof _0x7b95ef!=='object'||'namespace'in _0x7b95ef)&&(_0x4aeb56[_0x1e712e]={});_0x4aeb56=_0x4aeb56[_0x1e712e];continue;}const _0x4ff819=createLeaf(_0x4f976f,_0x1bd8f0);return _0x4aeb56[_0x1e712e]=_0x4ff819,_0x4ff819;}return;}function buildFromEps(_0x15f873){const _0x59d704=_0x1a6344,_0x5b5a5f=Object[_0x59d704(0x14b)](_0x15f873)[_0x59d704(0x13f)]();for(const _0x1e0506 of _0x5b5a5f){if(!_0x1e0506?.[_0x59d704(0x161)])continue;const _0x5156ee=attachLeaf(serviceRoot,_0x1e0506['prefix'],_0x1e0506[_0x59d704(0x14e)]||[]);if(_0x5156ee){const _0x3a1d4a=_0x1e0506['pageQueryOp'];_0x3a1d4a&&(_0x5156ee[_0x59d704(0x13a)]={'fieldEq':_0x3a1d4a['fieldEq'],'fieldLike':_0x3a1d4a[_0x59d704(0x142)],'fieldArray':_0x3a1d4a[_0x59d704(0x147)],'fieldRange':_0x3a1d4a[_0x59d704(0x149)],'keyWordLikeFields':_0x3a1d4a['keyWordLikeFields']});}}}function normalizeEpsMap(_0x4f92e2){const _0x1991dd=_0x1a6344;if(!_0x4f92e2||typeof _0x4f92e2!=='object')return{};const _0xe4ac4e=_0x4f92e2;if(_0x1991dd(0x141)in _0xe4ac4e&&'data'in _0xe4ac4e&&_0xe4ac4e['data']&&typeof _0xe4ac4e['data']==='object'&&!Array[_0x1991dd(0x16d)](_0xe4ac4e['data']))return _0xe4ac4e[_0x1991dd(0x15f)];return _0x4f92e2;}function countPrefixedEntities(_0x233db5){const _0x852de3=_0x1a6344;return Object[_0x852de3(0x14b)](_0x233db5)[_0x852de3(0x13f)]()['filter'](_0x40636c=>_0x40636c&&typeof _0x40636c===_0x852de3(0x151)&&Boolean(_0x40636c[_0x852de3(0x161)]))['length'];}function createServiceRoot(){const _0x2d970b=_0x1a6344,_0x16d21e=new BaseService();return{'request':_0x16d21e[_0x2d970b(0x154)][_0x2d970b(0x140)](_0x16d21e)};}const g=globalThis;function getOrCreateRoot(){const _0x168dd0=_0x1a6344;return!g[_0x168dd0(0x159)]&&(g[_0x168dd0(0x159)]=createServiceRoot()),g[_0x168dd0(0x159)];}const serviceRoot=getOrCreateRoot();function resetServiceModules(){const _0x4011e5=_0x1a6344;for(const _0xebac2a of Object[_0x4011e5(0x168)](serviceRoot)){if(_0xebac2a===_0x4011e5(0x154))continue;delete serviceRoot[_0xebac2a];}}export const service=serviceRoot;export async function createEps(_0x3cf870=![]){const _0x407281=_0x1a6344;if(!_0x3cf870&&g[_0x407281(0x153)])return g['__vome_admin_eps__'];const _0x31568f=((async()=>{const _0x63a90f=_0x407281,_0x468cf2=await loadEps(_0x3cf870)||{},_0x4ce15b=normalizeEpsMap(_0x468cf2),_0x370ed3=countPrefixedEntities(_0x4ce15b);if(!_0x370ed3)throw new Error(_0x63a90f(0x15b));resetServiceModules(),buildFromEps(_0x4ce15b);const _0x2a444b=serviceRoot[_0x63a90f(0x144)];if(!_0x2a444b||typeof _0x2a444b!==_0x63a90f(0x151))throw new Error(_0x63a90f(0x170));return serviceRoot;})());g[_0x407281(0x153)]=_0x31568f;try{return await _0x31568f;}catch(_0x298c8b){g['__vome_admin_eps__']=null;throw _0x298c8b;}}if(undefined){}export function setServicePerms(_0x3bc280,_0xbf280e=![]){const _0x20a813=_0x3bc280||[];function _0x38cd5e(_0x4e10f6){const _0x14bdfa=_0x48ef;if(!_0x4e10f6||typeof _0x4e10f6!=='object')return;const _0x25f79a=_0x4e10f6;if(_0x25f79a[_0x14bdfa(0x157)]&&_0x25f79a[_0x14bdfa(0x167)]){_0x25f79a['_permission']={};for(const _0x1dbbf5 of Object[_0x14bdfa(0x168)](_0x25f79a['permission'])){if(_0xbf280e){_0x25f79a['_permission'][_0x1dbbf5]=!![];continue;}const _0x120339=_0x25f79a['permission'][_0x1dbbf5];_0x25f79a['_permission'][_0x1dbbf5]=_0x20a813[_0x14bdfa(0x165)](_0x120339)||_0x20a813[_0x14bdfa(0x138)](_0x690511=>_0x690511[_0x14bdfa(0x155)](/:/g,'/')[_0x14bdfa(0x165)](_0x25f79a[_0x14bdfa(0x167)][_0x14bdfa(0x155)](/^admin\//,'')+'/'+_0x1dbbf5));}return;}for(const _0x18069f of Object['keys'](_0x25f79a)){if(_0x18069f===_0x14bdfa(0x154))continue;_0x38cd5e(_0x25f79a[_0x18069f]);}}_0x38cd5e(serviceRoot);}function _0x48ef(_0x1c3eca,_0x30be1c){_0x1c3eca=_0x1c3eca-0x138;const _0x46d6d7=_0x46d6();let _0x48ef41=_0x46d6d7[_0x1c3eca];if(_0x48ef['NioKTO']===undefined){var _0x1f6cb6=function(_0x4e7ed1){const _0x326086='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x1a5aad='',_0x3600dc='';for(let _0x43c434=0x0,_0x14c453,_0x1c5c95,_0x52fa07=0x0;_0x1c5c95=_0x4e7ed1['charAt'](_0x52fa07++);~_0x1c5c95&&(_0x14c453=_0x43c434%0x4?_0x14c453*0x40+_0x1c5c95:_0x1c5c95,_0x43c434++%0x4)?_0x1a5aad+=String['fromCharCode'](0xff&_0x14c453>>(-0x2*_0x43c434&0x6)):0x0){_0x1c5c95=_0x326086['indexOf'](_0x1c5c95);}for(let _0x491f2c=0x0,_0x3f5bf3=_0x1a5aad['length'];_0x491f2c<_0x3f5bf3;_0x491f2c++){_0x3600dc+='%'+('00'+_0x1a5aad['charCodeAt'](_0x491f2c)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x3600dc);};_0x48ef['ZWpqkg']=_0x1f6cb6,_0x48ef['CcOfCd']={},_0x48ef['NioKTO']=!![];}const _0x2f5d7a=_0x46d6d7[0x0],_0x5282bf=_0x1c3eca+_0x2f5d7a,_0x2692cf=_0x48ef['CcOfCd'][_0x5282bf];return!_0x2692cf?(_0x48ef41=_0x48ef['ZWpqkg'](_0x48ef41),_0x48ef['CcOfCd'][_0x5282bf]=_0x48ef41):_0x48ef41=_0x2692cf,_0x48ef41;}export function resolveService(_0x24fd46){const _0x131a2c=_0x1a6344,_0x14f824=_0x24fd46['replace'](/^\//,'')[_0x131a2c(0x15e)]('.')['filter'](Boolean);let _0x485d3b=serviceRoot;for(const _0x4a15ea of _0x14f824){if(!_0x485d3b||typeof _0x485d3b!==_0x131a2c(0x151))return;_0x485d3b=_0x485d3b[_0x4a15ea];}if(_0x485d3b&&typeof _0x485d3b===_0x131a2c(0x151)&&_0x131a2c(0x167)in _0x485d3b)return _0x485d3b;return;}export function serviceOf(_0x4d3c1b){const _0x1b1f32=_0x1a6344,_0x3125bc=_0x4d3c1b[_0x1b1f32(0x155)](/\/$/,''),_0x4755bb=prefixToParts(_0x3125bc)[_0x1b1f32(0x16f)]('.'),_0x59e89e=resolveService(_0x4755bb);if(!_0x59e89e)throw new Error(_0x1b1f32(0x169)+_0x4d3c1b+_0x1b1f32(0x16b));return _0x59e89e;}function _0x46d6(){const _0x52bcb9=['BwfW','x192B21Lx2fKBwLUx3nLCNzPy2vFxW','C3rHCNrZv2L0Aa','w3zVBwuTzxbZxsbLBxb0EsbVCIbPBNzHBgLKiokaLcbLBMfIBguGDM9Tzs5LChmGyw5KignOzwnRieDfvcaVywrTAw4VyMfZzs9VCgvUl2vWCYaOzxHWzwn0ig1VzhvSzsbTyxaGD2L0AcbWCMvMAxGP','mta0mJKWnZzOtezZBhG','BgvUz3rO','C3bSAxq','zgf0yq','Dg9vChbLCKnHC2u','ChjLzML4','mJmZnuXTq3zMBa','mta0nZu1nJHWCgn1D1G','Aw5MBW','Aw5JBhvKzxm','Dg9mB3DLCKnHC2u','BMfTzxnWywnL','A2v5CW','w3zVBwuTzxbZxsbZzxj2AwnLig1PC3nPBMC6ia','ChjVDg90ExbL','icHHD2fPDcbJCMvHDgvfChmGzMLYC3qP','zMLSDgvY','AxnbCNjHEq','z2v0','AM9PBG','w3zVBwuTzxbZxsbTB3vUDcbMywLSzwq6ihnLCNzPy2uUyMfZzsbTAxnZAw5NigfMDgvYievquYbHChbSEq','Cgf0Aa','C29Tzq','DxbKyxrL','C2vHCMnO','CMvZDg9Yzq','ywrTAw4','ndK1odm0mfzLD3PvyW','CgfYyw1Z','zMXHDa','yMLUza','y29Kzq','zMLLBgrmAwTL','mJy1nte4og1sDLDhCG','yMfZzq','zNvUy3rPB24','BgLZDa','zMLLBgrbCNjHEq','ywrK','zMLLBgrsyw5Nzq','mtu5me1gCvbhEa','DMfSDwvZ','Cg9ZDa','C2XPy2u','yxbP','mJi3ntyZtu9Zv2ry','x3bLCM1PC3nPB24','B2jQzwn0','mJm3mdKWnLnXCw5AAG','x192B21Lx2fKBwLUx2vWC19F','CMvXDwvZDa','CMvWBgfJzq','DgvZDa','CgvYBwLZC2LVBG'];_0x46d6=function(){return _0x52bcb9;};return _0x46d6();}export function createEpsService(_0x5abeda){return serviceOf(_0x5abeda);}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
|
-
(function(
|
|
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
|
+
});
|