vome-core 0.0.17 → 0.0.18

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.
Files changed (45) hide show
  1. package/dist/admin/api/client.js +2 -0
  2. package/dist/admin/config/plugin-dev.js +1 -1
  3. package/dist/admin/crud/config.js +1 -1
  4. package/dist/admin/crud/confirm.js +1 -1
  5. package/dist/admin/crud/dict.js +1 -1
  6. package/dist/admin/crud/index.js +1 -1
  7. package/dist/admin/crud/key.js +1 -1
  8. package/dist/admin/crud/mitt.js +1 -1
  9. package/dist/admin/crud/plugins.js +1 -1
  10. package/dist/admin/crud/span.js +1 -1
  11. package/dist/admin/crud/style.js +1 -1
  12. package/dist/admin/crud/validate.js +1 -1
  13. package/dist/admin/directives/perm.js +1 -1
  14. package/dist/admin/hooks/useUpload.js +1 -1
  15. package/dist/admin/hooks/useVome.d.ts +3 -1
  16. package/dist/admin/lib/browser.js +1 -1
  17. package/dist/admin/lib/cn.js +1 -1
  18. package/dist/admin/lib/dialog-float.js +1 -1
  19. package/dist/admin/lib/eps.d.ts +2 -11
  20. package/dist/admin/lib/eps.js +7 -33
  21. package/dist/admin/lib/menu.js +1 -1
  22. package/dist/admin/lib/tree.js +1 -1
  23. package/dist/admin/lib/upload.js +1 -1
  24. package/dist/admin/service/base.d.ts +2 -27
  25. package/dist/admin/service/base.js +1 -76
  26. package/dist/admin/service/index.d.ts +10 -16
  27. package/dist/admin/service/index.js +31 -259
  28. package/dist/client/base.d.ts +28 -0
  29. package/dist/client/base.js +77 -0
  30. package/dist/client/configure.d.ts +9 -0
  31. package/dist/client/configure.js +10 -0
  32. package/dist/client/eps.d.ts +12 -0
  33. package/dist/client/eps.js +42 -0
  34. package/dist/client/index.d.ts +4 -0
  35. package/dist/client/index.js +22 -0
  36. package/dist/client/service.d.ts +31 -0
  37. package/dist/client/service.js +299 -0
  38. package/dist/client/vite-plugin-eps.d.ts +42 -0
  39. package/dist/client/vite-plugin-eps.js +266 -0
  40. package/dist/index.js +1 -1
  41. package/dist/server/index.js +1 -1
  42. package/dist/shared/index.js +1 -1
  43. package/dist/shared/tree.js +1 -1
  44. package/package.json +18 -4
  45. package/typings/admin/comm/eps.d.ts +48 -0
@@ -1,11 +1,2 @@
1
- export type EpsSide = 'admin' | 'app';
2
- /** 拉取 EPS(默认 admin);公开接口失败不弹 toast */
3
- export declare function loadEps(force?: boolean, side?: EpsSide): Promise<any>;
4
- /** 并行拉取 admin + app */
5
- export declare function loadAllEps(force?: boolean): Promise<{
6
- admin: any;
7
- app: any;
8
- }>;
9
- export declare function getEps(side?: EpsSide): any;
10
- /** 按 prefix 找实体描述,如 /admin/base/user */
11
- export declare function findEpsEntity(prefix: string, side?: EpsSide): any;
1
+ export { loadEps, loadAllEps, getEps, findEpsEntity, type EpsSide, } from '../../client';
2
+ import '../api/client';
@@ -1,33 +1,7 @@
1
- import { request } from "../api/client";
2
- const EPS_URL = {
3
- admin: "/admin/base/open/eps",
4
- app: "/app/base/open/eps"
5
- };
6
- const cache = {
7
- admin: null,
8
- app: null
9
- };
10
- export async function loadEps(force = false, side = "admin") {
11
- if (cache[side] && !force)
12
- return cache[side];
13
- cache[side] = await request(EPS_URL[side], { toast: false }) || {};
14
- return cache[side];
15
- }
16
- export async function loadAllEps(force = false) {
17
- await Promise.all([loadEps(force, "admin"), loadEps(force, "app")]);
18
- return { admin: cache.admin, app: cache.app };
19
- }
20
- export function getEps(side = "admin") {
21
- return cache[side];
22
- }
23
- export function findEpsEntity(prefix, side = "admin") {
24
- const map = cache[side];
25
- if (!map)
26
- return;
27
- for (const list of Object.values(map)) {
28
- const hit = list.find((e) => e.prefix === prefix || e.prefix === prefix.replace(/\/$/, ""));
29
- if (hit)
30
- return hit;
31
- }
32
- return;
33
- }
1
+ export {
2
+ loadEps,
3
+ loadAllEps,
4
+ getEps,
5
+ findEpsEntity
6
+ } from "../../client";
7
+ import"../api/client";
@@ -1 +1 @@
1
- (function(_0x9439a,_0x48720){const _0x236e1a=_0x38be,_0x40db3e=_0x9439a();while(!![]){try{const _0x12557f=parseInt(_0x236e1a(0xd1))/0x1*(-parseInt(_0x236e1a(0xc7))/0x2)+parseInt(_0x236e1a(0xd7))/0x3*(parseInt(_0x236e1a(0xca))/0x4)+parseInt(_0x236e1a(0xcb))/0x5+-parseInt(_0x236e1a(0xd2))/0x6*(-parseInt(_0x236e1a(0xc9))/0x7)+-parseInt(_0x236e1a(0xcc))/0x8+parseInt(_0x236e1a(0xd6))/0x9+parseInt(_0x236e1a(0xcf))/0xa*(-parseInt(_0x236e1a(0xc6))/0xb);if(_0x12557f===_0x48720)break;else _0x40db3e['push'](_0x40db3e['shift']());}catch(_0x13a49){_0x40db3e['push'](_0x40db3e['shift']());}}}(_0x5a70,0xe2769));function _0x38be(_0x30f5b4,_0x550a0e){_0x30f5b4=_0x30f5b4-0xc6;const _0x5a708c=_0x5a70();let _0x38be82=_0x5a708c[_0x30f5b4];if(_0x38be['WqukwD']===undefined){var _0x276b9f=function(_0x49c91a){const _0x52af0c='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x27921d='',_0x14f29f='';for(let _0x9a641a=0x0,_0x4bb13c,_0x3719ec,_0x57b216=0x0;_0x3719ec=_0x49c91a['charAt'](_0x57b216++);~_0x3719ec&&(_0x4bb13c=_0x9a641a%0x4?_0x4bb13c*0x40+_0x3719ec:_0x3719ec,_0x9a641a++%0x4)?_0x27921d+=String['fromCharCode'](0xff&_0x4bb13c>>(-0x2*_0x9a641a&0x6)):0x0){_0x3719ec=_0x52af0c['indexOf'](_0x3719ec);}for(let _0x6fef2c=0x0,_0x519de1=_0x27921d['length'];_0x6fef2c<_0x519de1;_0x6fef2c++){_0x14f29f+='%'+('00'+_0x27921d['charCodeAt'](_0x6fef2c)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x14f29f);};_0x38be['qobxfs']=_0x276b9f,_0x38be['aNEjhA']={},_0x38be['WqukwD']=!![];}const _0x415363=_0x5a708c[0x0],_0x3d4a7c=_0x30f5b4+_0x415363,_0x5a72d5=_0x38be['aNEjhA'][_0x3d4a7c];return!_0x5a72d5?(_0x38be82=_0x38be['qobxfs'](_0x38be82),_0x38be['aNEjhA'][_0x3d4a7c]=_0x38be82):_0x38be82=_0x5a72d5,_0x38be82;}export function filterShowMenus(_0x27921d){const _0x262307=_0x38be;if(!Array[_0x262307(0xd4)](_0x27921d)||!_0x27921d[_0x262307(0xd0)])return[];return _0x27921d[_0x262307(0xd8)](_0x14f29f=>_0x14f29f&&_0x14f29f[_0x262307(0xd5)]!==![])[_0x262307(0xc8)](_0x9a641a=>({..._0x9a641a,'children':_0x9a641a['children']?.[_0x262307(0xd0)]?filterShowMenus(_0x9a641a[_0x262307(0xcd)]):undefined}))[_0x262307(0xd8)](_0x4bb13c=>{const _0x5056f8=_0x262307,_0x3719ec=Number(_0x4bb13c[_0x5056f8(0xd3)]);return _0x3719ec===0x0||_0x3719ec===0x1&&_0x4bb13c[_0x5056f8(0xce)]||(_0x4bb13c[_0x5056f8(0xcd)]?.[_0x5056f8(0xd0)]??0x0)>0x0;});}function _0x5a70(){const _0x441934=['BgvUz3rO','mJzJtNDIswW','nNzcz0Pmua','DhLWzq','AxnbCNjHEq','AxntAg93','mteYmde4ndf4ze1pwuK','ndqWmdq5CxvzDfbi','zMLSDgvY','nJe1odC5yvvNs0Pq','mtiXnZK2txHlyLvi','BwfW','mti4odG1ntrXwhjVq1m','mZzQALbUtw4','mJGXoduZnxfXBMvMua','odaYndu2mgzwvhrRCG','y2HPBgrYzw4','CM91DgvY','mJyWsurNwhfS'];_0x5a70=function(){return _0x441934;};return _0x5a70();}
1
+ (function(_0x378045,_0x55cc3b){const _0x4d92c7=_0x1fb9,_0x13182d=_0x378045();while(!![]){try{const _0x4173a1=-parseInt(_0x4d92c7(0x188))/0x1+-parseInt(_0x4d92c7(0x186))/0x2*(parseInt(_0x4d92c7(0x195))/0x3)+-parseInt(_0x4d92c7(0x18c))/0x4*(parseInt(_0x4d92c7(0x192))/0x5)+-parseInt(_0x4d92c7(0x18a))/0x6+parseInt(_0x4d92c7(0x18b))/0x7*(parseInt(_0x4d92c7(0x18d))/0x8)+-parseInt(_0x4d92c7(0x196))/0x9+parseInt(_0x4d92c7(0x191))/0xa;if(_0x4173a1===_0x55cc3b)break;else _0x13182d['push'](_0x13182d['shift']());}catch(_0x466da3){_0x13182d['push'](_0x13182d['shift']());}}}(_0x443f,0xf1ed1));function _0x1fb9(_0xbf441c,_0x6b7e4e){_0xbf441c=_0xbf441c-0x186;const _0x443fbb=_0x443f();let _0x1fb9ab=_0x443fbb[_0xbf441c];if(_0x1fb9['VvsUkZ']===undefined){var _0x1355c4=function(_0x2a11db){const _0x5edbaa='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x4e8d28='',_0x16f813='';for(let _0x562159=0x0,_0x35fc01,_0x2aa6dc,_0x5e6800=0x0;_0x2aa6dc=_0x2a11db['charAt'](_0x5e6800++);~_0x2aa6dc&&(_0x35fc01=_0x562159%0x4?_0x35fc01*0x40+_0x2aa6dc:_0x2aa6dc,_0x562159++%0x4)?_0x4e8d28+=String['fromCharCode'](0xff&_0x35fc01>>(-0x2*_0x562159&0x6)):0x0){_0x2aa6dc=_0x5edbaa['indexOf'](_0x2aa6dc);}for(let _0x2634b0=0x0,_0xbe99d8=_0x4e8d28['length'];_0x2634b0<_0xbe99d8;_0x2634b0++){_0x16f813+='%'+('00'+_0x4e8d28['charCodeAt'](_0x2634b0)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x16f813);};_0x1fb9['jXmGRS']=_0x1355c4,_0x1fb9['tViQTP']={},_0x1fb9['VvsUkZ']=!![];}const _0x4e42ac=_0x443fbb[0x0],_0x52bd9f=_0xbf441c+_0x4e42ac,_0x37d00d=_0x1fb9['tViQTP'][_0x52bd9f];return!_0x37d00d?(_0x1fb9ab=_0x1fb9['jXmGRS'](_0x1fb9ab),_0x1fb9['tViQTP'][_0x52bd9f]=_0x1fb9ab):_0x1fb9ab=_0x37d00d,_0x1fb9ab;}function _0x443f(){const _0x1fb1ce=['DhLWzq','CM91DgvY','BwfW','ndK3mJe2mtbczLfHEfm','odvuBufAEeq','y2HPBgrYzw4','BgvUz3rO','mti3odnvwxPuCuK','mtqWmJaYme9fEe1qAa','nJK4BgfxuKXX','AxnbCNjHEq','mZK0mty0veDQB2vy','zMLSDgvY','mta4otu2mtbmCg5mweK','mte2odKWmKL4A0Xuva','ndiZmdG4zxb5uhLi','odbPDgjlr1O'];_0x443f=function(){return _0x1fb1ce;};return _0x443f();}export function filterShowMenus(_0x4e8d28){const _0x919750=_0x1fb9;if(!Array[_0x919750(0x187)](_0x4e8d28)||!_0x4e8d28['length'])return[];return _0x4e8d28[_0x919750(0x189)](_0x16f813=>_0x16f813&&_0x16f813['isShow']!==![])[_0x919750(0x190)](_0x562159=>({..._0x562159,'children':_0x562159[_0x919750(0x193)]?.['length']?filterShowMenus(_0x562159[_0x919750(0x193)]):undefined}))[_0x919750(0x189)](_0x35fc01=>{const _0x59b2d5=_0x919750,_0x2aa6dc=Number(_0x35fc01[_0x59b2d5(0x18e)]);return _0x2aa6dc===0x0||_0x2aa6dc===0x1&&_0x35fc01[_0x59b2d5(0x18f)]||(_0x35fc01[_0x59b2d5(0x193)]?.[_0x59b2d5(0x194)]??0x0)>0x0;});}
@@ -1 +1 @@
1
- function _0x58fb(_0x5410c9,_0x157cc2){_0x5410c9=_0x5410c9-0x134;var _0x1196b7=_0x1196();var _0x58fb3f=_0x1196b7[_0x5410c9];if(_0x58fb['yKylSO']===undefined){var _0x412370=function(_0x38ac19){var _0x20ec6a='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var _0x50161c='',_0x4799bb='';for(var _0x7400d4=0x0,_0x4e65f9,_0x49a279,_0x5ce3d6=0x0;_0x49a279=_0x38ac19['charAt'](_0x5ce3d6++);~_0x49a279&&(_0x4e65f9=_0x7400d4%0x4?_0x4e65f9*0x40+_0x49a279:_0x49a279,_0x7400d4++%0x4)?_0x50161c+=String['fromCharCode'](0xff&_0x4e65f9>>(-0x2*_0x7400d4&0x6)):0x0){_0x49a279=_0x20ec6a['indexOf'](_0x49a279);}for(var _0x2030a2=0x0,_0x123458=_0x50161c['length'];_0x2030a2<_0x123458;_0x2030a2++){_0x4799bb+='%'+('00'+_0x50161c['charCodeAt'](_0x2030a2)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x4799bb);};_0x58fb['HuqwPz']=_0x412370,_0x58fb['nQjryw']={},_0x58fb['yKylSO']=!![];}var _0x5d6e16=_0x1196b7[0x0],_0x12cab0=_0x5410c9+_0x5d6e16,_0x52fa47=_0x58fb['nQjryw'][_0x12cab0];return!_0x52fa47?(_0x58fb3f=_0x58fb['HuqwPz'](_0x58fb3f),_0x58fb['nQjryw'][_0x12cab0]=_0x58fb3f):_0x58fb3f=_0x52fa47,_0x58fb3f;}(function(_0x251bb9,_0x3df1b6){var _0x3a449c=_0x58fb,_0x429cb7=_0x251bb9();while(!![]){try{var _0x2da6c2=parseInt(_0x3a449c(0x138))/0x1+-parseInt(_0x3a449c(0x13c))/0x2*(parseInt(_0x3a449c(0x137))/0x3)+-parseInt(_0x3a449c(0x135))/0x4+-parseInt(_0x3a449c(0x13b))/0x5*(-parseInt(_0x3a449c(0x134))/0x6)+parseInt(_0x3a449c(0x136))/0x7+-parseInt(_0x3a449c(0x139))/0x8+parseInt(_0x3a449c(0x13a))/0x9;if(_0x2da6c2===_0x3df1b6)break;else _0x429cb7['push'](_0x429cb7['shift']());}catch(_0x47351a){_0x429cb7['push'](_0x429cb7['shift']());}}}(_0x1196,0xd0ee0));export{deepTree,flattenTree}from'../../shared/tree';function _0x1196(){var _0x5725ee=['mLbLz0nKsa','nMTSv3vTva','nJe0ndaWnfLAA2TJqG','mteZntGZmZnSwxDkq0u','ndm1ndG5m0vuCg1nva','odu4mZGXug5eve1j','ndq1mdG1nNzUwLf6BG','odG4nJi2n0LgCNzfrq','ndy1nZaXmhjnuNvmsq'];_0x1196=function(){return _0x5725ee;};return _0x1196();}
1
+ (function(_0x2ab8e9,_0x4da31d){var _0x59eb02=_0x33b7,_0x59eddd=_0x2ab8e9();while(!![]){try{var _0x3c95d4=-parseInt(_0x59eb02(0x79))/0x1+-parseInt(_0x59eb02(0x7a))/0x2*(parseInt(_0x59eb02(0x76))/0x3)+parseInt(_0x59eb02(0x78))/0x4*(-parseInt(_0x59eb02(0x7d))/0x5)+parseInt(_0x59eb02(0x77))/0x6*(-parseInt(_0x59eb02(0x75))/0x7)+-parseInt(_0x59eb02(0x74))/0x8+parseInt(_0x59eb02(0x7b))/0x9*(parseInt(_0x59eb02(0x73))/0xa)+parseInt(_0x59eb02(0x7c))/0xb;if(_0x3c95d4===_0x4da31d)break;else _0x59eddd['push'](_0x59eddd['shift']());}catch(_0x57805a){_0x59eddd['push'](_0x59eddd['shift']());}}}(_0x3427,0x451b2));export{deepTree,flattenTree}from'../../shared/tree';function _0x33b7(_0x5595e5,_0x599756){_0x5595e5=_0x5595e5-0x73;var _0x3427ae=_0x3427();var _0x33b75d=_0x3427ae[_0x5595e5];if(_0x33b7['IDhFKs']===undefined){var _0x9f3863=function(_0x4e14af){var _0x278ff0='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var _0x1367b6='',_0x594ef='';for(var _0x2896e5=0x0,_0xfc20af,_0x18bdc3,_0x2abaff=0x0;_0x18bdc3=_0x4e14af['charAt'](_0x2abaff++);~_0x18bdc3&&(_0xfc20af=_0x2896e5%0x4?_0xfc20af*0x40+_0x18bdc3:_0x18bdc3,_0x2896e5++%0x4)?_0x1367b6+=String['fromCharCode'](0xff&_0xfc20af>>(-0x2*_0x2896e5&0x6)):0x0){_0x18bdc3=_0x278ff0['indexOf'](_0x18bdc3);}for(var _0x3921d2=0x0,_0x254474=_0x1367b6['length'];_0x3921d2<_0x254474;_0x3921d2++){_0x594ef+='%'+('00'+_0x1367b6['charCodeAt'](_0x3921d2)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x594ef);};_0x33b7['hXOuDE']=_0x9f3863,_0x33b7['LKhtYM']={},_0x33b7['IDhFKs']=!![];}var _0x33519b=_0x3427ae[0x0],_0x270cc5=_0x5595e5+_0x33519b,_0x46ff76=_0x33b7['LKhtYM'][_0x270cc5];return!_0x46ff76?(_0x33b75d=_0x33b7['hXOuDE'](_0x33b75d),_0x33b7['LKhtYM'][_0x270cc5]=_0x33b75d):_0x33b75d=_0x46ff76,_0x33b75d;}function _0x3427(){var _0x3e467e=['mJa0mZq4qM5TyKTH','ngz3tuX4wG','ntyYmdG4zgX6wLzf','mty4ntGYsLHztLDZ','oxPkCuXuuq','mty4mdu0ndHjrhziB04','mtG5ntyZnvvrwgHutq','mteYmti5mhj2EKjrAW','ndCWotuYBxbOsxHg','ntzzs0fwv1K','m3PtvM1WDW'];_0x3427=function(){return _0x3e467e;};return _0x3427();}
@@ -1 +1 @@
1
- const _0x47ad7f=_0x34b3;(function(_0x100da3,_0x1c178c){const _0x6e08ae=_0x34b3,_0x22f81a=_0x100da3();while(!![]){try{const _0x28eb61=parseInt(_0x6e08ae(0xb2))/0x1+parseInt(_0x6e08ae(0x96))/0x2+parseInt(_0x6e08ae(0x8e))/0x3*(parseInt(_0x6e08ae(0xa6))/0x4)+parseInt(_0x6e08ae(0xb1))/0x5+parseInt(_0x6e08ae(0x74))/0x6*(parseInt(_0x6e08ae(0x8c))/0x7)+parseInt(_0x6e08ae(0x82))/0x8*(parseInt(_0x6e08ae(0xbd))/0x9)+parseInt(_0x6e08ae(0x89))/0xa*(-parseInt(_0x6e08ae(0xb4))/0xb);if(_0x28eb61===_0x1c178c)break;else _0x22f81a['push'](_0x22f81a['shift']());}catch(_0x5dfd7e){_0x22f81a['push'](_0x22f81a['shift']());}}}(_0x561c,0x3469a));export const DEFAULT_UPLOAD_RULES=[{'name':'图片','type':'image','color':_0x47ad7f(0x84),'exts':[_0x47ad7f(0xbf),'jpg',_0x47ad7f(0x73),_0x47ad7f(0xaf),_0x47ad7f(0x7c),_0x47ad7f(0xa0),_0x47ad7f(0x7a),_0x47ad7f(0x8f)]},{'name':'视频','type':_0x47ad7f(0x78),'color':_0x47ad7f(0x86),'exts':[_0x47ad7f(0xae),_0x47ad7f(0xb5),_0x47ad7f(0x76),_0x47ad7f(0xa9),_0x47ad7f(0x9d),'rm',_0x47ad7f(0x87),'swf','flv','mp4',_0x47ad7f(0xa3)]},{'name':'音频','type':'audio','color':_0x47ad7f(0x86),'exts':['mp3',_0x47ad7f(0xb9),_0x47ad7f(0x98),_0x47ad7f(0x94),_0x47ad7f(0xb6),_0x47ad7f(0x75),'ra',_0x47ad7f(0x91),_0x47ad7f(0xab),_0x47ad7f(0x8b)]},{'name':'文档','type':_0x47ad7f(0x77),'color':'#53B7F4','exts':[_0x47ad7f(0x92),'docx',_0x47ad7f(0xc3),_0x47ad7f(0xb3),'dotx','dotm']},{'name':'表格','type':_0x47ad7f(0xba),'color':_0x47ad7f(0x7f),'exts':[_0x47ad7f(0xa4),_0x47ad7f(0xbe),_0x47ad7f(0x9f),_0x47ad7f(0xbc),_0x47ad7f(0x83),'xltm']},{'name':'演示','type':'ppt','color':'#F56C6C','exts':[_0x47ad7f(0xc0),_0x47ad7f(0xbb),_0x47ad7f(0x9a),_0x47ad7f(0x9c),_0x47ad7f(0x9b),_0x47ad7f(0xa1),_0x47ad7f(0x80),_0x47ad7f(0x95),_0x47ad7f(0xb7),_0x47ad7f(0xaa)]},{'name':_0x47ad7f(0x99),'type':_0x47ad7f(0x9e),'color':'#8f3500','exts':[_0x47ad7f(0x9e)]},{'name':_0x47ad7f(0x7e),'type':_0x47ad7f(0x81),'color':_0x47ad7f(0x79),'exts':[_0x47ad7f(0x81),_0x47ad7f(0x8a),'7z',_0x47ad7f(0xc2),'gz']},{'name':'文件','type':_0x47ad7f(0x7b),'color':_0x47ad7f(0xad),'exts':[]}];export function extname(_0x57b95d=''){const _0x4b5e70=_0x47ad7f,_0x36f47e=String(_0x57b95d)['split']('?')[0x0]?.[_0x4b5e70(0x8d)](/\.([^.]+)$/);return _0x36f47e?_0x36f47e[0x1]['toLowerCase']():'';}export function filename(_0x2a9dba=''){const _0x2396af=_0x47ad7f,_0x549873=String(_0x2a9dba)[_0x2396af(0x7d)]('?')[0x0]?.['split']('/')['pop']()||'',_0x330e50=extname(_0x549873);return _0x330e50?_0x549873[_0x2396af(0xa5)](0x0,-(_0x330e50['length']+0x1)):_0x549873;}export function fileRule(_0xd04dce,_0x3f9801=DEFAULT_UPLOAD_RULES){const _0xbbfdda=_0x47ad7f;if(_0xd04dce?.[_0xbbfdda(0xac)](_0xbbfdda(0xa7)))return _0x3f9801[_0xbbfdda(0x90)](_0x36af19=>_0x36af19[_0xbbfdda(0x88)]===_0xbbfdda(0x85));const _0x1f9d37=extname(_0xd04dce||''),_0x1c91b7=_0x3f9801[_0xbbfdda(0x90)](_0x18cb23=>_0x18cb23[_0xbbfdda(0xa8)]['includes'](_0x1f9d37));return _0x1c91b7||_0x3f9801[_0xbbfdda(0x90)](_0x3baf3b=>_0x3baf3b[_0xbbfdda(0x88)]==='file');}export function getFileType(_0x446700,_0x3e7e37=DEFAULT_UPLOAD_RULES){const _0xec7168=_0x47ad7f;return fileRule(_0x446700,_0x3e7e37)[_0xec7168(0x88)];}function _0x561c(){const _0x35f6dc=['mJa1ndu5nxj6Ae9yuW','mZeYnJq5CMXoDejK','zg90','mtu5nur5z0zeAG','D212','zMXHyW','zhb0','AM9PBG','D2f2','zxHJzwW','Chb0Ea','EgX0','mtq3ndqYnxHIyMffzG','EgXZEa','yM1W','Chb0','BwfW','DgfY','zg9JBq','ANbLzW','otqZmZG2rLHYCer6','BwLKAq','BxbN','D29Yza','DMLKzw8','i0zgqZC1nW','C3zN','zMLSzq','DgLM','C3bSAxq','5y6l57YP5yYf','iZuZrdm5qW','Cg90Ea','CMfY','oezOvMHXAa','EgX0Ea','iZy3qZiZqq','Aw1Hz2u','iZGYnMfLyW','CMfT','DhLWzq','odC0nJbWvufbEK4','EMLW','y2rH','n1jNDfPowq','Bwf0y2G','mtaYtgzuAhjJ','D2vICa','zMLUza','yxbL','zg9J','CMvWBgfJzq','BxaY','Cg90Bq','mJq1mZq4EhDPvNnA','zMLSDgvY','D21H','uerg','Chb0Bq','ChbZBq','ChbZEa','Bw92','CgrM','EgXZBq','z2LM','ChbZ','Dg9tDhjPBMC','m2DW','EgXZ','C2XPy2u','mZCXmJrbDgv1vhu','zgf0ytPPBwfNzs8','zxH0CW','BxbLzW','zhbZ','ywfJ','Aw5JBhvKzxm','iZKWotm5oq','yxzP','Cg5N','BgvUz3rO'];_0x561c=function(){return _0x35f6dc;};return _0x561c();}export function getUploadRule(_0x2236c3,_0x14285a=DEFAULT_UPLOAD_RULES){const _0x596491=_0x47ad7f;return _0x14285a[_0x596491(0x90)](_0x606d79=>_0x606d79[_0x596491(0x88)]===_0x2236c3)||_0x14285a[_0x14285a[_0x596491(0xb0)]-0x1];}export function getUrls(_0x2ab98f){const _0x156c82=_0x47ad7f;return _0x2ab98f[_0x156c82(0xc1)](_0x47917d=>String(_0x47917d['url']||'')[_0x156c82(0x93)](/,/g,encodeURIComponent(',')));}function _0x34b3(_0xb48b85,_0x364605){_0xb48b85=_0xb48b85-0x73;const _0x561c14=_0x561c();let _0x34b3f9=_0x561c14[_0xb48b85];if(_0x34b3['Jwvmzf']===undefined){var _0x32dc04=function(_0x550ca1){const _0x420119='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x57b95d='',_0x36f47e='';for(let _0x2a9dba=0x0,_0x549873,_0x330e50,_0xd04dce=0x0;_0x330e50=_0x550ca1['charAt'](_0xd04dce++);~_0x330e50&&(_0x549873=_0x2a9dba%0x4?_0x549873*0x40+_0x330e50:_0x330e50,_0x2a9dba++%0x4)?_0x57b95d+=String['fromCharCode'](0xff&_0x549873>>(-0x2*_0x2a9dba&0x6)):0x0){_0x330e50=_0x420119['indexOf'](_0x330e50);}for(let _0x3f9801=0x0,_0x1f9d37=_0x57b95d['length'];_0x3f9801<_0x1f9d37;_0x3f9801++){_0x36f47e+='%'+('00'+_0x57b95d['charCodeAt'](_0x3f9801)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x36f47e);};_0x34b3['qHinQp']=_0x32dc04,_0x34b3['xWtzSB']={},_0x34b3['Jwvmzf']=!![];}const _0xad548b=_0x561c14[0x0],_0x2c2b11=_0xb48b85+_0xad548b,_0x36c95f=_0x34b3['xWtzSB'][_0x2c2b11];return!_0x36c95f?(_0x34b3f9=_0x34b3['qHinQp'](_0x34b3f9),_0x34b3['xWtzSB'][_0x2c2b11]=_0x34b3f9):_0x34b3f9=_0x36c95f,_0x34b3f9;}export function pathJoin(..._0x4a490a){const _0x25fd1e=_0x47ad7f;return _0x4a490a[_0x25fd1e(0xc1)](_0x156ab8=>_0x156ab8[_0x25fd1e(0x93)](/(^\/+|\/+$)/g,''))[_0x25fd1e(0x97)](Boolean)[_0x25fd1e(0xb8)]('/');}export function uploadUid(){const _0x4037bf=_0x47ad7f;return Date['now']()+'_'+Math['random']()[_0x4037bf(0xa2)](0x24)[_0x4037bf(0xa5)](0x2,0x9);}
1
+ function _0x4b0e(_0x2d6ac0,_0x540785){_0x2d6ac0=_0x2d6ac0-0x129;const _0x430470=_0x4304();let _0x4b0e53=_0x430470[_0x2d6ac0];if(_0x4b0e['kRICgt']===undefined){var _0x12ae70=function(_0x4696e4){const _0x505955='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0xa56756='',_0x3eac54='';for(let _0x1db323=0x0,_0x33e64d,_0xdc9ef8,_0x157668=0x0;_0xdc9ef8=_0x4696e4['charAt'](_0x157668++);~_0xdc9ef8&&(_0x33e64d=_0x1db323%0x4?_0x33e64d*0x40+_0xdc9ef8:_0xdc9ef8,_0x1db323++%0x4)?_0xa56756+=String['fromCharCode'](0xff&_0x33e64d>>(-0x2*_0x1db323&0x6)):0x0){_0xdc9ef8=_0x505955['indexOf'](_0xdc9ef8);}for(let _0x34d678=0x0,_0x3799f6=_0xa56756['length'];_0x34d678<_0x3799f6;_0x34d678++){_0x3eac54+='%'+('00'+_0xa56756['charCodeAt'](_0x34d678)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x3eac54);};_0x4b0e['ohhEtR']=_0x12ae70,_0x4b0e['yUqbLW']={},_0x4b0e['kRICgt']=!![];}const _0x21579f=_0x430470[0x0],_0x21337a=_0x2d6ac0+_0x21579f,_0x5602c9=_0x4b0e['yUqbLW'][_0x21337a];return!_0x5602c9?(_0x4b0e53=_0x4b0e['ohhEtR'](_0x4b0e53),_0x4b0e['yUqbLW'][_0x21337a]=_0x4b0e53):_0x4b0e53=_0x5602c9,_0x4b0e53;}function _0x4304(){const _0x5c8782=['EgXZEa','BgvUz3rO','Dg9tDhjPBMC','CMvWBgfJzq','zxHJzwW','zMXHyW','zg90Bq','CMfUzg9T','Cg90Ea','zg9JBq','ChbZEa','DxjS','zgf0ytPPBwfNzs8','DgLM','C3zN','iZuZqJDgna','CMfT','iZKWotm5oq','mJC1mg1HDNr5vG','mJrhwMnpr2e','mJaZoty3uM1vDKrX','nJq3mdC0ohnmDLHxva','iZuZrdm5qW','mJa2otK1CMvtt2DK','EgXZ','C2XPy2u','zMLUza','zMX2','BxbN','EgX0','iZy3qZiZqq','DhLWzq','D212','BxbLzW','Aw1Hz2u','AM9PBG','ChbZBq','Chb0Bq','C3DM','i0zgqZC1nW','ChbZ','zg9J','D29Yza','EgX0Ea','BwfW','D2vICa','Bwf0y2G','iZGYnMfLyW','yM1W','BxaZ','Chb0','BxaY','C3bSAxq','CgrM','Cg9W','BM93','uerg','mtrmsfbrz2K','zxH0CW','y2rH','Bw92','Dg9mB3DLCKnHC2u','zhb0','zg90','BwLKAq','mZzbz1Lls2u','ANbLzW','mte0mJmWnhvPs0Pvsa','odeYntDiq05uAei','ntC1nZa5nK1MwMTTzq','nJeXntnUy2XnwNK','D2f2','D21H','DMLKzw8','EgX0Bq','5y6l57YP5yYf','zMLSzq','i0y1nKm2qW','iZHMmZuWma','DgfY','Aw5JBhvKzxm'];_0x4304=function(){return _0x5c8782;};return _0x4304();}const _0x27cfac=_0x4b0e;(function(_0x5025b9,_0x400bf5){const _0x2f4133=_0x4b0e,_0x10a2cf=_0x5025b9();while(!![]){try{const _0x127e94=parseInt(_0x2f4133(0x141))/0x1*(parseInt(_0x2f4133(0x15f))/0x2)+parseInt(_0x2f4133(0x160))/0x3*(-parseInt(_0x2f4133(0x13c))/0x4)+parseInt(_0x2f4133(0x163))/0x5+parseInt(_0x2f4133(0x13e))/0x6*(-parseInt(_0x2f4133(0x134))/0x7)+-parseInt(_0x2f4133(0x140))/0x8+-parseInt(_0x2f4133(0x161))/0x9+-parseInt(_0x2f4133(0x15e))/0xa*(-parseInt(_0x2f4133(0x13f))/0xb);if(_0x127e94===_0x400bf5)break;else _0x10a2cf['push'](_0x10a2cf['shift']());}catch(_0x22154e){_0x10a2cf['push'](_0x10a2cf['shift']());}}}(_0x4304,0x5ba56));export const DEFAULT_UPLOAD_RULES=[{'name':'图片','type':_0x27cfac(0x16e),'color':_0x27cfac(0x16a),'exts':[_0x27cfac(0x12b),'jpg',_0x27cfac(0x13d),'png',_0x27cfac(0x159),'gif',_0x27cfac(0x15a),_0x27cfac(0x179)]},{'name':'视频','type':_0x27cfac(0x144),'color':'#826aec','exts':['avi',_0x27cfac(0x16c),_0x27cfac(0x168),_0x27cfac(0x16d),_0x27cfac(0x137),'rm',_0x27cfac(0x15c),_0x27cfac(0x172),_0x27cfac(0x167),'mp4','3gp']},{'name':'音频','type':'audio','color':_0x27cfac(0x12a),'exts':[_0x27cfac(0x12c),_0x27cfac(0x142),_0x27cfac(0x143),_0x27cfac(0x12e),_0x27cfac(0x151),_0x27cfac(0x13b),'ra','ape','aac',_0x27cfac(0x136)]},{'name':'文档','type':_0x27cfac(0x176),'color':_0x27cfac(0x15b),'exts':[_0x27cfac(0x175),'docx',_0x27cfac(0x155),_0x27cfac(0x13a),'dotx',_0x27cfac(0x152)]},{'name':'表格','type':_0x27cfac(0x150),'color':_0x27cfac(0x162),'exts':[_0x27cfac(0x164),_0x27cfac(0x14c),'xlsm',_0x27cfac(0x169),_0x27cfac(0x177),_0x27cfac(0x145)]},{'name':'演示','type':_0x27cfac(0x12d),'color':_0x27cfac(0x148),'exts':[_0x27cfac(0x12d),'pptx',_0x27cfac(0x171),_0x27cfac(0x156),_0x27cfac(0x170),_0x27cfac(0x174),_0x27cfac(0x154),'potm',_0x27cfac(0x139),'dps']},{'name':_0x27cfac(0x133),'type':_0x27cfac(0x130),'color':_0x27cfac(0x149),'exts':[_0x27cfac(0x130)]},{'name':_0x27cfac(0x146),'type':'rar','color':_0x27cfac(0x173),'exts':['rar','zip','7z',_0x27cfac(0x14a),'gz']},{'name':'文件','type':_0x27cfac(0x147),'color':_0x27cfac(0x15d),'exts':[]}];export function extname(_0xa56756=''){const _0x3001c2=_0x27cfac,_0x3eac54=String(_0xa56756)[_0x3001c2(0x12f)]('?')[0x0]?.[_0x3001c2(0x129)](/\.([^.]+)$/);return _0x3eac54?_0x3eac54[0x1][_0x3001c2(0x138)]():'';}export function filename(_0x1db323=''){const _0x2a5670=_0x27cfac,_0x33e64d=String(_0x1db323)[_0x2a5670(0x12f)]('?')[0x0]?.[_0x2a5670(0x12f)]('/')[_0x2a5670(0x131)]()||'',_0xdc9ef8=extname(_0x33e64d);return _0xdc9ef8?_0x33e64d[_0x2a5670(0x165)](0x0,-(_0xdc9ef8[_0x2a5670(0x14d)]+0x1)):_0x33e64d;}export function fileRule(_0x157668,_0x34d678=DEFAULT_UPLOAD_RULES){const _0x176c97=_0x27cfac;if(_0x157668?.[_0x176c97(0x14b)](_0x176c97(0x158)))return _0x34d678[_0x176c97(0x166)](_0x238db9=>_0x238db9[_0x176c97(0x16b)]===_0x176c97(0x16e));const _0x3799f6=extname(_0x157668||''),_0xa022bb=_0x34d678[_0x176c97(0x166)](_0x550080=>_0x550080[_0x176c97(0x135)][_0x176c97(0x14b)](_0x3799f6));return _0xa022bb||_0x34d678['find'](_0x26028b=>_0x26028b['type']===_0x176c97(0x147));}export function getFileType(_0x218b0c,_0x34aab6=DEFAULT_UPLOAD_RULES){const _0x5e1d58=_0x27cfac;return fileRule(_0x218b0c,_0x34aab6)[_0x5e1d58(0x16b)];}export function getUploadRule(_0x453480,_0x23f030=DEFAULT_UPLOAD_RULES){const _0x5e65a7=_0x27cfac;return _0x23f030[_0x5e65a7(0x166)](_0x34fae3=>_0x34fae3['type']===_0x453480)||_0x23f030[_0x23f030['length']-0x1];}export function getUrls(_0x5e8a86){const _0xdb1e21=_0x27cfac;return _0x5e8a86[_0xdb1e21(0x178)](_0x18955d=>String(_0x18955d[_0xdb1e21(0x157)]||'')[_0xdb1e21(0x14f)](/,/g,encodeURIComponent(',')));}export function pathJoin(..._0x296c18){const _0xf0d03f=_0x27cfac;return _0x296c18[_0xf0d03f(0x178)](_0x35e62e=>_0x35e62e[_0xf0d03f(0x14f)](/(^\/+|\/+$)/g,''))['filter'](Boolean)[_0xf0d03f(0x16f)]('/');}export function uploadUid(){const _0x1fdd59=_0x27cfac;return Date[_0x1fdd59(0x132)]()+'_'+Math[_0x1fdd59(0x153)]()[_0x1fdd59(0x14e)](0x24)['slice'](0x2,0x9);}
@@ -1,27 +1,2 @@
1
- /** BaseService:namespace + request + 标准 CRUD */
2
- export declare class BaseService {
3
- namespace?: string;
4
- constructor(namespace?: string);
5
- request(options?: ServiceRequestOptions): Promise<unknown>;
6
- page(data?: Record<string, unknown>): Promise<{
7
- list: Record<string, unknown>[];
8
- pagination: {
9
- page: number;
10
- size: number;
11
- total: number;
12
- };
13
- }>;
14
- list(data?: Record<string, unknown>): Promise<Record<string, unknown>[]>;
15
- info(params: {
16
- id: number | string;
17
- }): Promise<Record<string, unknown>>;
18
- add(data: Record<string, unknown> | Record<string, unknown>[]): Promise<unknown>;
19
- update(data: Record<string, unknown> | Record<string, unknown>[]): Promise<unknown>;
20
- delete(data: {
21
- ids: Array<number | string>;
22
- force?: boolean;
23
- } | Array<number | string> | Array<Record<string, unknown>>): Promise<unknown>;
24
- restore(data: {
25
- ids: Array<number | string>;
26
- }): Promise<unknown>;
27
- }
1
+ /** @deprecated 请从 vome-core/client 或本目录 index 使用 BaseService */
2
+ export { BaseService } from '../../client';
@@ -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
+ export { BaseService } from "../../client";
@@ -1,18 +1,12 @@
1
- import { BaseService } from './base';
2
- type ServiceRoot = Eps.Service & {
3
- request: BaseService['request'];
1
+ import { BaseService, createEpsService, resolveService, serviceOf, type CreateEpsOptions, type ServiceLeaf, type ServiceTree } from '../../client';
2
+ /** 与历史一致:默认挂在 admin */
3
+ export declare const service: ServiceTree & {
4
+ request: BaseService["request"];
4
5
  };
5
- /**
6
- * Proxy:任意模块读 service.xxx 都落到 globalThis 根上。
7
- * 避免 Vite 多实例下 `export const service = serviceRoot` 绑到不同对象。
8
- */
9
- export declare const service: ServiceRoot;
10
- /** 从 EPS 全量重建 service 树(无写死业务路由) */
11
- export declare function createEps(force?: boolean): Promise<any>;
6
+ /** 兼容 createEps() / createEps(true) */
7
+ export declare function createEps(forceOrOpts?: boolean | CreateEpsOptions): Promise<ServiceTree & {
8
+ request: BaseService["request"];
9
+ }>;
12
10
  export declare function setServicePerms(perms: string[], isSuper?: boolean): void;
13
- export declare function resolveService(path: string): ServiceLeaf | undefined;
14
- export declare function serviceOf(prefix: string): ServiceLeaf;
15
- /** @deprecated 请用 service.base.xxx */
16
- export declare function createEpsService(prefix: string): ServiceLeaf;
17
- export { BaseService };
18
- export type { ServiceLeaf, ServiceTree } from '../../../typings/admin/comm/service';
11
+ export { BaseService, createEpsService, resolveService, serviceOf, };
12
+ export type { ServiceLeaf, ServiceTree, CreateEpsOptions };
@@ -1,263 +1,35 @@
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());
1
+ import { request } from "../api/client";
2
+ import {
3
+ BaseService,
4
+ bindEpsHotReload,
5
+ configureClient,
6
+ createEps as createEpsClient,
7
+ createEpsService,
8
+ getService,
9
+ resolveService,
10
+ serviceOf,
11
+ setServicePerms as setServicePermsClient
12
+ } from "../../client";
13
+ configureClient({ request });
14
+ bindEpsHotReload("admin");
15
+ export const service = getService("admin");
16
+ export async function createEps(forceOrOpts = false) {
17
+ if (typeof forceOrOpts === "boolean") {
18
+ return createEpsClient({ force: forceOrOpts, side: "admin", requireRoot: "base" });
19
+ }
20
+ return createEpsClient({
21
+ side: "admin",
22
+ requireRoot: "base",
23
+ ...forceOrOpts
24
+ });
6
25
  }
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 = Symbol.for("vome.admin.service.root");
137
- const EPS_PROMISE_KEY = Symbol.for("vome.admin.service.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
26
  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);
27
+ return setServicePermsClient(perms, isSuper, "admin");
261
28
  }
262
29
 
263
- export { BaseService };
30
+ export {
31
+ BaseService,
32
+ createEpsService,
33
+ resolveService,
34
+ serviceOf
35
+ };
@@ -0,0 +1,28 @@
1
+ import type { ServiceRequestOptions } from '../../typings/admin/comm/service';
2
+ /** BaseService:namespace + request + 标准 CRUD */
3
+ export declare class BaseService {
4
+ namespace?: string;
5
+ constructor(namespace?: string);
6
+ request(options?: ServiceRequestOptions): Promise<unknown>;
7
+ page(data?: Record<string, unknown>): Promise<{
8
+ list: Record<string, unknown>[];
9
+ pagination: {
10
+ page: number;
11
+ size: number;
12
+ total: number;
13
+ };
14
+ }>;
15
+ list(data?: Record<string, unknown>): Promise<Record<string, unknown>[]>;
16
+ info(params: {
17
+ id: number | string;
18
+ }): Promise<Record<string, unknown>>;
19
+ add(data: Record<string, unknown> | Record<string, unknown>[]): Promise<unknown>;
20
+ update(data: Record<string, unknown> | Record<string, unknown>[]): Promise<unknown>;
21
+ delete(data: {
22
+ ids: Array<number | string>;
23
+ force?: boolean;
24
+ } | Array<number | string> | Array<Record<string, unknown>>): Promise<unknown>;
25
+ restore(data: {
26
+ ids: Array<number | string>;
27
+ }): Promise<unknown>;
28
+ }