x-essential-lib 0.10.14 → 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 +18 -21
  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,27 +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 {
669
- if (!orgId) throw new Error(`orgId not specified`);
670
- await syncOrg(orgId);
671
- await syncPermission(orgId);
672
- onBeforeChange(to.path, from.path, lastAppPath);
673
- } catch {
674
- return {
667
+ else {
668
+ const orgId = to.query.orgId;
669
+ if (!orgId) return {
675
670
  path: `/main/${Date.now()}`,
676
671
  query: { orgId: "public" }
677
672
  };
678
- }
679
- else try {
680
- if (!orgId) throw new Error(`orgId not specified`);
681
- await syncOrg(orgId);
682
- await syncPermission(orgId);
683
- onBeforeChange(to.path, from.path, lastAppPath);
684
- } catch {
685
- 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
+ }
686
683
  }
687
684
  }
688
685
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x-essential-lib",
3
- "version": "0.10.14",
3
+ "version": "0.10.16",
4
4
  "files": [
5
5
  "dist"
6
6
  ],