fix: 修复token失效时更新token的bug

This commit is contained in:
范鹏 2025-03-24 15:26:37 +08:00
parent 9ddbc35238
commit aea953d60b
3 changed files with 10 additions and 9 deletions

View File

@ -250,9 +250,10 @@ export async function cleanLockUser() {
/**
* 登录星云
* @param {Number} [uid] 用户ID
* @param {Boolean} [force] 是否强制更新
* @returns Result
*/
export async function login(uid) {
export async function login(uid, force = false) {
let accounts = getStorage('starCloudAccount')
let userInfos = getStorage('starCloudUser')
if (!accounts) {
@ -266,7 +267,7 @@ export async function login(uid) {
this.accountInfo = accounts[id]
if (this.accountInfo) {
if (this.accountInfo.token) {
if (this.accountInfo.token && !force) {
this.userInfo = userInfos[id]
setStorage('starCloudToken', this.accountInfo.token)

View File

@ -24,7 +24,7 @@ const request = config => {
// 默认请求头
const headerDefault = {
version: baseConfig.version + '+' + baseConfig.buildNumber
version: baseConfig.version
}
const header = {
...headerDefault,
@ -61,9 +61,9 @@ const request = config => {
removeStorage('starCloudToken')
removeStorage('starCloudUser')
const { code } = await starCloud.login({
username: starCloud.starCloudAccountInfo.username,
password: starCloud.starCloudAccountInfo.password,
uid: starCloud.starCloudAccountInfo.uid
username: starCloud.accountInfo.username,
password: starCloud.accountInfo.password,
uid: starCloud.accountInfo.uid
})
if (code === Result.Success.code) {
resolve(await request(config))

View File

@ -81,9 +81,9 @@ const request = (config) => {
removeStorage('starCloudToken')
removeStorage('starCloudUser')
const loginResult = await starCloud.login({
username: starCloud.starCloudAccountInfo.username,
password: starCloud.starCloudAccountInfo.password,
uid: starCloud.starCloudAccountInfo.uid
username: starCloud.accountInfo.username,
password: starCloud.accountInfo.password,
uid: starCloud.accountInfo.uid
})
if (loginResult.code === Result.Success.code) {
return resolve(await request(config))