fix:修复登录菜单不刷新问题
This commit is contained in:
@@ -46,7 +46,9 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
|
|||||||
const authRoutes = shallowRef<ElegantConstRoute[]>([]);
|
const authRoutes = shallowRef<ElegantConstRoute[]>([]);
|
||||||
|
|
||||||
function addAuthRoutes(routes: ElegantConstRoute[]) {
|
function addAuthRoutes(routes: ElegantConstRoute[]) {
|
||||||
const authRoutesMap = new Map(authRoutes.value.map(route => [route.name, route]));
|
const {constantRoutes} = createStaticRoutes();
|
||||||
|
|
||||||
|
const authRoutesMap = new Map(constantRoutes.map(route => [route.name, route]));
|
||||||
|
|
||||||
routes.forEach(route => {
|
routes.forEach(route => {
|
||||||
authRoutesMap.set(route.name, route);
|
authRoutesMap.set(route.name, route);
|
||||||
@@ -160,7 +162,7 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
|
|||||||
|
|
||||||
const {data: routes, error} = await doGetUserRoutes();
|
const {data: routes, error} = await doGetUserRoutes();
|
||||||
if (!error) {
|
if (!error) {
|
||||||
const {authRoutes: staticAuthRoutes} = createStaticRoutes();
|
const {authRoutes: staticAuthRoutes} = createStaticRoutes();
|
||||||
const filteredAuthRoutes = filterAuthRoutesByRoles(staticAuthRoutes, authStore.userInfo.roles ?? []);
|
const filteredAuthRoutes = filterAuthRoutesByRoles(staticAuthRoutes, authStore.userInfo.roles ?? []);
|
||||||
addAuthRoutes(filteredAuthRoutes.concat(routes));
|
addAuthRoutes(filteredAuthRoutes.concat(routes));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user