代码调整

This commit is contained in:
joylink_fanyuhong 2024-10-21 10:20:43 +08:00
parent 199e775f81
commit c77612e4dc

View File

@ -45,15 +45,18 @@ export default route(function (/* { store, ssrContext } */) {
next({ path: '/login' }); next({ path: '/login' });
} else { } else {
try { try {
const userInfo = await getUserInfo();
const userStore = useUserStore(); const userStore = useUserStore();
userStore.defaultRole = userInfo.defaultRole; if (!userStore.remainingSecond) {
userStore.roles = userInfo.roles; const userInfo = await getUserInfo();
userStore.remainingSecond = userInfo.remainingSecond; userStore.defaultRole = userInfo.defaultRole;
setTimeout( userStore.roles = userInfo.roles;
() => handleRefreshToken(), userStore.remainingSecond = userInfo.remainingSecond;
userInfo.remainingSecond * 1000 - 10000 setTimeout(
); () => handleRefreshToken(),
userInfo.remainingSecond * 1000 - 10000
);
}
next(); next();
} catch (e) { } catch (e) {
console.error('获取用户信息出错:', e); console.error('获取用户信息出错:', e);
@ -66,7 +69,7 @@ export default route(function (/* { store, ssrContext } */) {
return Router; return Router;
}); });
async function handleRefreshToken() { export async function handleRefreshToken() {
try { try {
const tokenInfo = await refreshToken(); const tokenInfo = await refreshToken();
saveJwtToken(tokenInfo.token); saveJwtToken(tokenInfo.token);