代码调整
This commit is contained in:
parent
199e775f81
commit
c77612e4dc
@ -45,15 +45,18 @@ export default route(function (/* { store, ssrContext } */) {
|
||||
next({ path: '/login' });
|
||||
} else {
|
||||
try {
|
||||
const userInfo = await getUserInfo();
|
||||
const userStore = useUserStore();
|
||||
userStore.defaultRole = userInfo.defaultRole;
|
||||
userStore.roles = userInfo.roles;
|
||||
userStore.remainingSecond = userInfo.remainingSecond;
|
||||
setTimeout(
|
||||
() => handleRefreshToken(),
|
||||
userInfo.remainingSecond * 1000 - 10000
|
||||
);
|
||||
if (!userStore.remainingSecond) {
|
||||
const userInfo = await getUserInfo();
|
||||
userStore.defaultRole = userInfo.defaultRole;
|
||||
userStore.roles = userInfo.roles;
|
||||
userStore.remainingSecond = userInfo.remainingSecond;
|
||||
setTimeout(
|
||||
() => handleRefreshToken(),
|
||||
userInfo.remainingSecond * 1000 - 10000
|
||||
);
|
||||
}
|
||||
|
||||
next();
|
||||
} catch (e) {
|
||||
console.error('获取用户信息出错:', e);
|
||||
@ -66,7 +69,7 @@ export default route(function (/* { store, ssrContext } */) {
|
||||
return Router;
|
||||
});
|
||||
|
||||
async function handleRefreshToken() {
|
||||
export async function handleRefreshToken() {
|
||||
try {
|
||||
const tokenInfo = await refreshToken();
|
||||
saveJwtToken(tokenInfo.token);
|
||||
|
Loading…
Reference in New Issue
Block a user