修复钉钉登录:修正响应数据格式处理,request拦截器已返回Result对象
This commit is contained in:
parent
d8a5191e3b
commit
344e8f26ee
@ -392,21 +392,23 @@ const handleDingTalkLogin = async () => {
|
||||
dingTalkLoginLoading.value = true
|
||||
try {
|
||||
// 获取钉钉登录URL
|
||||
// 注意:request 拦截器已经处理了 Result 包装,返回的就是 Result 对象
|
||||
const response = await request.get<Result<{ authUrl: string; appKey: string }>>('/dingtalk/oauth/login', {
|
||||
params: {
|
||||
redirectUrl: `${window.location.origin}/auth/dingtalk/callback`
|
||||
}
|
||||
})
|
||||
|
||||
if (response.data.code === 200 && response.data.data) {
|
||||
// response 已经是 Result 对象,直接使用 response.data
|
||||
if (response.code === 200 && response.data) {
|
||||
// 跳转到钉钉登录页面
|
||||
window.location.href = response.data.data.authUrl
|
||||
window.location.href = response.data.authUrl
|
||||
} else {
|
||||
message.error(response.data.message || '获取钉钉登录地址失败')
|
||||
message.error(response.message || '获取钉钉登录地址失败')
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('钉钉登录失败:', error)
|
||||
message.error(error.response?.data?.message || '钉钉登录失败,请稍后重试')
|
||||
message.error(error.response?.data?.message || error.message || '钉钉登录失败,请稍后重试')
|
||||
} finally {
|
||||
dingTalkLoginLoading.value = false
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user