Skip to content

Commit

Permalink
fix: set default route (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
heyanlong authored Dec 26, 2023
1 parent 001fa25 commit c5d80d9
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,23 @@ router.beforeEach((to, from, next) => {
}

if (to.path === "/") {
const defaultPath = (routesLayers[0] && routesLayers[0].children[0].path) || "";
let defaultPath = "";
for (const route of routesLayers) {
for (const child of route.children) {
if (child.meta.activate) {
defaultPath = child.path;
break;
}
}
if (defaultPath) {
break;
}
}

if (!defaultPath) {
defaultPath = "/marketplace";
}

next({ path: defaultPath });
} else {
next();
Expand Down

0 comments on commit c5d80d9

Please sign in to comment.