x-essential-lib 0.10.15 → 0.10.17
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.js +45 -51
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -623,10 +623,7 @@ function onBeforeChange(toPath, fromPath, lastAppPath) {
|
|
|
623
623
|
if (fromPath === "/") fromPath = lastAppPath;
|
|
624
624
|
const toRouteMeta = matchRouteMeta(toPath);
|
|
625
625
|
const fromRouteMeta = matchRouteMeta(fromPath);
|
|
626
|
-
if (!toRouteMeta)
|
|
627
|
-
console.assert(false);
|
|
628
|
-
return;
|
|
629
|
-
}
|
|
626
|
+
if (!toRouteMeta) return;
|
|
630
627
|
console.info(`~~~~routeChange~~~~ ${fromPath} -> ${toPath}`);
|
|
631
628
|
if (!fromRouteMeta) return;
|
|
632
629
|
const sameApp = toRouteMeta.app === fromRouteMeta.app;
|
|
@@ -662,30 +659,27 @@ async function onBeforeEach(to, from, lastAppPath) {
|
|
|
662
659
|
const toRouteMeta = matchRouteMeta(to.path);
|
|
663
660
|
if (!toRouteMeta) return;
|
|
664
661
|
if (toRouteMeta.requireAuth && !hasAccessToken) return { path: `/passport/login` };
|
|
665
|
-
if (hasAccessToken && to.path.startsWith("/passport/")) return {
|
|
666
|
-
|
|
662
|
+
if (hasAccessToken && to.path.startsWith("/passport/")) return {
|
|
663
|
+
path: `/main/${Date.now()}`,
|
|
664
|
+
query: { orgId: "public" }
|
|
665
|
+
};
|
|
667
666
|
if (to.path.startsWith("/passport/")) onBeforeChange(to.path, from.path, lastAppPath);
|
|
668
|
-
else
|
|
667
|
+
else {
|
|
668
|
+
const orgId = to.query.orgId;
|
|
669
669
|
if (!orgId) return {
|
|
670
670
|
path: `/main/${Date.now()}`,
|
|
671
671
|
query: { orgId: "public" }
|
|
672
672
|
};
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
if (!orgId) throw new Error(`orgId not specified`);
|
|
684
|
-
await syncOrg(orgId);
|
|
685
|
-
await syncPermission(orgId);
|
|
686
|
-
onBeforeChange(to.path, from.path, lastAppPath);
|
|
687
|
-
} catch {
|
|
688
|
-
return { path: `/main` };
|
|
673
|
+
try {
|
|
674
|
+
await syncOrg(orgId);
|
|
675
|
+
await syncPermission(orgId);
|
|
676
|
+
onBeforeChange(to.path, from.path, lastAppPath);
|
|
677
|
+
} catch {
|
|
678
|
+
return {
|
|
679
|
+
path: `/main/${Date.now()}`,
|
|
680
|
+
query: { orgId: "public" }
|
|
681
|
+
};
|
|
682
|
+
}
|
|
689
683
|
}
|
|
690
684
|
}
|
|
691
685
|
|
|
@@ -828,34 +822,6 @@ function useMicroApp(globalStates, base, customBack) {
|
|
|
828
822
|
syncStatusBar();
|
|
829
823
|
}, { immediate: true });
|
|
830
824
|
}
|
|
831
|
-
async function handleBack() {
|
|
832
|
-
if (!isEmpty(views)) {
|
|
833
|
-
if (!hasView(views, "waitDlg")) popView(views);
|
|
834
|
-
return;
|
|
835
|
-
}
|
|
836
|
-
const routeMeta = matchRouteMeta(route.path);
|
|
837
|
-
if (!routeMeta) return;
|
|
838
|
-
if (routeMeta.level === 0) navigator?.Backbutton?.goHome(() => {}, () => {});
|
|
839
|
-
else if (customBack) customBack(routeMeta);
|
|
840
|
-
else if (routeMeta.back) await router.replace({
|
|
841
|
-
path: routeMeta.back,
|
|
842
|
-
query: { orgId: activeOrg.value }
|
|
843
|
-
});
|
|
844
|
-
}
|
|
845
|
-
async function onKeyDown(e) {
|
|
846
|
-
if (e.key === "Escape") {
|
|
847
|
-
await handleBack();
|
|
848
|
-
return;
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
if (base) {
|
|
852
|
-
onMounted(() => {
|
|
853
|
-
window.addEventListener("keydown", onKeyDown);
|
|
854
|
-
});
|
|
855
|
-
onBeforeUnmount(() => {
|
|
856
|
-
window.removeEventListener("keydown", onKeyDown);
|
|
857
|
-
});
|
|
858
|
-
}
|
|
859
825
|
let handle;
|
|
860
826
|
async function syncPermission() {
|
|
861
827
|
if (!running.value) return;
|
|
@@ -890,6 +856,34 @@ function useMicroApp(globalStates, base, customBack) {
|
|
|
890
856
|
stopTimer();
|
|
891
857
|
});
|
|
892
858
|
}
|
|
859
|
+
async function handleBack() {
|
|
860
|
+
if (!isEmpty(views)) {
|
|
861
|
+
if (!hasView(views, "waitDlg")) popView(views);
|
|
862
|
+
return;
|
|
863
|
+
}
|
|
864
|
+
const routeMeta = matchRouteMeta(route.path);
|
|
865
|
+
if (!routeMeta) return;
|
|
866
|
+
if (routeMeta.level === 0) navigator?.Backbutton?.goHome(() => {}, () => {});
|
|
867
|
+
else if (customBack) customBack(routeMeta);
|
|
868
|
+
else if (routeMeta.back) await router.replace({
|
|
869
|
+
path: routeMeta.back,
|
|
870
|
+
query: { orgId: activeOrg.value }
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
async function onKeyDown(e) {
|
|
874
|
+
if (e.key === "Escape") {
|
|
875
|
+
await handleBack();
|
|
876
|
+
return;
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
if (!base) {
|
|
880
|
+
onMounted(() => {
|
|
881
|
+
window.addEventListener("keydown", onKeyDown);
|
|
882
|
+
});
|
|
883
|
+
onBeforeUnmount(() => {
|
|
884
|
+
window.removeEventListener("keydown", onKeyDown);
|
|
885
|
+
});
|
|
886
|
+
}
|
|
893
887
|
function onUpdateDark(val) {
|
|
894
888
|
dark.value = val;
|
|
895
889
|
}
|