Refactor login response handling and token management
This commit is contained in:
@ -211,8 +211,8 @@
|
|||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
const res = await login(loginForm)
|
const res = await login(loginForm)
|
||||||
const { code, data, msg } = res
|
const { code, data} = res
|
||||||
if (code !== 0) return ElMessage.error(msg)
|
if (code === 0) {
|
||||||
// 设置cookie
|
// 设置cookie
|
||||||
tokenCookie.value = data.accessToken;
|
tokenCookie.value = data.accessToken;
|
||||||
// 更新state
|
// 更新state
|
||||||
@ -229,6 +229,7 @@
|
|||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
userStore.getUserInfo()
|
userStore.getUserInfo()
|
||||||
// 登录成功
|
// 登录成功
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user