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