bugfix - token过期导致的登录异常

This commit is contained in:
Yuan 2023-06-12 14:39:42 +08:00
parent fe8fc9cf33
commit 916d89abf7
3 changed files with 7 additions and 1 deletions

View File

@ -7,3 +7,7 @@ export function saveJwtToken(token: string) {
export function getJwtToken(): string | null {
return sessionStorage.getItem(JwtTokenKey);
}
export function clearJwtToken(): void {
sessionStorage.removeItem(JwtTokenKey);
}

View File

@ -1,5 +1,6 @@
function getHost(): string {
// return '192.168.3.7:9081';
// return '192.168.3.47:9081';
return '192.168.3.233:9081';
}

View File

@ -55,7 +55,7 @@
import { useQuasar } from 'quasar';
import { ApiError } from 'src/boot/axios';
import { login } from 'src/api/UserApi';
import { saveJwtToken } from 'src/configs/TokenManage';
import { clearJwtToken, saveJwtToken } from 'src/configs/TokenManage';
import { reactive } from 'vue';
import { useRouter } from 'vue-router';
@ -69,6 +69,7 @@ const loginInfo = reactive({
async function doLogin() {
try {
clearJwtToken();
const token = await login(loginInfo);
saveJwtToken(token);
router.push({ name: 'home' });