x-essential-lib 0.10.12 → 0.10.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.
@@ -3,12 +3,12 @@ import { t as __exportAll } from "./rolldown-runtime.c6i0pdwe.js";
3
3
  //#region src/i18n/locales/en/index.ts
4
4
  var en_exports = /* @__PURE__ */ __exportAll({ default: () => en_default });
5
5
  var en_default = {
6
- dlg: { common: {
6
+ "dlg": { common: {
7
7
  cancel: "Cancel",
8
8
  confirm: "Confirm",
9
9
  responding: "Responding..."
10
10
  } },
11
- $vuetify: {
11
+ "$vuetify": {
12
12
  badge: "Badge",
13
13
  open: "Open",
14
14
  close: "Close",
@@ -194,7 +194,8 @@ var en_default = {
194
194
  hexaInput: "HEX with alpha value",
195
195
  changeFormat: "Change color format"
196
196
  } }
197
- }
197
+ },
198
+ "x-essential-lib": { publicDomain: "Public Domain" }
198
199
  };
199
200
 
200
201
  //#endregion
@@ -3,12 +3,12 @@ import { t as __exportAll } from "./rolldown-runtime.c6i0pdwe.js";
3
3
  //#region src/i18n/locales/zhHans/index.ts
4
4
  var zhHans_exports = /* @__PURE__ */ __exportAll({ default: () => zhHans_default });
5
5
  var zhHans_default = {
6
- dlg: { common: {
6
+ "dlg": { common: {
7
7
  cancel: "取消",
8
8
  confirm: "确定",
9
9
  responding: "响应中..."
10
10
  } },
11
- $vuetify: {
11
+ "$vuetify": {
12
12
  badge: "徽章",
13
13
  open: "打开",
14
14
  close: "关闭",
@@ -194,7 +194,8 @@ var zhHans_default = {
194
194
  hexaInput: "带不透明度 HEX 值",
195
195
  changeFormat: "更改颜色格式"
196
196
  } }
197
- }
197
+ },
198
+ "x-essential-lib": { publicDomain: "公域" }
198
199
  };
199
200
 
200
201
  //#endregion
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as EventType, t as Emitter } from "./vendor.nvyu21oc.js";
1
+ import { n as EventType, t as Emitter } from "./vendor.bri8m5ch.js";
2
2
  import { Ref } from "vue";
3
3
  import { RouteLocationNormalized } from "vue-router";
4
4
  import { AxiosInstance } from "axios";
@@ -256,6 +256,8 @@ declare function provideLocale(locale: Ref<string>): void;
256
256
  declare function injectLocale(): Ref<string>;
257
257
  declare function provideActiveOrg(activeOrg: Ref<string>): void;
258
258
  declare function injectActiveOrg(): Ref<string>;
259
+ declare function provideActiveOrgName(activeOrgName: Ref<string>): void;
260
+ declare function injectActiveOrgName(): Ref<string>;
259
261
  declare function providePermissionObjects(permissionObjects: Ref<PermissionObjects>): void;
260
262
  declare function injectPermissionObjects(): Ref<PermissionObjects>;
261
263
  declare function providePermissionChecksum(permissionChecksum: Ref<string>): void;
@@ -305,12 +307,13 @@ interface GlobalStates {
305
307
  dark: Ref<boolean | undefined>;
306
308
  locale: Ref<string>;
307
309
  activeOrg: Ref<string>;
310
+ activeOrgName: Ref<string>;
308
311
  permissionObjects: Ref<PermissionObjects>;
309
312
  permissionChecksum: Ref<string>;
310
313
  lastAppPath: Ref<string>;
311
314
  views: Ref<string[]>;
312
315
  }
313
- declare function useMicroApp(globalStates: GlobalStates, syncLocale: () => Promise<void>, base?: boolean, customBack?: (m: RouteMeta) => void): void;
316
+ declare function useMicroApp(globalStates: GlobalStates, base?: boolean, customBack?: (m: RouteMeta) => void): void;
314
317
  //#endregion
315
318
  //#region src/composables/permission.d.ts
316
319
  declare function usePermission(): {
@@ -546,6 +549,9 @@ declare function loadLocaleMessageEssential(locale: string): Promise<{
546
549
  };
547
550
  };
548
551
  };
552
+ 'x-essential-lib': {
553
+ publicDomain: string;
554
+ };
549
555
  }>;
550
556
  //#endregion
551
557
  //#region src/index.d.ts
@@ -553,4 +559,4 @@ declare const _default: {
553
559
  install: (app: import("vue").App) => void;
554
560
  };
555
561
  //#endregion
556
- export { Permission, PermissionObjects, RouteMeta, Type, addView, appAppear, clearViews, closeWaitDlg, createAxios, _default as default, delView, eventBus, getTypeColor, getTypeDefault, globalObjects, hasView, injectActiveOrg, injectDark, injectLastAppPath, injectLocale, injectPermissionChecksum, injectPermissionObjects, injectViews, isEmpty, isExist, lastView, loadLocaleMessageEssential, matchRouteMeta, messageError, messageInfo, messageSuccess, messageWarning, onBeforeEach, openConfirmDlg, openNumberDlg, openPromptDlg, openWaitDlg, popView, provideActiveOrg, provideDark, provideLastAppPath, provideLocale, providePermissionChecksum, providePermissionObjects, provideViews, routeTransName, toPermissionObjects, types, useColor, useMicroApp, usePermission, useSystem, useViewStack, verifyPermission, waitMs, waitUtil };
562
+ export { Permission, PermissionObjects, RouteMeta, Type, addView, appAppear, clearViews, closeWaitDlg, createAxios, _default as default, delView, eventBus, getTypeColor, getTypeDefault, globalObjects, hasView, injectActiveOrg, injectActiveOrgName, injectDark, injectLastAppPath, injectLocale, injectPermissionChecksum, injectPermissionObjects, injectViews, isEmpty, isExist, lastView, loadLocaleMessageEssential, matchRouteMeta, messageError, messageInfo, messageSuccess, messageWarning, onBeforeEach, openConfirmDlg, openNumberDlg, openPromptDlg, openWaitDlg, popView, provideActiveOrg, provideActiveOrgName, provideDark, provideLastAppPath, provideLocale, providePermissionChecksum, providePermissionObjects, provideViews, routeTransName, toPermissionObjects, types, useColor, 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.nvyu21oc.js";
2
+ import { a as api, i as mitt_default, o as usePreferredDark, r as toLower } from "./vendor.bri8m5ch.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";
@@ -48,6 +48,9 @@ if (window.API_URL) instance.defaults.baseURL = window.API_URL + "/orgbase/";
48
48
 
49
49
  //#endregion
50
50
  //#region src/api/orgbase/index.ts
51
+ function GetOrgName(request) {
52
+ return instance.post("getOrgName", request);
53
+ }
51
54
  function PullPermission(request) {
52
55
  return instance.post("pullPermission", request);
53
56
  }
@@ -433,6 +436,12 @@ function provideActiveOrg(activeOrg) {
433
436
  function injectActiveOrg() {
434
437
  return inject("essentialActiveOrg");
435
438
  }
439
+ function provideActiveOrgName(activeOrgName) {
440
+ provide("essentialActiveOrgName", activeOrgName);
441
+ }
442
+ function injectActiveOrgName() {
443
+ return inject("essentialActiveOrgName");
444
+ }
436
445
  function providePermissionObjects(permissionObjects) {
437
446
  provide("essentialPermissionObjects", permissionObjects);
438
447
  }
@@ -633,12 +642,20 @@ function onBeforeChange(toPath, fromPath, lastAppPath) {
633
642
  function isHasAccessToken() {
634
643
  return !!api.get("accessToken");
635
644
  }
645
+ async function syncOrg(orgId) {
646
+ if (orgId !== "public") {
647
+ const { name } = await GetOrgName({ orgId });
648
+ eventBus.emit("updateActiveOrg", [orgId, name]);
649
+ } else eventBus.emit("updateActiveOrg", [orgId, ""]);
650
+ }
636
651
  async function syncPermission(orgId) {
637
- const { permissions } = await PullPermission({
638
- orgId,
639
- checksum: ""
640
- });
641
- eventBus.emit("updatePermission", [toPermissionObjects(permissions), permissions["checksum"] ?? ""]);
652
+ if (orgId !== "public") {
653
+ const { permissions } = await PullPermission({
654
+ orgId,
655
+ checksum: ""
656
+ });
657
+ eventBus.emit("updatePermission", [toPermissionObjects(permissions), permissions["checksum"] ?? ""]);
658
+ } else eventBus.emit("updatePermission", [{}, ""]);
642
659
  }
643
660
  async function onBeforeEach(to, from, lastAppPath) {
644
661
  const hasAccessToken = isHasAccessToken();
@@ -650,8 +667,8 @@ async function onBeforeEach(to, from, lastAppPath) {
650
667
  if (to.path.startsWith("/passport/")) onBeforeChange(to.path, from.path, lastAppPath);
651
668
  else if (to.path.startsWith("/main")) try {
652
669
  if (!orgId) throw new Error(`orgId not specified`);
670
+ await syncOrg(orgId);
653
671
  await syncPermission(orgId);
654
- eventBus.emit("updateActiveOrg", orgId);
655
672
  onBeforeChange(to.path, from.path, lastAppPath);
656
673
  } catch {
657
674
  return {
@@ -661,8 +678,8 @@ async function onBeforeEach(to, from, lastAppPath) {
661
678
  }
662
679
  else try {
663
680
  if (!orgId) throw new Error(`orgId not specified`);
681
+ await syncOrg(orgId);
664
682
  await syncPermission(orgId);
665
- eventBus.emit("updateActiveOrg", orgId);
666
683
  onBeforeChange(to.path, from.path, lastAppPath);
667
684
  } catch {
668
685
  return { path: `/main` };
@@ -731,10 +748,11 @@ function clearViews(views) {
731
748
 
732
749
  //#endregion
733
750
  //#region src/composables/microApp.ts
734
- function useMicroApp(globalStates, syncLocale, base, customBack) {
751
+ function useMicroApp(globalStates, base, customBack) {
752
+ const { t } = useI18n();
735
753
  const route = useRoute();
736
754
  const router = useRouter();
737
- const { dark, locale, activeOrg, permissionObjects, permissionChecksum, lastAppPath, views } = globalStates;
755
+ const { dark, locale, activeOrg, activeOrgName, permissionObjects, permissionChecksum, lastAppPath, views } = globalStates;
738
756
  const prefDark = usePreferredDark();
739
757
  const finalDark = ref(false);
740
758
  watchEffect(() => {
@@ -747,19 +765,10 @@ function useMicroApp(globalStates, syncLocale, base, customBack) {
747
765
  watchEffect(async () => {
748
766
  await theme.change(finalDark.value ? "dark" : "light");
749
767
  });
750
- let pending = true;
751
- router.beforeEach(async (to, from) => {
752
- await syncLocale();
753
- pending = false;
754
- return onBeforeEach(to, from, lastAppPath.value);
755
- });
756
- watch(locale, async () => {
757
- if (pending) return;
758
- await syncLocale();
759
- });
760
768
  provideDark(finalDark);
761
769
  provideLocale(locale);
762
770
  provideActiveOrg(activeOrg);
771
+ provideActiveOrgName(activeOrgName);
763
772
  providePermissionObjects(permissionObjects);
764
773
  providePermissionChecksum(permissionChecksum);
765
774
  provideLastAppPath(lastAppPath);
@@ -825,7 +834,10 @@ function useMicroApp(globalStates, syncLocale, base, customBack) {
825
834
  if (!routeMeta) return;
826
835
  if (routeMeta.level === 0) navigator?.Backbutton?.goHome(() => {}, () => {});
827
836
  else if (customBack) customBack(routeMeta);
828
- else if (routeMeta.back) await router.replace({ path: routeMeta.back });
837
+ else if (routeMeta.back) await router.replace({
838
+ path: routeMeta.back,
839
+ query: { orgId: activeOrg.value }
840
+ });
829
841
  }
830
842
  async function onKeyDown(e) {
831
843
  if (e.key === "Escape") {
@@ -881,8 +893,14 @@ function useMicroApp(globalStates, syncLocale, base, customBack) {
881
893
  function onUpdateLocale(val) {
882
894
  locale.value = val;
883
895
  }
896
+ const activeOrgNameRaw = ref("");
897
+ watchEffect(() => {
898
+ if (activeOrg.value === "public") activeOrgName.value = t("x-essential-lib.publicDomain");
899
+ else activeOrgName.value = activeOrgNameRaw.value;
900
+ });
884
901
  function onUpdateActiveOrg(val) {
885
- activeOrg.value = val;
902
+ activeOrg.value = val[0];
903
+ activeOrgNameRaw.value = val[1];
886
904
  }
887
905
  function onUpdatePermission(val) {
888
906
  permissionObjects.value = val[0];
@@ -894,7 +912,7 @@ function useMicroApp(globalStates, syncLocale, base, customBack) {
894
912
  function onSyncGlobalStates() {
895
913
  eventBus.emit("updateDark", dark.value);
896
914
  eventBus.emit("updateLocale", locale.value);
897
- eventBus.emit("updateActiveOrg", activeOrg.value);
915
+ eventBus.emit("updateActiveOrg", [activeOrg.value, activeOrgNameRaw.value]);
898
916
  eventBus.emit("updatePermission", [permissionObjects.value, permissionChecksum.value]);
899
917
  eventBus.emit("updateLastAppPath", lastAppPath.value);
900
918
  }
@@ -1667,8 +1685,8 @@ const install = (app) => {
1667
1685
  //#endregion
1668
1686
  //#region src/i18n/index.ts
1669
1687
  async function loadLocaleMessageEssential(locale) {
1670
- if (locale === "en") return (await import("./i18n-en.exw0q3rp.js").then((n) => n.t)).default;
1671
- else if (locale === "zhHans") return (await import("./i18n-zhHans.itmme76z.js").then((n) => n.t)).default;
1688
+ if (locale === "en") return (await import("./i18n-en.fcyirt0q.js").then((n) => n.t)).default;
1689
+ else if (locale === "zhHans") return (await import("./i18n-zhHans.kjj6z3dm.js").then((n) => n.t)).default;
1672
1690
  else throw new Error(`invalid locale=${locale}`);
1673
1691
  }
1674
1692
 
@@ -1677,4 +1695,4 @@ async function loadLocaleMessageEssential(locale) {
1677
1695
  var src_default = { install };
1678
1696
 
1679
1697
  //#endregion
1680
- export { Permission, addView, appAppear, clearViews, closeWaitDlg, createAxios, src_default as default, delView, eventBus, getTypeColor, getTypeDefault, globalObjects, hasView, injectActiveOrg, injectDark, injectLastAppPath, injectLocale, injectPermissionChecksum, injectPermissionObjects, injectViews, isEmpty, isExist, lastView, loadLocaleMessageEssential, matchRouteMeta, messageError, messageInfo, messageSuccess, messageWarning, onBeforeEach, openConfirmDlg, openNumberDlg, openPromptDlg, openWaitDlg, popView, provideActiveOrg, provideDark, provideLastAppPath, provideLocale, providePermissionChecksum, providePermissionObjects, provideViews, routeTransName, toPermissionObjects, types, useColor, useMicroApp, usePermission, useSystem, useViewStack, verifyPermission, waitMs, waitUtil };
1698
+ export { Permission, addView, appAppear, clearViews, closeWaitDlg, createAxios, src_default as default, delView, eventBus, getTypeColor, getTypeDefault, globalObjects, hasView, injectActiveOrg, injectActiveOrgName, injectDark, injectLastAppPath, injectLocale, injectPermissionChecksum, injectPermissionObjects, injectViews, isEmpty, isExist, lastView, loadLocaleMessageEssential, matchRouteMeta, messageError, messageInfo, messageSuccess, messageWarning, onBeforeEach, openConfirmDlg, openNumberDlg, openPromptDlg, openWaitDlg, popView, provideActiveOrg, provideActiveOrgName, provideDark, provideLastAppPath, provideLocale, providePermissionChecksum, providePermissionObjects, provideViews, routeTransName, toPermissionObjects, types, useColor, 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
- 65,
580
+ 67,
581
581
  () => [],
582
582
  []
583
583
  ];
584
584
  var Handler = [
585
- 66,
585
+ 68,
586
586
  (T) => [T],
587
587
  [
588
588
  "",
@@ -591,7 +591,7 @@ var Handler = [
591
591
  ]
592
592
  ];
593
593
  var WildcardHandler = [
594
- 67,
594
+ 69,
595
595
  (T) => [
596
596
  Record,
597
597
  T,
@@ -609,7 +609,7 @@ var WildcardHandler = [
609
609
  ]
610
610
  ];
611
611
  var EventHandlerList = [
612
- 68,
612
+ 70,
613
613
  (T) => [
614
614
  T,
615
615
  Handler,
@@ -623,7 +623,7 @@ var EventHandlerList = [
623
623
  ]
624
624
  ];
625
625
  var WildCardEventHandlerList = [
626
- 69,
626
+ 71,
627
627
  (T) => [
628
628
  Record,
629
629
  T,
@@ -639,7 +639,7 @@ var WildCardEventHandlerList = [
639
639
  ]
640
640
  ];
641
641
  var EventHandlerMap = [
642
- 70,
642
+ 72,
643
643
  (Events) => [
644
644
  EventType,
645
645
  Record,
@@ -665,7 +665,7 @@ var EventHandlerMap = [
665
665
  ]
666
666
  ];
667
667
  var Emitter = [
668
- 71,
668
+ 73,
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.12",
3
+ "version": "0.10.14",
4
4
  "files": [
5
5
  "dist"
6
6
  ],