x-essential-lib 0.10.24 → 0.10.26
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/index.d.ts +6 -2
- package/dist/index.js +59 -45
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -272,7 +272,6 @@ declare const routeTransName: import("vue").Ref<string, string>;
|
|
|
272
272
|
declare function onBeforeEach(to: RouteLocationNormalized, from: RouteLocationNormalized, lastAppPath: string): Promise<{
|
|
273
273
|
path: string;
|
|
274
274
|
} | undefined>;
|
|
275
|
-
declare function switchOrg(orgId: string | undefined): Promise<boolean>;
|
|
276
275
|
//#endregion
|
|
277
276
|
//#region src/utils/type.d.ts
|
|
278
277
|
declare const types: readonly ["string", "number", "boolean", "array", "object", "any"];
|
|
@@ -313,6 +312,11 @@ declare function usePermission(): {
|
|
|
313
312
|
verifyPermission: (permission: Permission, instance?: string) => boolean;
|
|
314
313
|
};
|
|
315
314
|
//#endregion
|
|
315
|
+
//#region src/composables/routeChange.d.ts
|
|
316
|
+
declare function useRouteChange(routeChange: () => Promise<void>): {
|
|
317
|
+
syncOrg: () => Promise<boolean>;
|
|
318
|
+
};
|
|
319
|
+
//#endregion
|
|
316
320
|
//#region src/composables/system.d.ts
|
|
317
321
|
declare function useSystem(): {
|
|
318
322
|
sysBarAvail: import("vue").ComputedRef<boolean>;
|
|
@@ -553,4 +557,4 @@ declare const _default: {
|
|
|
553
557
|
install: (app: import("vue").App) => void;
|
|
554
558
|
};
|
|
555
559
|
//#endregion
|
|
556
|
-
export { GlobalStates, Permission, PermissionObjects, RouteMeta, Type, addView, appAppear, clearViews, closeWaitDlg, createAxios, _default as default, delView, eventBus, getTypeColor, getTypeDefault, globalObjects, hasView, injectDark, injectLocale, injectPermissionObjects, injectViews, isEmpty, isExist, lastView, loadLocaleMessageEssential, matchRouteMeta, messageError, messageInfo, messageSuccess, messageWarning, onBeforeEach, openConfirmDlg, openNumberDlg, openPromptDlg, openWaitDlg, popView, provideDark, provideLocale, providePermissionObjects, provideViews, routeTransName,
|
|
560
|
+
export { GlobalStates, Permission, PermissionObjects, RouteMeta, Type, addView, appAppear, clearViews, closeWaitDlg, createAxios, _default as default, delView, eventBus, getTypeColor, getTypeDefault, globalObjects, hasView, injectDark, injectLocale, injectPermissionObjects, injectViews, isEmpty, isExist, lastView, loadLocaleMessageEssential, matchRouteMeta, messageError, messageInfo, messageSuccess, messageWarning, onBeforeEach, openConfirmDlg, openNumberDlg, openPromptDlg, openWaitDlg, popView, provideDark, provideLocale, providePermissionObjects, provideViews, routeTransName, toPermissionObjects, types, useColor, useGlobalStates, useMicroApp, usePermission, useRouteChange, useSystem, useViewStack, verifyPermission, waitMs, waitUtil };
|
package/dist/index.js
CHANGED
|
@@ -431,25 +431,6 @@ function injectViews() {
|
|
|
431
431
|
return inject("viewsKey");
|
|
432
432
|
}
|
|
433
433
|
|
|
434
|
-
//#endregion
|
|
435
|
-
//#region src/api/orgbase/instance.ts
|
|
436
|
-
const instance = createAxios$1({
|
|
437
|
-
baseUrl: "http://localhost/orgbase/",
|
|
438
|
-
onError: (error) => {
|
|
439
|
-
messageError$1(getErrorMessage(error));
|
|
440
|
-
}
|
|
441
|
-
});
|
|
442
|
-
if (window.API_URL) instance.defaults.baseURL = window.API_URL + "/orgbase/";
|
|
443
|
-
|
|
444
|
-
//#endregion
|
|
445
|
-
//#region src/api/orgbase/index.ts
|
|
446
|
-
function GetOrgName(request) {
|
|
447
|
-
return instance.post("getOrgName", request);
|
|
448
|
-
}
|
|
449
|
-
function PullPermission(request) {
|
|
450
|
-
return instance.post("pullPermission", request);
|
|
451
|
-
}
|
|
452
|
-
|
|
453
434
|
//#endregion
|
|
454
435
|
//#region src/utils/router.ts
|
|
455
436
|
const routeMetas = [
|
|
@@ -630,31 +611,6 @@ async function onBeforeEach(to, from, lastAppPath) {
|
|
|
630
611
|
if (hasAccessToken && to.path.startsWith("/passport/")) return { path: `/main/${Date.now()}` };
|
|
631
612
|
onBeforeChange(to.path, from.path, lastAppPath);
|
|
632
613
|
}
|
|
633
|
-
async function switchOrg(orgId) {
|
|
634
|
-
const router = useRouter();
|
|
635
|
-
if (!orgId) {
|
|
636
|
-
await router.replace({ path: `/main/${Date.now()}` });
|
|
637
|
-
return false;
|
|
638
|
-
}
|
|
639
|
-
if (orgId === "public") {
|
|
640
|
-
eventBus.emit("updateActiveOrg", [orgId, ""]);
|
|
641
|
-
eventBus.emit("updatePermission", [{}, ""]);
|
|
642
|
-
return true;
|
|
643
|
-
}
|
|
644
|
-
try {
|
|
645
|
-
const { name } = await GetOrgName({ orgId });
|
|
646
|
-
const { permissions } = await PullPermission({
|
|
647
|
-
orgId,
|
|
648
|
-
checksum: ""
|
|
649
|
-
});
|
|
650
|
-
eventBus.emit("updateActiveOrg", [orgId, name]);
|
|
651
|
-
eventBus.emit("updatePermission", [toPermissionObjects(permissions), permissions.checksum ?? ""]);
|
|
652
|
-
return true;
|
|
653
|
-
} catch (e) {
|
|
654
|
-
if (e === "org not found" || e === "org member not found") await router.replace({ path: `/main/${Date.now()}` });
|
|
655
|
-
return false;
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
614
|
|
|
659
615
|
//#endregion
|
|
660
616
|
//#region src/utils/type.ts
|
|
@@ -838,6 +794,64 @@ function usePermission() {
|
|
|
838
794
|
return { verifyPermission: verifyPermission$1 };
|
|
839
795
|
}
|
|
840
796
|
|
|
797
|
+
//#endregion
|
|
798
|
+
//#region src/api/orgbase/instance.ts
|
|
799
|
+
const instance = createAxios$1({
|
|
800
|
+
baseUrl: "http://localhost/orgbase/",
|
|
801
|
+
onError: (error) => {
|
|
802
|
+
messageError$1(getErrorMessage(error));
|
|
803
|
+
}
|
|
804
|
+
});
|
|
805
|
+
if (window.API_URL) instance.defaults.baseURL = window.API_URL + "/orgbase/";
|
|
806
|
+
|
|
807
|
+
//#endregion
|
|
808
|
+
//#region src/api/orgbase/index.ts
|
|
809
|
+
function GetOrgName(request) {
|
|
810
|
+
return instance.post("getOrgName", request);
|
|
811
|
+
}
|
|
812
|
+
function PullPermission(request) {
|
|
813
|
+
return instance.post("pullPermission", request);
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
//#endregion
|
|
817
|
+
//#region src/composables/routeChange.ts
|
|
818
|
+
function useRouteChange(routeChange) {
|
|
819
|
+
const route = useRoute();
|
|
820
|
+
const router = useRouter();
|
|
821
|
+
async function syncOrg() {
|
|
822
|
+
const orgId = route.query.orgId;
|
|
823
|
+
if (!orgId) {
|
|
824
|
+
await router.replace({ path: `/main/${Date.now()}` });
|
|
825
|
+
return false;
|
|
826
|
+
}
|
|
827
|
+
if (orgId === "public") {
|
|
828
|
+
eventBus.emit("updateActiveOrg", [orgId, ""]);
|
|
829
|
+
eventBus.emit("updatePermission", [{}, ""]);
|
|
830
|
+
return true;
|
|
831
|
+
}
|
|
832
|
+
try {
|
|
833
|
+
const { name } = await GetOrgName({ orgId });
|
|
834
|
+
const { permissions } = await PullPermission({
|
|
835
|
+
orgId,
|
|
836
|
+
checksum: ""
|
|
837
|
+
});
|
|
838
|
+
eventBus.emit("updateActiveOrg", [orgId, name]);
|
|
839
|
+
eventBus.emit("updatePermission", [toPermissionObjects(permissions), permissions.checksum ?? ""]);
|
|
840
|
+
return true;
|
|
841
|
+
} catch (e) {
|
|
842
|
+
if (e === "org not found" || e === "org member not found") await router.replace({ path: `/main/${Date.now()}` });
|
|
843
|
+
return false;
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
onBeforeMount(async () => {
|
|
847
|
+
await routeChange();
|
|
848
|
+
});
|
|
849
|
+
watch(() => route.path, async () => {
|
|
850
|
+
await routeChange();
|
|
851
|
+
});
|
|
852
|
+
return { syncOrg };
|
|
853
|
+
}
|
|
854
|
+
|
|
841
855
|
//#endregion
|
|
842
856
|
//#region src/composables/system.ts
|
|
843
857
|
function useSystem() {
|
|
@@ -1588,4 +1602,4 @@ async function loadLocaleMessageEssential(locale) {
|
|
|
1588
1602
|
var src_default = { install };
|
|
1589
1603
|
|
|
1590
1604
|
//#endregion
|
|
1591
|
-
export { Permission, addView, appAppear, clearViews, closeWaitDlg, createAxios, src_default as default, delView, eventBus, getTypeColor, getTypeDefault, globalObjects, hasView, injectDark, injectLocale, injectPermissionObjects, injectViews, isEmpty, isExist, lastView, loadLocaleMessageEssential, matchRouteMeta, messageError, messageInfo, messageSuccess, messageWarning, onBeforeEach, openConfirmDlg, openNumberDlg, openPromptDlg, openWaitDlg, popView, provideDark, provideLocale, providePermissionObjects, provideViews, routeTransName,
|
|
1605
|
+
export { Permission, addView, appAppear, clearViews, closeWaitDlg, createAxios, src_default as default, delView, eventBus, getTypeColor, getTypeDefault, globalObjects, hasView, injectDark, injectLocale, injectPermissionObjects, injectViews, isEmpty, isExist, lastView, loadLocaleMessageEssential, matchRouteMeta, messageError, messageInfo, messageSuccess, messageWarning, onBeforeEach, openConfirmDlg, openNumberDlg, openPromptDlg, openWaitDlg, popView, provideDark, provideLocale, providePermissionObjects, provideViews, routeTransName, toPermissionObjects, types, useColor, useGlobalStates, useMicroApp, usePermission, useRouteChange, useSystem, useViewStack, verifyPermission, waitMs, waitUtil };
|