1
This commit is contained in:
+6
-23
@@ -155,38 +155,21 @@ export const saveProfileData = (profileData) => {
|
||||
|
||||
/**
|
||||
* 清理登录流程中的临时数据
|
||||
* @deprecated 使用 http/utils/auth-helper.js 中的 clearTempLoginData 替代
|
||||
*/
|
||||
export const clearTempLoginData = () => {
|
||||
// 清理临时数据,保留重要的用户信息
|
||||
uni.removeStorageSync(STORAGE_KEYS.WX_LOGIN_CODE)
|
||||
|
||||
console.log('清理临时登录数据')
|
||||
const { clearTempLoginData } = require('../http/utils/auth-helper.js')
|
||||
clearTempLoginData()
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查并验证token有效性
|
||||
* @returns {Promise<boolean>} token是否有效
|
||||
* @deprecated 使用 http/utils/auth-helper.js 中的 validateToken 替代
|
||||
*/
|
||||
export const validateToken = async () => {
|
||||
const token = uni.getStorageSync(STORAGE_KEYS.TOKEN)
|
||||
if (!token) {
|
||||
return false
|
||||
}
|
||||
|
||||
try {
|
||||
// 调用一个简单的API来验证token
|
||||
const { getUserInfo } = await import('@/http/api/profile.js')
|
||||
await getUserInfo({
|
||||
custom: {
|
||||
loading: false,
|
||||
toast: false
|
||||
}
|
||||
})
|
||||
return true
|
||||
} catch (error) {
|
||||
console.log('Token验证失败:', error)
|
||||
return false
|
||||
}
|
||||
const { validateToken } = await import('../http/utils/auth-helper.js')
|
||||
return await validateToken()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user