x-essential-lib 0.10.15 → 0.10.16

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.
Files changed (2) hide show
  1. package/dist/index.js +17 -23
  2. 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 { path: `/main` };
666
- const orgId = to.query.orgId;
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 if (to.path.startsWith("/main")) try {
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
- await syncOrg(orgId);
674
- await syncPermission(orgId);
675
- onBeforeChange(to.path, from.path, lastAppPath);
676
- } catch {
677
- return {
678
- path: `/main/${Date.now()}`,
679
- query: { orgId: "public" }
680
- };
681
- }
682
- else try {
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x-essential-lib",
3
- "version": "0.10.15",
3
+ "version": "0.10.16",
4
4
  "files": [
5
5
  "dist"
6
6
  ],