fix: login landing from menu_access, silent optional Layout 403
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -4,7 +4,8 @@ import request from '@/utils/request'
|
||||
import {
|
||||
ensureMenuAccess,
|
||||
getMenuAccess,
|
||||
getFirstVisiblePath,
|
||||
getDefaultLandingPath,
|
||||
getEffectiveVisiblePaths,
|
||||
isMenuSessionFresh,
|
||||
JITUAN_API,
|
||||
} from '@/utils/club-context'
|
||||
@@ -17,10 +18,13 @@ const routes = [
|
||||
{
|
||||
path: '/',
|
||||
component: Layout,
|
||||
redirect: () => getFirstVisiblePath() || '/order/platform',
|
||||
redirect: () => getDefaultLandingPath() || '/welcome',
|
||||
children: [
|
||||
|
||||
|
||||
{
|
||||
path: 'welcome',
|
||||
component: () => import('@/views/Welcome.vue'),
|
||||
meta: { title: '首页' }
|
||||
},
|
||||
// ========== 板块与财务 ==========
|
||||
{
|
||||
path: 'finance/bankuai',
|
||||
@@ -352,18 +356,31 @@ router.beforeEach(async (to, from, next) => {
|
||||
}
|
||||
|
||||
const access = getMenuAccess()
|
||||
if (!isMenuSessionFresh() || !access?.visible_paths?.length) {
|
||||
|
||||
if (!isMenuSessionFresh()) {
|
||||
next()
|
||||
return
|
||||
}
|
||||
|
||||
if (to.path === '/welcome') {
|
||||
next()
|
||||
return
|
||||
}
|
||||
|
||||
if (!getEffectiveVisiblePaths(access).length) {
|
||||
if (to.path !== '/welcome') {
|
||||
next('/welcome')
|
||||
return
|
||||
}
|
||||
next()
|
||||
return
|
||||
}
|
||||
|
||||
const path = to.path
|
||||
if (!isRouteAllowed(path, access.visible_paths)) {
|
||||
const fallback = getFirstVisiblePath()
|
||||
if (fallback && path !== fallback) {
|
||||
next(fallback)
|
||||
return
|
||||
}
|
||||
if (!isRouteAllowed(path, getEffectiveVisiblePaths(access))) {
|
||||
const fallback = getDefaultLandingPath(access) || '/welcome'
|
||||
next(fallback)
|
||||
return
|
||||
}
|
||||
next()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user