Skip to content

Commit 740e4c1

Browse files
author
tars-macmini
committed
fix: Update existing route index to prevent 404 on user switch
1 parent b148b8e commit 740e4c1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/effects/access/src/accessible.ts

+8
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ async function generateAccessible(
4444
// 根据router name判断,如果路由已经存在,则不再添加
4545
if (!names?.includes(route.name)) {
4646
root.children?.push(route);
47+
} else {
48+
// 找到已存在的路由索引并更新,不更新会造成切换用户时,一级目录未更新,homePath 在二级目录导致的404问题
49+
const index = root.children?.findIndex(
50+
(item) => item.name === route.name,
51+
);
52+
if (index !== undefined && index !== -1 && root.children) {
53+
root.children[index] = route;
54+
}
4755
}
4856
} else {
4957
router.addRoute(route);

0 commit comments

Comments
 (0)