Commit dec0d391 authored by shenshaokai's avatar shenshaokai

fix: 登录后菜单权限问题

parent 4d498995
......@@ -100,7 +100,7 @@ export function patchRoutes({ routes }: IRoutes) {
export async function render(oldRender: Function) {
const { pathname } = history.location
if(pathname === '/') {
if (pathname === '/') {
history.replace(defaultHomePath())
}
// 白名单页面不进行权限校验
......@@ -110,9 +110,8 @@ export async function render(oldRender: Function) {
}
const authInfo = getAuth()
if (authInfo) {
getMemberLoginReget({}, { useCache: true, ttl: 1000 }).then(res => {
const { data, code } = res
console.log("getMemberLoginReget---->",res)
try {
const { data, code } = await getMemberLoginReget({}, { useCache: true, ttl: 1000 })
if (code === 1000) {
setAuth(data as any)
setRouters(data.auth)
......@@ -122,7 +121,13 @@ export async function render(oldRender: Function) {
history.replace('/user/login')
SpaLogin()
}
})
} catch (error) {
removeAuth()
removeRouters()
history.replace('/user/login')
SpaLogin()
}
// const resReget = await getMemberLoginReget({}, { useCache: true, ttl: 1000 })
// if (resReget.code === 1000) {
// setAuth(resReget.data as any)
......@@ -159,14 +164,14 @@ export async function render(oldRender: Function) {
// @description 获取权限列表 实时控制菜单访问权限
const resAuth: any = getResAuth || await getMemberAuthList({})
sessionStorage.setItem('ls-auth', JSON.stringify(resAuth))
if(resAuth.code === 1000) {
if (resAuth.code === 1000) {
realTimeAuthLists = resAuth.data
oldRender()
} else {
removeLogin()
return message.error(resAuth.message)
}
} catch(err) {
} catch (err) {
console.log(err)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment