x-essential-lib 0.10.33 → 0.10.35

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
@@ -304,16 +304,16 @@ declare function useGlobalStates(globalStates: GlobalStates, base?: boolean): vo
304
304
  //#region src/composables/microApp.d.ts
305
305
  declare function useMicroApp(globalStates: GlobalStates, customBack?: (m: RouteMeta) => void): void;
306
306
  //#endregion
307
+ //#region src/composables/pageRoute.d.ts
308
+ declare function usePageRoute(onRouteChange?: () => Promise<void>): {
309
+ syncOrg: () => Promise<boolean>;
310
+ };
311
+ //#endregion
307
312
  //#region src/composables/permission.d.ts
308
313
  declare function usePermission(): {
309
314
  verifyPermission: (permission: Permission, instance?: string) => boolean;
310
315
  };
311
316
  //#endregion
312
- //#region src/composables/routeChange.d.ts
313
- declare function useRouteChange(onRouteChange?: () => Promise<void>): {
314
- syncOrg: () => Promise<boolean>;
315
- };
316
- //#endregion
317
317
  //#region src/composables/system.d.ts
318
318
  declare function useSystem(): {
319
319
  sysBarAvail: import("vue").ComputedRef<boolean>;
@@ -554,4 +554,4 @@ declare const _default: {
554
554
  install: (app: import("vue").App) => void;
555
555
  };
556
556
  //#endregion
557
- 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, onBeforeEnter, openConfirmDlg, openNumberDlg, openPromptDlg, openWaitDlg, popView, provideDark, provideLocale, providePermissionObjects, provideViews, routeTransName, toPermissionObjects, types, useColor, useGlobalStates, useMicroApp, usePermission, useRouteChange, useSystem, useViewStack, verifyPermission, waitMs, waitUtil };
557
+ 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, onBeforeEnter, openConfirmDlg, openNumberDlg, openPromptDlg, openWaitDlg, popView, provideDark, provideLocale, providePermissionObjects, provideViews, routeTransName, toPermissionObjects, types, useColor, useGlobalStates, useMicroApp, usePageRoute, usePermission, useSystem, useViewStack, verifyPermission, waitMs, waitUtil };
package/dist/index.js CHANGED
@@ -36,6 +36,53 @@ function useColor() {
36
36
  };
37
37
  }
38
38
 
39
+ //#endregion
40
+ //#region src/utils/misc.ts
41
+ const globalObjects = (function() {
42
+ if (!window.globalObjects) {
43
+ window.globalObjects = {
44
+ router: null,
45
+ i18n: null
46
+ };
47
+ console.log("globalObjects created");
48
+ }
49
+ return window.globalObjects;
50
+ })();
51
+ const eventBus = (function() {
52
+ if (!window.eventBus) {
53
+ window.eventBus = mitt_default();
54
+ console.log("eventBus created");
55
+ }
56
+ return window.eventBus;
57
+ })();
58
+ async function waitMs(ms) {
59
+ return new Promise((resolve) => {
60
+ setTimeout(resolve, ms);
61
+ });
62
+ }
63
+ async function waitUtil(conditionFunc, timeout, interval) {
64
+ const timestamp = Date.now();
65
+ return new Promise((resolve) => {
66
+ const check = () => {
67
+ if (conditionFunc()) resolve(true);
68
+ else if (timeout && Date.now() - timestamp > timeout) resolve(false);
69
+ else setTimeout(check, interval ?? 30);
70
+ };
71
+ check();
72
+ });
73
+ }
74
+ function appAppear(name, diff) {
75
+ const appElement = document.getElementById("single-spa-application:" + name);
76
+ if (!appElement) return;
77
+ appElement.classList.remove("app-fade", "app-left", "app-right", "app-reset");
78
+ if (diff === 0) return;
79
+ if (diff > 0) appElement.classList.add("app-left");
80
+ else appElement.classList.add("app-right");
81
+ setTimeout(() => {
82
+ appElement.classList.add("app-reset");
83
+ }, 50);
84
+ }
85
+
39
86
  //#endregion
40
87
  //#region src/utils/axios.ts
41
88
  function createAxios(options) {
@@ -85,59 +132,12 @@ function onRespRejected(error, onError) {
85
132
  }
86
133
  }
87
134
  function onUnauthorized() {
88
- const router = useRouter();
135
+ const { router } = globalObjects;
89
136
  api.remove("accessToken");
90
137
  api.remove("refreshToken");
91
138
  router.replace({ path: `/passport/login` });
92
139
  }
93
140
 
94
- //#endregion
95
- //#region src/utils/misc.ts
96
- const globalObjects = (function() {
97
- if (!window.globalObjects) {
98
- window.globalObjects = {
99
- router: null,
100
- i18n: null
101
- };
102
- console.log("globalObjects created");
103
- }
104
- return window.globalObjects;
105
- })();
106
- const eventBus = (function() {
107
- if (!window.eventBus) {
108
- window.eventBus = mitt_default();
109
- console.log("eventBus created");
110
- }
111
- return window.eventBus;
112
- })();
113
- async function waitMs(ms) {
114
- return new Promise((resolve) => {
115
- setTimeout(resolve, ms);
116
- });
117
- }
118
- async function waitUtil(conditionFunc, timeout, interval) {
119
- const timestamp = Date.now();
120
- return new Promise((resolve) => {
121
- const check = () => {
122
- if (conditionFunc()) resolve(true);
123
- else if (timeout && Date.now() - timestamp > timeout) resolve(false);
124
- else setTimeout(check, interval ?? 30);
125
- };
126
- check();
127
- });
128
- }
129
- function appAppear(name, diff) {
130
- const appElement = document.getElementById("single-spa-application:" + name);
131
- if (!appElement) return;
132
- appElement.classList.remove("app-fade", "app-left", "app-right", "app-reset");
133
- if (diff === 0) return;
134
- if (diff > 0) appElement.classList.add("app-left");
135
- else appElement.classList.add("app-right");
136
- setTimeout(() => {
137
- appElement.classList.add("app-reset");
138
- }, 50);
139
- }
140
-
141
141
  //#endregion
142
142
  //#region src/utils/dialog.ts
143
143
  let lastTime = Date.now();
@@ -773,16 +773,6 @@ function useMicroApp(globalStates, customBack) {
773
773
  });
774
774
  }
775
775
 
776
- //#endregion
777
- //#region src/composables/permission.ts
778
- function usePermission() {
779
- const permissionObjects = injectPermissionObjects();
780
- function verifyPermission$1(permission, instance) {
781
- return verifyPermission(permissionObjects.value, permission, instance ?? "");
782
- }
783
- return { verifyPermission: verifyPermission$1 };
784
- }
785
-
786
776
  //#endregion
787
777
  //#region src/api/orgbase/instance.ts
788
778
  const instance = createAxios$1({
@@ -803,8 +793,8 @@ function PullPermission(request) {
803
793
  }
804
794
 
805
795
  //#endregion
806
- //#region src/composables/routeChange.ts
807
- function useRouteChange(onRouteChange) {
796
+ //#region src/composables/pageRoute.ts
797
+ function usePageRoute(onRouteChange) {
808
798
  const route = useRoute();
809
799
  const router = useRouter();
810
800
  async function syncOrg() {
@@ -843,6 +833,16 @@ function useRouteChange(onRouteChange) {
843
833
  return { syncOrg };
844
834
  }
845
835
 
836
+ //#endregion
837
+ //#region src/composables/permission.ts
838
+ function usePermission() {
839
+ const permissionObjects = injectPermissionObjects();
840
+ function verifyPermission$1(permission, instance) {
841
+ return verifyPermission(permissionObjects.value, permission, instance ?? "");
842
+ }
843
+ return { verifyPermission: verifyPermission$1 };
844
+ }
845
+
846
846
  //#endregion
847
847
  //#region src/composables/system.ts
848
848
  function useSystem() {
@@ -1593,4 +1593,4 @@ async function loadLocaleMessageEssential(locale) {
1593
1593
  var src_default = { install };
1594
1594
 
1595
1595
  //#endregion
1596
- 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, onBeforeEnter, openConfirmDlg, openNumberDlg, openPromptDlg, openWaitDlg, popView, provideDark, provideLocale, providePermissionObjects, provideViews, routeTransName, toPermissionObjects, types, useColor, useGlobalStates, useMicroApp, usePermission, useRouteChange, useSystem, useViewStack, verifyPermission, waitMs, waitUtil };
1596
+ 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, onBeforeEnter, openConfirmDlg, openNumberDlg, openPromptDlg, openWaitDlg, popView, provideDark, provideLocale, providePermissionObjects, provideViews, routeTransName, toPermissionObjects, types, useColor, useGlobalStates, useMicroApp, usePageRoute, usePermission, useSystem, useViewStack, verifyPermission, waitMs, waitUtil };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x-essential-lib",
3
- "version": "0.10.33",
3
+ "version": "0.10.35",
4
4
  "files": [
5
5
  "dist"
6
6
  ],