From aea953d60b88848df877b62bc253142c40f6005d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8C=83=E9=B9=8F?= Date: Mon, 24 Mar 2025 15:26:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dtoken=E5=A4=B1?= =?UTF-8?q?=E6=95=88=E6=97=B6=E6=9B=B4=E6=96=B0token=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common.js | 5 +++-- uni/request.js | 8 ++++---- web/request.js | 6 +++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/common.js b/common.js index 5cf6670..3de41d0 100644 --- a/common.js +++ b/common.js @@ -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) diff --git a/uni/request.js b/uni/request.js index f90c83b..3224c75 100644 --- a/uni/request.js +++ b/uni/request.js @@ -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)) diff --git a/web/request.js b/web/request.js index 7ac2c6d..ce9a2dd 100644 --- a/web/request.js +++ b/web/request.js @@ -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))