fix 修复 重新登录无法跳转到过期前页面问题

This commit is contained in:
疯狂的狮子Li 2024-09-06 17:58:28 +08:00
parent 9f13c29cd7
commit 25848ea99e
2 changed files with 10 additions and 4 deletions

View File

@ -10,6 +10,7 @@ import FileSaver from 'file-saver';
import { getLanguage } from '@/lang'; import { getLanguage } from '@/lang';
import { encryptBase64, encryptWithAes, generateAesKey, decryptWithAes, decryptBase64 } from '@/utils/crypto'; import { encryptBase64, encryptWithAes, generateAesKey, decryptWithAes, decryptBase64 } from '@/utils/crypto';
import { encrypt, decrypt } from '@/utils/jsencrypt'; import { encrypt, decrypt } from '@/utils/jsencrypt';
import router from "@/router";
const encryptHeader = 'encrypt-key'; const encryptHeader = 'encrypt-key';
let downloadLoadingInstance: LoadingInstance; let downloadLoadingInstance: LoadingInstance;
@ -134,8 +135,13 @@ service.interceptors.response.use(
}).then(() => { }).then(() => {
isRelogin.show = false; isRelogin.show = false;
useUserStore().logout().then(() => { useUserStore().logout().then(() => {
location.href = import.meta.env.VITE_APP_CONTEXT_PATH + 'index'; router.replace({
}); path: '/login',
query: {
redirect: encodeURIComponent(router.currentRoute.value.fullPath || '/')
}
})
});
}).catch(() => { }).catch(() => {
isRelogin.show = false; isRelogin.show = false;
}); });

View File

@ -97,7 +97,7 @@ const tenantEnabled = ref(true);
// //
const register = ref(false); const register = ref(false);
const redirect = ref(undefined); const redirect = ref('');
const loginRef = ref<ElFormInstance>(); const loginRef = ref<ElFormInstance>();
// //
const tenantList = ref<TenantVO[]>([]); const tenantList = ref<TenantVO[]>([]);
@ -105,7 +105,7 @@ const tenantList = ref<TenantVO[]>([]);
watch( watch(
() => router.currentRoute.value, () => router.currentRoute.value,
(newRoute: any) => { (newRoute: any) => {
redirect.value = newRoute.query && newRoute.query.redirect; redirect.value = newRoute.query && decodeURIComponent(newRoute.query.redirect);
}, },
{ immediate: true } { immediate: true }
); );