x-essential-lib 0.10.23 → 0.10.24

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 CHANGED
@@ -1,4 +1,4 @@
1
- import { n as EventType, t as Emitter } from "./vendor.dqdzrw43.js";
1
+ import { n as EventType, t as Emitter } from "./vendor.homyhtbu.js";
2
2
  import { Ref } from "vue";
3
3
  import { AxiosInstance } from "axios";
4
4
  import { RouteLocationNormalized } from "vue-router";
@@ -272,6 +272,7 @@ 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>;
275
276
  //#endregion
276
277
  //#region src/utils/type.d.ts
277
278
  declare const types: readonly ["string", "number", "boolean", "array", "object", "any"];
@@ -305,7 +306,7 @@ interface GlobalStates {
305
306
  declare function useGlobalStates(globalStates: GlobalStates, base?: boolean): void;
306
307
  //#endregion
307
308
  //#region src/composables/microApp.d.ts
308
- declare function useMicroApp(globalStates: GlobalStates, ignoreSyncOrg?: boolean, onRouteChange?: () => Promise<void>, customBack?: (m: RouteMeta) => void): void;
309
+ declare function useMicroApp(globalStates: GlobalStates, customBack?: (m: RouteMeta) => void): void;
309
310
  //#endregion
310
311
  //#region src/composables/permission.d.ts
311
312
  declare function usePermission(): {
@@ -552,4 +553,4 @@ declare const _default: {
552
553
  install: (app: import("vue").App) => void;
553
554
  };
554
555
  //#endregion
555
- 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, useSystem, useViewStack, verifyPermission, waitMs, waitUtil };
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, switchOrg, toPermissionObjects, types, useColor, useGlobalStates, useMicroApp, usePermission, useSystem, useViewStack, verifyPermission, waitMs, waitUtil };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  (function(){try{document.getElementById(`x-essential-lib`)?.remove();const e = document.createElement(`style`);e.setAttribute(`id`, `x-essential-lib`);const t = document.createTextNode(`.fade-leave-active[data-v-x-essential-lib-c3545c8d]{transition:opacity .5s}.fade-leave-to[data-v-x-essential-lib-c3545c8d]{opacity:0}.x-cont[data-v-x-essential-lib-c3545c8d]{justify-content:center;align-items:center;display:flex;position:absolute;inset:0}.lds-spinner[data-v-x-essential-lib-c3545c8d]{color:official;width:40px;height:40px;display:inline-block;position:relative}.lds-spinner div[data-v-x-essential-lib-c3545c8d]{transform-origin:20px 20px;animation:1.2s linear infinite lds-spinner-x-essential-lib-c3545c8d}.lds-spinner div[data-v-x-essential-lib-c3545c8d]:after{content:" ";background:#9e9e9e;border-radius:5%;width:2px;height:6px;display:block;position:absolute;top:3px;left:18px}.lds-spinner div[data-v-x-essential-lib-c3545c8d]:first-child{animation-delay:-1.1s;transform:rotate(0)}.lds-spinner div[data-v-x-essential-lib-c3545c8d]:nth-child(2){animation-delay:-1s;transform:rotate(30deg)}.lds-spinner div[data-v-x-essential-lib-c3545c8d]:nth-child(3){animation-delay:-.9s;transform:rotate(60deg)}.lds-spinner div[data-v-x-essential-lib-c3545c8d]:nth-child(4){animation-delay:-.8s;transform:rotate(90deg)}.lds-spinner div[data-v-x-essential-lib-c3545c8d]:nth-child(5){animation-delay:-.7s;transform:rotate(120deg)}.lds-spinner div[data-v-x-essential-lib-c3545c8d]:nth-child(6){animation-delay:-.6s;transform:rotate(150deg)}.lds-spinner div[data-v-x-essential-lib-c3545c8d]:nth-child(7){animation-delay:-.5s;transform:rotate(180deg)}.lds-spinner div[data-v-x-essential-lib-c3545c8d]:nth-child(8){animation-delay:-.4s;transform:rotate(210deg)}.lds-spinner div[data-v-x-essential-lib-c3545c8d]:nth-child(9){animation-delay:-.3s;transform:rotate(240deg)}.lds-spinner div[data-v-x-essential-lib-c3545c8d]:nth-child(10){animation-delay:-.2s;transform:rotate(270deg)}.lds-spinner div[data-v-x-essential-lib-c3545c8d]:nth-child(11){animation-delay:-.1s;transform:rotate(300deg)}.lds-spinner div[data-v-x-essential-lib-c3545c8d]:nth-child(12){animation-delay:0s;transform:rotate(330deg)}@keyframes lds-spinner-x-essential-lib-c3545c8d{0%{opacity:1}to{opacity:0}}.x-item[data-v-x-essential-lib-cfcda9d9]{width:600px}@media (width<=600px){.x-item[data-v-x-essential-lib-cfcda9d9]{width:calc(100vw - 16px)}}.x-cont[data-v-x-essential-lib-b973907d]{z-index:9999;position:fixed;bottom:20px;left:50%;transform:translate(-50%)}`);e.appendChild(t);document.head.appendChild(e);}catch(e){console.error('rolldown-plugin-inject-css', e);}})()
2
- import { a as api, i as mitt_default, o as usePreferredDark, r as toLower } from "./vendor.dqdzrw43.js";
2
+ import { a as api, i as mitt_default, o as usePreferredDark, r as toLower } from "./vendor.homyhtbu.js";
3
3
  import { Fragment, Transition, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, inject, isRef, normalizeStyle, onBeforeMount, onBeforeUnmount, onMounted, openBlock, provide, ref, renderList, resolveComponent, toDisplayString, unref, useTemplateRef, watch, watchEffect, withCtx, withKeys, withModifiers } from "vue";
4
4
  import { useI18n } from "vue-i18n";
5
5
  import { useDisplay, useTheme } from "vuetify";
@@ -431,6 +431,25 @@ 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
+
434
453
  //#endregion
435
454
  //#region src/utils/router.ts
436
455
  const routeMetas = [
@@ -611,6 +630,31 @@ async function onBeforeEach(to, from, lastAppPath) {
611
630
  if (hasAccessToken && to.path.startsWith("/passport/")) return { path: `/main/${Date.now()}` };
612
631
  onBeforeChange(to.path, from.path, lastAppPath);
613
632
  }
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
+ }
614
658
 
615
659
  //#endregion
616
660
  //#region src/utils/type.ts
@@ -742,67 +786,13 @@ function useGlobalStates(globalStates, base) {
742
786
  });
743
787
  }
744
788
 
745
- //#endregion
746
- //#region src/api/orgbase/instance.ts
747
- const instance = createAxios$1({
748
- baseUrl: "http://localhost/orgbase/",
749
- onError: (error) => {
750
- messageError$1(getErrorMessage(error));
751
- }
752
- });
753
- if (window.API_URL) instance.defaults.baseURL = window.API_URL + "/orgbase/";
754
-
755
- //#endregion
756
- //#region src/api/orgbase/index.ts
757
- function GetOrgName(request) {
758
- return instance.post("getOrgName", request);
759
- }
760
- function PullPermission(request) {
761
- return instance.post("pullPermission", request);
762
- }
763
-
764
789
  //#endregion
765
790
  //#region src/composables/microApp.ts
766
- function useMicroApp(globalStates, ignoreSyncOrg, onRouteChange, customBack) {
791
+ function useMicroApp(globalStates, customBack) {
767
792
  const route = useRoute();
768
793
  const router = useRouter();
769
794
  useGlobalStates(globalStates);
770
795
  const { activeOrg, views } = globalStates;
771
- async function syncOrg() {
772
- const orgId = route.query.orgId;
773
- if (!orgId) {
774
- router.replace({ path: `/main/${Date.now()}` });
775
- return false;
776
- }
777
- if (orgId === "public") {
778
- eventBus.emit("updateActiveOrg", [orgId, ""]);
779
- eventBus.emit("updatePermission", [{}, ""]);
780
- return true;
781
- }
782
- try {
783
- const { name } = await GetOrgName({ orgId });
784
- const { permissions } = await PullPermission({
785
- orgId,
786
- checksum: ""
787
- });
788
- eventBus.emit("updateActiveOrg", [orgId, name]);
789
- eventBus.emit("updatePermission", [toPermissionObjects(permissions), permissions.checksum ?? ""]);
790
- return true;
791
- } catch (e) {
792
- if (e === "org not found" || e === "org member not found") router.replace({ path: `/main/${Date.now()}` });
793
- return false;
794
- }
795
- }
796
- async function fetch() {
797
- if (!ignoreSyncOrg && !await syncOrg()) return;
798
- await onRouteChange?.();
799
- }
800
- onBeforeMount(async () => {
801
- await fetch();
802
- });
803
- watch(() => route.path, async () => {
804
- await fetch();
805
- });
806
796
  async function handleBack() {
807
797
  if (!isEmpty(views)) {
808
798
  if (!hasView(views, "waitDlg")) popView(views);
@@ -1598,4 +1588,4 @@ async function loadLocaleMessageEssential(locale) {
1598
1588
  var src_default = { install };
1599
1589
 
1600
1590
  //#endregion
1601
- 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, useSystem, useViewStack, verifyPermission, waitMs, waitUtil };
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, switchOrg, toPermissionObjects, types, useColor, useGlobalStates, useMicroApp, usePermission, useSystem, useViewStack, verifyPermission, waitMs, waitUtil };
@@ -577,12 +577,12 @@ function toLower(value) {
577
577
  //#endregion
578
578
  //#region node_modules/.pnpm/mitt@3.0.1/node_modules/mitt/index.d.ts
579
579
  var EventType = [
580
- 60,
580
+ 61,
581
581
  () => [],
582
582
  []
583
583
  ];
584
584
  var Handler = [
585
- 61,
585
+ 62,
586
586
  (T) => [T],
587
587
  [
588
588
  "",
@@ -591,7 +591,7 @@ var Handler = [
591
591
  ]
592
592
  ];
593
593
  var WildcardHandler = [
594
- 62,
594
+ 63,
595
595
  (T) => [
596
596
  Record,
597
597
  T,
@@ -609,7 +609,7 @@ var WildcardHandler = [
609
609
  ]
610
610
  ];
611
611
  var EventHandlerList = [
612
- 63,
612
+ 64,
613
613
  (T) => [
614
614
  T,
615
615
  Handler,
@@ -623,7 +623,7 @@ var EventHandlerList = [
623
623
  ]
624
624
  ];
625
625
  var WildCardEventHandlerList = [
626
- 64,
626
+ 65,
627
627
  (T) => [
628
628
  Record,
629
629
  T,
@@ -639,7 +639,7 @@ var WildCardEventHandlerList = [
639
639
  ]
640
640
  ];
641
641
  var EventHandlerMap = [
642
- 65,
642
+ 66,
643
643
  (Events) => [
644
644
  EventType,
645
645
  Record,
@@ -665,7 +665,7 @@ var EventHandlerMap = [
665
665
  ]
666
666
  ];
667
667
  var Emitter = [
668
- 66,
668
+ 67,
669
669
  (Key, Events) => [
670
670
  EventType,
671
671
  Record,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x-essential-lib",
3
- "version": "0.10.23",
3
+ "version": "0.10.24",
4
4
  "files": [
5
5
  "dist"
6
6
  ],