x-essential-lib 0.10.19 → 0.10.21
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 +11 -20
- package/dist/index.js +137 -231
- package/dist/{vendor.bri8m5ch.js → vendor.dqdzrw43.js} +7 -7
- package/package.json +4 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as EventType, t as Emitter } from "./vendor.
|
|
1
|
+
import { n as EventType, t as Emitter } from "./vendor.dqdzrw43.js";
|
|
2
2
|
import { Ref } from "vue";
|
|
3
|
-
import { RouteLocationNormalized } from "vue-router";
|
|
4
3
|
import { AxiosInstance } from "axios";
|
|
4
|
+
import { RouteLocationNormalized } from "vue-router";
|
|
5
5
|
|
|
6
6
|
//#region src/composables/color.d.ts
|
|
7
7
|
declare function useColor(): {
|
|
@@ -254,16 +254,8 @@ declare function provideDark(dark: Ref<boolean>): void;
|
|
|
254
254
|
declare function injectDark(): Ref<boolean>;
|
|
255
255
|
declare function provideLocale(locale: Ref<string>): void;
|
|
256
256
|
declare function injectLocale(): Ref<string>;
|
|
257
|
-
declare function provideActiveOrg(activeOrg: Ref<string>): void;
|
|
258
|
-
declare function injectActiveOrg(): Ref<string>;
|
|
259
|
-
declare function provideActiveOrgName(activeOrgName: Ref<string>): void;
|
|
260
|
-
declare function injectActiveOrgName(): Ref<string>;
|
|
261
257
|
declare function providePermissionObjects(permissionObjects: Ref<PermissionObjects>): void;
|
|
262
258
|
declare function injectPermissionObjects(): Ref<PermissionObjects>;
|
|
263
|
-
declare function providePermissionChecksum(permissionChecksum: Ref<string>): void;
|
|
264
|
-
declare function injectPermissionChecksum(): Ref<string>;
|
|
265
|
-
declare function provideLastAppPath(lastAppPath: Ref<string>): void;
|
|
266
|
-
declare function injectLastAppPath(): Ref<string>;
|
|
267
259
|
declare function provideViews(views: Ref<string[]>): void;
|
|
268
260
|
declare function injectViews(): Ref<string[]>;
|
|
269
261
|
//#endregion
|
|
@@ -279,12 +271,6 @@ declare function matchRouteMeta(path: string): RouteMeta | undefined;
|
|
|
279
271
|
declare const routeTransName: import("vue").Ref<string, string>;
|
|
280
272
|
declare function onBeforeEach(to: RouteLocationNormalized, from: RouteLocationNormalized, lastAppPath: string): Promise<{
|
|
281
273
|
path: string;
|
|
282
|
-
query?: undefined;
|
|
283
|
-
} | {
|
|
284
|
-
path: string;
|
|
285
|
-
query: {
|
|
286
|
-
orgId: string;
|
|
287
|
-
};
|
|
288
274
|
} | undefined>;
|
|
289
275
|
//#endregion
|
|
290
276
|
//#region src/utils/type.d.ts
|
|
@@ -302,18 +288,23 @@ declare function delView(views: Ref<string[]>, name: string): void;
|
|
|
302
288
|
declare function popView(views: Ref<string[]>): void;
|
|
303
289
|
declare function clearViews(views: Ref<string[]>): void;
|
|
304
290
|
//#endregion
|
|
305
|
-
//#region src/composables/
|
|
291
|
+
//#region src/composables/globalStates.d.ts
|
|
306
292
|
interface GlobalStates {
|
|
307
|
-
|
|
293
|
+
darkRaw: Ref<boolean | undefined>;
|
|
294
|
+
dark: Ref<boolean>;
|
|
308
295
|
locale: Ref<string>;
|
|
309
296
|
activeOrg: Ref<string>;
|
|
297
|
+
activeOrgNameRaw: Ref<string>;
|
|
310
298
|
activeOrgName: Ref<string>;
|
|
311
299
|
permissionObjects: Ref<PermissionObjects>;
|
|
312
300
|
permissionChecksum: Ref<string>;
|
|
313
301
|
lastAppPath: Ref<string>;
|
|
314
302
|
views: Ref<string[]>;
|
|
315
303
|
}
|
|
316
|
-
declare function
|
|
304
|
+
declare function useGlobalStates(globalStates: GlobalStates, base?: boolean): void;
|
|
305
|
+
//#endregion
|
|
306
|
+
//#region src/composables/microApp.d.ts
|
|
307
|
+
declare function useMicroApp(globalStates: GlobalStates, ignoreSyncOrg?: boolean, onRouteChange?: () => Promise<void>, customBack?: (m: RouteMeta) => void): void;
|
|
317
308
|
//#endregion
|
|
318
309
|
//#region src/composables/permission.d.ts
|
|
319
310
|
declare function usePermission(): {
|
|
@@ -560,4 +551,4 @@ declare const _default: {
|
|
|
560
551
|
install: (app: import("vue").App) => void;
|
|
561
552
|
};
|
|
562
553
|
//#endregion
|
|
563
|
-
export { Permission, PermissionObjects, RouteMeta, Type, addView, appAppear, clearViews, closeWaitDlg, createAxios, _default as default, delView, eventBus, getTypeColor, getTypeDefault, globalObjects, hasView,
|
|
554
|
+
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 };
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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.
|
|
2
|
+
import { a as api, i as mitt_default, o as usePreferredDark, r as toLower } from "./vendor.dqdzrw43.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";
|
|
6
|
-
import
|
|
6
|
+
import axios from "axios";
|
|
7
|
+
import { onBeforeRouteUpdate, useRoute, useRouter } from "vue-router";
|
|
7
8
|
import { getErrorMessage } from "x-error-lib";
|
|
8
9
|
import { createAxios as createAxios$1, messageError as messageError$1 } from "x-essential-lib";
|
|
9
|
-
import axios from "axios";
|
|
10
10
|
|
|
11
11
|
//#region src/composables/color.ts
|
|
12
12
|
function useColor() {
|
|
@@ -36,25 +36,6 @@ function useColor() {
|
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/api/orgbase/instance.ts
|
|
41
|
-
const instance = createAxios$1({
|
|
42
|
-
baseUrl: "http://localhost/orgbase/",
|
|
43
|
-
onError: (error) => {
|
|
44
|
-
messageError$1(getErrorMessage(error));
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
if (window.API_URL) instance.defaults.baseURL = window.API_URL + "/orgbase/";
|
|
48
|
-
|
|
49
|
-
//#endregion
|
|
50
|
-
//#region src/api/orgbase/index.ts
|
|
51
|
-
function GetOrgName(request) {
|
|
52
|
-
return instance.post("getOrgName", request);
|
|
53
|
-
}
|
|
54
|
-
function PullPermission(request) {
|
|
55
|
-
return instance.post("pullPermission", request);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
39
|
//#endregion
|
|
59
40
|
//#region src/utils/axios.ts
|
|
60
41
|
function createAxios(options) {
|
|
@@ -90,17 +71,24 @@ function onRespRejected(error, onError) {
|
|
|
90
71
|
const resp = error.response;
|
|
91
72
|
if (!resp) return Promise.reject(error);
|
|
92
73
|
if (resp.status === 401) onUnauthorized();
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
74
|
+
const msg = resp.data?.message;
|
|
75
|
+
if (msg) {
|
|
76
|
+
onError(msg);
|
|
77
|
+
return Promise.reject(msg);
|
|
78
|
+
} else {
|
|
79
|
+
const obj = {
|
|
80
|
+
code: resp.status,
|
|
81
|
+
message: resp.statusText
|
|
82
|
+
};
|
|
83
|
+
onError(obj);
|
|
84
|
+
return Promise.reject(obj);
|
|
85
|
+
}
|
|
99
86
|
}
|
|
100
87
|
function onUnauthorized() {
|
|
88
|
+
const router = useRouter();
|
|
101
89
|
api.remove("accessToken");
|
|
102
90
|
api.remove("refreshToken");
|
|
103
|
-
|
|
91
|
+
router.replace({ path: `/passport/login` });
|
|
104
92
|
}
|
|
105
93
|
|
|
106
94
|
//#endregion
|
|
@@ -430,36 +418,12 @@ function provideLocale(locale) {
|
|
|
430
418
|
function injectLocale() {
|
|
431
419
|
return inject("essentialLocale");
|
|
432
420
|
}
|
|
433
|
-
function provideActiveOrg(activeOrg) {
|
|
434
|
-
provide("essentialActiveOrg", activeOrg);
|
|
435
|
-
}
|
|
436
|
-
function injectActiveOrg() {
|
|
437
|
-
return inject("essentialActiveOrg");
|
|
438
|
-
}
|
|
439
|
-
function provideActiveOrgName(activeOrgName) {
|
|
440
|
-
provide("essentialActiveOrgName", activeOrgName);
|
|
441
|
-
}
|
|
442
|
-
function injectActiveOrgName() {
|
|
443
|
-
return inject("essentialActiveOrgName");
|
|
444
|
-
}
|
|
445
421
|
function providePermissionObjects(permissionObjects) {
|
|
446
422
|
provide("essentialPermissionObjects", permissionObjects);
|
|
447
423
|
}
|
|
448
424
|
function injectPermissionObjects() {
|
|
449
425
|
return inject("essentialPermissionObjects");
|
|
450
426
|
}
|
|
451
|
-
function providePermissionChecksum(permissionChecksum) {
|
|
452
|
-
provide("essentialPermissionChecksum", permissionChecksum);
|
|
453
|
-
}
|
|
454
|
-
function injectPermissionChecksum() {
|
|
455
|
-
return inject("essentialPermissionChecksum");
|
|
456
|
-
}
|
|
457
|
-
function provideLastAppPath(lastAppPath) {
|
|
458
|
-
provide("essentialLastAppPath", lastAppPath);
|
|
459
|
-
}
|
|
460
|
-
function injectLastAppPath() {
|
|
461
|
-
return inject("essentialLastAppPath");
|
|
462
|
-
}
|
|
463
427
|
function provideViews(views) {
|
|
464
428
|
provide("viewsKey", views);
|
|
465
429
|
}
|
|
@@ -517,36 +481,42 @@ const routeMetas = [
|
|
|
517
481
|
{
|
|
518
482
|
app: "x-mine-mf",
|
|
519
483
|
path: "/mine/personalInfo",
|
|
484
|
+
back: "/mine",
|
|
520
485
|
level: 1,
|
|
521
486
|
requireAuth: true
|
|
522
487
|
},
|
|
523
488
|
{
|
|
524
489
|
app: "x-mine-mf",
|
|
525
490
|
path: "/mine/settings",
|
|
491
|
+
back: "/mine",
|
|
526
492
|
level: 1,
|
|
527
493
|
requireAuth: true
|
|
528
494
|
},
|
|
529
495
|
{
|
|
530
496
|
app: "x-mine-mf",
|
|
531
497
|
path: "/mine/accountSecurity",
|
|
498
|
+
back: "/mine/settings",
|
|
532
499
|
level: 2,
|
|
533
500
|
requireAuth: true
|
|
534
501
|
},
|
|
535
502
|
{
|
|
536
503
|
app: "x-mine-mf",
|
|
537
504
|
path: "/mine/general",
|
|
505
|
+
back: "/mine/settings",
|
|
538
506
|
level: 2,
|
|
539
507
|
requireAuth: true
|
|
540
508
|
},
|
|
541
509
|
{
|
|
542
510
|
app: "x-mine-mf",
|
|
543
511
|
path: "/mine/darkMode",
|
|
512
|
+
back: "/mine/general",
|
|
544
513
|
level: 3,
|
|
545
514
|
requireAuth: true
|
|
546
515
|
},
|
|
547
516
|
{
|
|
548
517
|
app: "x-mine-mf",
|
|
549
518
|
path: "/mine/language",
|
|
519
|
+
back: "/mine/general",
|
|
550
520
|
level: 3,
|
|
551
521
|
requireAuth: true
|
|
552
522
|
},
|
|
@@ -633,48 +603,13 @@ function onBeforeChange(toPath, fromPath, lastAppPath) {
|
|
|
633
603
|
function isHasAccessToken() {
|
|
634
604
|
return !!api.get("accessToken");
|
|
635
605
|
}
|
|
636
|
-
async function syncOrg(orgId) {
|
|
637
|
-
if (orgId !== "public") {
|
|
638
|
-
const { name } = await GetOrgName({ orgId });
|
|
639
|
-
eventBus.emit("updateActiveOrg", [orgId, name]);
|
|
640
|
-
} else eventBus.emit("updateActiveOrg", [orgId, ""]);
|
|
641
|
-
}
|
|
642
|
-
async function syncPermission(orgId) {
|
|
643
|
-
if (orgId !== "public") {
|
|
644
|
-
const { permissions } = await PullPermission({
|
|
645
|
-
orgId,
|
|
646
|
-
checksum: ""
|
|
647
|
-
});
|
|
648
|
-
eventBus.emit("updatePermission", [toPermissionObjects(permissions), permissions["checksum"] ?? ""]);
|
|
649
|
-
} else eventBus.emit("updatePermission", [{}, ""]);
|
|
650
|
-
}
|
|
651
606
|
async function onBeforeEach(to, from, lastAppPath) {
|
|
652
607
|
const hasAccessToken = isHasAccessToken();
|
|
653
608
|
const toRouteMeta = matchRouteMeta(to.path);
|
|
654
609
|
if (!toRouteMeta) return;
|
|
655
610
|
if (toRouteMeta.requireAuth && !hasAccessToken) return { path: `/passport/login` };
|
|
656
|
-
if (hasAccessToken && to.path.startsWith("/passport/")) return {
|
|
657
|
-
|
|
658
|
-
query: { orgId: "public" }
|
|
659
|
-
};
|
|
660
|
-
if (to.path.startsWith("/passport/")) onBeforeChange(to.path, from.path, lastAppPath);
|
|
661
|
-
else {
|
|
662
|
-
const orgId = to.query.orgId;
|
|
663
|
-
if (!orgId) return {
|
|
664
|
-
path: `/main/${Date.now()}`,
|
|
665
|
-
query: { orgId: "public" }
|
|
666
|
-
};
|
|
667
|
-
try {
|
|
668
|
-
await syncOrg(orgId);
|
|
669
|
-
await syncPermission(orgId);
|
|
670
|
-
onBeforeChange(to.path, from.path, lastAppPath);
|
|
671
|
-
} catch {
|
|
672
|
-
return {
|
|
673
|
-
path: `/main/${Date.now()}`,
|
|
674
|
-
query: { orgId: "public" }
|
|
675
|
-
};
|
|
676
|
-
}
|
|
677
|
-
}
|
|
611
|
+
if (hasAccessToken && to.path.startsWith("/passport/")) return { path: `/main/${Date.now()}` };
|
|
612
|
+
onBeforeChange(to.path, from.path, lastAppPath);
|
|
678
613
|
}
|
|
679
614
|
|
|
680
615
|
//#endregion
|
|
@@ -738,160 +673,35 @@ function clearViews(views) {
|
|
|
738
673
|
}
|
|
739
674
|
|
|
740
675
|
//#endregion
|
|
741
|
-
//#region src/composables/
|
|
742
|
-
function
|
|
676
|
+
//#region src/composables/globalStates.ts
|
|
677
|
+
function useGlobalStates(globalStates, base) {
|
|
743
678
|
const { t } = useI18n();
|
|
744
|
-
const
|
|
745
|
-
|
|
746
|
-
|
|
679
|
+
const { darkRaw, dark, locale, activeOrg, activeOrgNameRaw, activeOrgName, permissionObjects, permissionChecksum, lastAppPath, views } = globalStates;
|
|
680
|
+
provideDark(dark);
|
|
681
|
+
provideLocale(locale);
|
|
682
|
+
providePermissionObjects(permissionObjects);
|
|
683
|
+
provideViews(views);
|
|
747
684
|
const prefDark = usePreferredDark();
|
|
748
|
-
const finalDark = ref(false);
|
|
749
685
|
watchEffect(() => {
|
|
750
686
|
let d;
|
|
751
|
-
if (typeof
|
|
687
|
+
if (typeof darkRaw.value === "boolean") d = darkRaw.value;
|
|
752
688
|
else d = prefDark.value;
|
|
753
|
-
|
|
689
|
+
dark.value = d;
|
|
754
690
|
});
|
|
755
691
|
const theme = useTheme();
|
|
756
692
|
watchEffect(async () => {
|
|
757
|
-
await theme.change(
|
|
693
|
+
await theme.change(dark.value ? "dark" : "light");
|
|
694
|
+
});
|
|
695
|
+
watchEffect(() => {
|
|
696
|
+
if (activeOrg.value === "public") activeOrgName.value = t("x-essential-lib.publicDomain");
|
|
697
|
+
else activeOrgName.value = activeOrgNameRaw.value;
|
|
758
698
|
});
|
|
759
|
-
provideDark(finalDark);
|
|
760
|
-
provideLocale(locale);
|
|
761
|
-
provideActiveOrg(activeOrg);
|
|
762
|
-
provideActiveOrgName(activeOrgName);
|
|
763
|
-
providePermissionObjects(permissionObjects);
|
|
764
|
-
providePermissionChecksum(permissionChecksum);
|
|
765
|
-
provideLastAppPath(lastAppPath);
|
|
766
|
-
provideViews(views);
|
|
767
|
-
function extractPathFromUrl(url) {
|
|
768
|
-
return new URL(url).pathname;
|
|
769
|
-
}
|
|
770
|
-
function onBeforeAppChange(e) {
|
|
771
|
-
const lastAppPath = extractPathFromUrl(e.detail.oldUrl);
|
|
772
|
-
eventBus.emit("updateLastAppPath", lastAppPath);
|
|
773
|
-
}
|
|
774
|
-
if (base) {
|
|
775
|
-
onMounted(() => {
|
|
776
|
-
window.addEventListener("single-spa:before-app-change", onBeforeAppChange);
|
|
777
|
-
});
|
|
778
|
-
onBeforeUnmount(() => {
|
|
779
|
-
window.removeEventListener("single-spa:before-app-change", onBeforeAppChange);
|
|
780
|
-
});
|
|
781
|
-
}
|
|
782
|
-
function syncStatusBar() {
|
|
783
|
-
if (typeof StatusBar !== "object") return;
|
|
784
|
-
if (finalDark.value) StatusBar.styleLightContent();
|
|
785
|
-
else StatusBar.styleDefault();
|
|
786
|
-
}
|
|
787
|
-
const running = ref(true);
|
|
788
|
-
function onPause() {
|
|
789
|
-
running.value = false;
|
|
790
|
-
}
|
|
791
|
-
function onResume() {
|
|
792
|
-
running.value = true;
|
|
793
|
-
}
|
|
794
|
-
async function onBackButton() {
|
|
795
|
-
eventBus.emit("back");
|
|
796
|
-
}
|
|
797
|
-
function onDeviceReady() {
|
|
798
|
-
console.log("onDeviceReady");
|
|
799
|
-
document.addEventListener("pause", onPause, false);
|
|
800
|
-
document.addEventListener("resume", onResume, false);
|
|
801
|
-
document.addEventListener("backbutton", onBackButton, false);
|
|
802
|
-
setInterval(() => {
|
|
803
|
-
syncStatusBar();
|
|
804
|
-
}, 1e3);
|
|
805
|
-
navigator.splashscreen.hide();
|
|
806
|
-
}
|
|
807
|
-
if (base) {
|
|
808
|
-
onMounted(() => {
|
|
809
|
-
document.addEventListener("deviceready", onDeviceReady, false);
|
|
810
|
-
});
|
|
811
|
-
onBeforeUnmount(() => {
|
|
812
|
-
document.removeEventListener("deviceready", onDeviceReady, false);
|
|
813
|
-
});
|
|
814
|
-
watch(finalDark, (val) => {
|
|
815
|
-
window.dispatchEvent(new CustomEvent("darkChange", { detail: val }));
|
|
816
|
-
syncStatusBar();
|
|
817
|
-
}, { immediate: true });
|
|
818
|
-
}
|
|
819
|
-
let handle;
|
|
820
|
-
async function syncPermission() {
|
|
821
|
-
if (!running.value) return;
|
|
822
|
-
if (!api.get("accessToken")) return;
|
|
823
|
-
try {
|
|
824
|
-
const { update, permissions } = await PullPermission({
|
|
825
|
-
orgId: activeOrg.value,
|
|
826
|
-
checksum: permissionChecksum.value
|
|
827
|
-
});
|
|
828
|
-
if (!update) return;
|
|
829
|
-
eventBus.emit("updatePermission", [toPermissionObjects(permissions), permissions["checksum"] ?? ""]);
|
|
830
|
-
} catch (e) {
|
|
831
|
-
console.error(e);
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
async function startTimer() {
|
|
835
|
-
window.clearTimeout(handle);
|
|
836
|
-
handle = window.setTimeout(async () => {
|
|
837
|
-
await syncPermission();
|
|
838
|
-
if (handle) await startTimer();
|
|
839
|
-
}, 3e3);
|
|
840
|
-
}
|
|
841
|
-
function stopTimer() {
|
|
842
|
-
window.clearTimeout(handle);
|
|
843
|
-
handle = void 0;
|
|
844
|
-
}
|
|
845
|
-
if (base) {
|
|
846
|
-
onMounted(async () => {
|
|
847
|
-
await startTimer();
|
|
848
|
-
});
|
|
849
|
-
onBeforeUnmount(() => {
|
|
850
|
-
stopTimer();
|
|
851
|
-
});
|
|
852
|
-
}
|
|
853
|
-
async function handleBack() {
|
|
854
|
-
if (!isEmpty(views)) {
|
|
855
|
-
if (!hasView(views, "waitDlg")) popView(views);
|
|
856
|
-
return;
|
|
857
|
-
}
|
|
858
|
-
const routeMeta = matchRouteMeta(route.path);
|
|
859
|
-
if (!routeMeta) return;
|
|
860
|
-
if (routeMeta.level === 0) navigator?.Backbutton?.goHome(() => {}, () => {});
|
|
861
|
-
else if (customBack) customBack(routeMeta);
|
|
862
|
-
else if (routeMeta.back) router.replace({
|
|
863
|
-
path: routeMeta.back,
|
|
864
|
-
query: { orgId: activeOrg.value }
|
|
865
|
-
});
|
|
866
|
-
else router.back();
|
|
867
|
-
}
|
|
868
|
-
async function onKeyDown(e) {
|
|
869
|
-
if (e.key === "Escape") {
|
|
870
|
-
await handleBack();
|
|
871
|
-
return;
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
if (!base) {
|
|
875
|
-
onMounted(() => {
|
|
876
|
-
window.addEventListener("keydown", onKeyDown);
|
|
877
|
-
eventBus.on("back", handleBack);
|
|
878
|
-
});
|
|
879
|
-
onBeforeUnmount(() => {
|
|
880
|
-
window.removeEventListener("keydown", onKeyDown);
|
|
881
|
-
eventBus.off("back", handleBack);
|
|
882
|
-
});
|
|
883
|
-
}
|
|
884
699
|
function onUpdateDark(val) {
|
|
885
|
-
|
|
700
|
+
darkRaw.value = val;
|
|
886
701
|
}
|
|
887
702
|
function onUpdateLocale(val) {
|
|
888
703
|
locale.value = val;
|
|
889
704
|
}
|
|
890
|
-
const activeOrgNameRaw = ref("");
|
|
891
|
-
watchEffect(() => {
|
|
892
|
-
if (activeOrg.value === "public") activeOrgName.value = t("x-essential-lib.publicDomain");
|
|
893
|
-
else activeOrgName.value = activeOrgNameRaw.value;
|
|
894
|
-
});
|
|
895
705
|
function onUpdateActiveOrg(val) {
|
|
896
706
|
activeOrg.value = val[0];
|
|
897
707
|
activeOrgNameRaw.value = val[1];
|
|
@@ -929,6 +739,102 @@ function useMicroApp(globalStates, base, customBack) {
|
|
|
929
739
|
});
|
|
930
740
|
}
|
|
931
741
|
|
|
742
|
+
//#endregion
|
|
743
|
+
//#region src/api/orgbase/instance.ts
|
|
744
|
+
const instance = createAxios$1({
|
|
745
|
+
baseUrl: "http://localhost/orgbase/",
|
|
746
|
+
onError: (error) => {
|
|
747
|
+
messageError$1(getErrorMessage(error));
|
|
748
|
+
}
|
|
749
|
+
});
|
|
750
|
+
if (window.API_URL) instance.defaults.baseURL = window.API_URL + "/orgbase/";
|
|
751
|
+
|
|
752
|
+
//#endregion
|
|
753
|
+
//#region src/api/orgbase/index.ts
|
|
754
|
+
function GetOrgName(request) {
|
|
755
|
+
return instance.post("getOrgName", request);
|
|
756
|
+
}
|
|
757
|
+
function PullPermission(request) {
|
|
758
|
+
return instance.post("pullPermission", request);
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
//#endregion
|
|
762
|
+
//#region src/composables/microApp.ts
|
|
763
|
+
function useMicroApp(globalStates, ignoreSyncOrg, onRouteChange, customBack) {
|
|
764
|
+
const route = useRoute();
|
|
765
|
+
const router = useRouter();
|
|
766
|
+
useGlobalStates(globalStates);
|
|
767
|
+
const { activeOrg, views } = globalStates;
|
|
768
|
+
async function syncOrg() {
|
|
769
|
+
const orgId = route.query.orgId;
|
|
770
|
+
if (!orgId) {
|
|
771
|
+
router.replace(`/main/${Date.now()}`);
|
|
772
|
+
return false;
|
|
773
|
+
}
|
|
774
|
+
if (orgId === "public") {
|
|
775
|
+
eventBus.emit("updateActiveOrg", [orgId, ""]);
|
|
776
|
+
eventBus.emit("updatePermission", [{}, ""]);
|
|
777
|
+
return true;
|
|
778
|
+
}
|
|
779
|
+
try {
|
|
780
|
+
const { name } = await GetOrgName({ orgId });
|
|
781
|
+
const { permissions } = await PullPermission({
|
|
782
|
+
orgId,
|
|
783
|
+
checksum: ""
|
|
784
|
+
});
|
|
785
|
+
eventBus.emit("updateActiveOrg", [orgId, name]);
|
|
786
|
+
eventBus.emit("updatePermission", [toPermissionObjects(permissions), permissions.checksum ?? ""]);
|
|
787
|
+
return true;
|
|
788
|
+
} catch (e) {
|
|
789
|
+
if (e === "org not found" || e === "org member not found") router.replace(`/main/${Date.now()}`);
|
|
790
|
+
return false;
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
async function fetch() {
|
|
794
|
+
if (!ignoreSyncOrg && !await syncOrg()) return;
|
|
795
|
+
await onRouteChange?.();
|
|
796
|
+
}
|
|
797
|
+
onBeforeMount(async () => {
|
|
798
|
+
await fetch();
|
|
799
|
+
});
|
|
800
|
+
onBeforeRouteUpdate(async () => {
|
|
801
|
+
await fetch();
|
|
802
|
+
});
|
|
803
|
+
async function handleBack() {
|
|
804
|
+
if (!isEmpty(views)) {
|
|
805
|
+
if (!hasView(views, "waitDlg")) popView(views);
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
const routeMeta = matchRouteMeta(route.path);
|
|
809
|
+
if (!routeMeta) return;
|
|
810
|
+
if (routeMeta.level === 0) navigator?.Backbutton?.goHome(() => {}, () => {});
|
|
811
|
+
else if (customBack) customBack(routeMeta);
|
|
812
|
+
else {
|
|
813
|
+
let back;
|
|
814
|
+
if (route.query.back) back = route.query.back;
|
|
815
|
+
else if (routeMeta.back) back = routeMeta.back;
|
|
816
|
+
if (back) router.replace({
|
|
817
|
+
path: back,
|
|
818
|
+
query: { orgId: activeOrg.value }
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
async function onKeyDown(e) {
|
|
823
|
+
if (e.key === "Escape") {
|
|
824
|
+
await handleBack();
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
onMounted(() => {
|
|
829
|
+
window.addEventListener("keydown", onKeyDown);
|
|
830
|
+
eventBus.on("back", handleBack);
|
|
831
|
+
});
|
|
832
|
+
onBeforeUnmount(() => {
|
|
833
|
+
window.removeEventListener("keydown", onKeyDown);
|
|
834
|
+
eventBus.off("back", handleBack);
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
|
|
932
838
|
//#endregion
|
|
933
839
|
//#region src/composables/permission.ts
|
|
934
840
|
function usePermission() {
|
|
@@ -1689,4 +1595,4 @@ async function loadLocaleMessageEssential(locale) {
|
|
|
1689
1595
|
var src_default = { install };
|
|
1690
1596
|
|
|
1691
1597
|
//#endregion
|
|
1692
|
-
export { Permission, addView, appAppear, clearViews, closeWaitDlg, createAxios, src_default as default, delView, eventBus, getTypeColor, getTypeDefault, globalObjects, hasView,
|
|
1598
|
+
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 };
|
|
@@ -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
|
-
|
|
580
|
+
60,
|
|
581
581
|
() => [],
|
|
582
582
|
[]
|
|
583
583
|
];
|
|
584
584
|
var Handler = [
|
|
585
|
-
|
|
585
|
+
61,
|
|
586
586
|
(T) => [T],
|
|
587
587
|
[
|
|
588
588
|
"",
|
|
@@ -591,7 +591,7 @@ var Handler = [
|
|
|
591
591
|
]
|
|
592
592
|
];
|
|
593
593
|
var WildcardHandler = [
|
|
594
|
-
|
|
594
|
+
62,
|
|
595
595
|
(T) => [
|
|
596
596
|
Record,
|
|
597
597
|
T,
|
|
@@ -609,7 +609,7 @@ var WildcardHandler = [
|
|
|
609
609
|
]
|
|
610
610
|
];
|
|
611
611
|
var EventHandlerList = [
|
|
612
|
-
|
|
612
|
+
63,
|
|
613
613
|
(T) => [
|
|
614
614
|
T,
|
|
615
615
|
Handler,
|
|
@@ -623,7 +623,7 @@ var EventHandlerList = [
|
|
|
623
623
|
]
|
|
624
624
|
];
|
|
625
625
|
var WildCardEventHandlerList = [
|
|
626
|
-
|
|
626
|
+
64,
|
|
627
627
|
(T) => [
|
|
628
628
|
Record,
|
|
629
629
|
T,
|
|
@@ -639,7 +639,7 @@ var WildCardEventHandlerList = [
|
|
|
639
639
|
]
|
|
640
640
|
];
|
|
641
641
|
var EventHandlerMap = [
|
|
642
|
-
|
|
642
|
+
65,
|
|
643
643
|
(Events) => [
|
|
644
644
|
EventType,
|
|
645
645
|
Record,
|
|
@@ -665,7 +665,7 @@ var EventHandlerMap = [
|
|
|
665
665
|
]
|
|
666
666
|
];
|
|
667
667
|
var Emitter = [
|
|
668
|
-
|
|
668
|
+
66,
|
|
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.
|
|
3
|
+
"version": "0.10.21",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist"
|
|
6
6
|
],
|
|
@@ -38,14 +38,15 @@
|
|
|
38
38
|
"mitt": "^3.0.1",
|
|
39
39
|
"oxfmt": "^0.55.0",
|
|
40
40
|
"oxlint": "^1.70.0",
|
|
41
|
+
"picomatch": "^4.0.5",
|
|
41
42
|
"rolldown": "^1.1.2",
|
|
42
43
|
"sass": "^1.101.0",
|
|
43
44
|
"tsdown": "^0.22.3",
|
|
44
45
|
"typescript": "^6.0.3",
|
|
45
46
|
"vite": "^8.0.16",
|
|
46
47
|
"x-config-lib": "^0.1.5",
|
|
47
|
-
"x-config-oxfmt": "^0.1.
|
|
48
|
-
"x-config-oxlint": "^0.1.
|
|
48
|
+
"x-config-oxfmt": "^0.1.5",
|
|
49
|
+
"x-config-oxlint": "^0.1.6"
|
|
49
50
|
},
|
|
50
51
|
"peerDependencies": {
|
|
51
52
|
"axios": "^1.18.0",
|
|
@@ -53,9 +54,5 @@
|
|
|
53
54
|
"vue-i18n": "^11.4.6",
|
|
54
55
|
"vue-router": "^5.1.0",
|
|
55
56
|
"vuetify": "^4.1.2"
|
|
56
|
-
},
|
|
57
|
-
"lint-staged": {
|
|
58
|
-
"*.{js,jsx,ts,tsx,vue}": "oxlint",
|
|
59
|
-
"*": "oxfmt --no-error-on-unmatched-pattern"
|
|
60
57
|
}
|
|
61
58
|
}
|