From 06322f39c6b7539fa791e06b7dd528b4d3b28e56 Mon Sep 17 00:00:00 2001 From: wkj <278599135@.com> Date: Mon, 29 Apr 2024 16:14:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20token=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E6=97=B6=20=E9=A1=B5=E9=9D=A2=E4=B8=80=E7=9B=B4=E6=98=BE?= =?UTF-8?q?=E7=A4=BAloading=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- es/aspects/token.js | 5 +++++ es/features/token.js | 9 ++++----- lib/aspects/token.js | 5 +++++ lib/features/token.js | 6 +++--- package.json | 2 +- src/aspects/token.ts | 5 +++++ src/features/token.ts | 6 +++--- 7 files changed, 26 insertions(+), 12 deletions(-) diff --git a/es/aspects/token.js b/es/aspects/token.js index 4227ff02c..efa232f14 100644 --- a/es/aspects/token.js +++ b/es/aspects/token.js @@ -1351,6 +1351,11 @@ export async function refreshToken(params, context) { assert(token); const now = Date.now(); if (!checkTokenEnvConsistency(env, token.env)) { + console.log('####### refreshToken环境改变 start #######\n'); + console.log(env); + console.log('---------------------\n'); + console.log(token.env); + console.log('####### refreshToken环境改变 end #######\n'); await context.operate('token', { id: await generateNewIdAsync(), action: 'disable', diff --git a/es/features/token.js b/es/features/token.js index b40eb50d1..c1e8c74f7 100644 --- a/es/features/token.js +++ b/es/features/token.js @@ -10,8 +10,8 @@ export class Token extends Feature { cache; storage; async loadSavedToken() { - let tokenValue = await this.storage.load(LOCAL_STORAGE_KEYS.token); - await this.refreshTokenData(tokenValue); + this.tokenValue = await this.storage.load(LOCAL_STORAGE_KEYS.token); + await this.refreshTokenData(this.tokenValue); this.publish(); } constructor(cache, storage, environment) { @@ -46,13 +46,12 @@ export class Token extends Feature { tokenValue, env, }, undefined, true, true); - if (this.tokenValue !== result) { + if (tokenValue !== result) { // 如果返回空字符串,token被disabled,tokenValue置为undefined if (result) { this.tokenValue = result; await this.storage.save(LOCAL_STORAGE_KEYS.token, result); - } - else { + } else { this.removeToken(true); } } diff --git a/lib/aspects/token.js b/lib/aspects/token.js index a81c685d7..32aa6ee78 100644 --- a/lib/aspects/token.js +++ b/lib/aspects/token.js @@ -1366,6 +1366,11 @@ async function refreshToken(params, context) { (0, assert_1.assert)(token); const now = Date.now(); if (!checkTokenEnvConsistency(env, token.env)) { + console.log('####### refreshToken环境改变 start #######\n'); + console.log(env); + console.log('---------------------\n'); + console.log(token.env); + console.log('####### refreshToken环境改变 end #######\n'); await context.operate('token', { id: await (0, uuid_1.generateNewIdAsync)(), action: 'disable', diff --git a/lib/features/token.js b/lib/features/token.js index c3c2aa850..c23b71383 100644 --- a/lib/features/token.js +++ b/lib/features/token.js @@ -13,8 +13,8 @@ class Token extends Feature_1.Feature { cache; storage; async loadSavedToken() { - let tokenValue = await this.storage.load(constants_1.LOCAL_STORAGE_KEYS.token); - await this.refreshTokenData(tokenValue); + this.tokenValue = await this.storage.load(constants_1.LOCAL_STORAGE_KEYS.token); + await this.refreshTokenData(this.tokenValue); this.publish(); } constructor(cache, storage, environment) { @@ -49,7 +49,7 @@ class Token extends Feature_1.Feature { tokenValue, env, }, undefined, true, true); - if (this.tokenValue !== result) { + if (tokenValue !== result) { // 如果返回空字符串,token被disabled,tokenValue置为undefined if (result) { this.tokenValue = result; diff --git a/package.json b/package.json index 41dd0c955..62da5c483 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "antd-mobile-icons": ">=0.3.0", "react": ">=18.2.0", "react-dom": ">=18.1.0", - "react-native": "^0.72.7", + "react-native": ">=0.72.7", "react-router-dom": ">=6.3.0" }, "devDependencies": { diff --git a/src/aspects/token.ts b/src/aspects/token.ts index fa55810bb..126780386 100644 --- a/src/aspects/token.ts +++ b/src/aspects/token.ts @@ -1861,6 +1861,11 @@ export async function refreshToken( assert(token); const now = Date.now(); if (!checkTokenEnvConsistency(env, token.env as WebEnv)) { + console.log('####### refreshToken 环境改变 start #######\n'); + console.log(env); + console.log('---------------------\n'); + console.log(token.env); + console.log('####### refreshToken 环境改变 end #######\n'); await context.operate('token', { id: await generateNewIdAsync(), action: 'disable', diff --git a/src/features/token.ts b/src/features/token.ts index b0abce1fc..2dbf7daeb 100644 --- a/src/features/token.ts +++ b/src/features/token.ts @@ -23,8 +23,8 @@ export class Token extends Feature { private storage: LocalStorage; private async loadSavedToken() { - let tokenValue = await this.storage.load(LOCAL_STORAGE_KEYS.token); - await this.refreshTokenData(tokenValue); + this.tokenValue = await this.storage.load(LOCAL_STORAGE_KEYS.token); + await this.refreshTokenData(this.tokenValue); this.publish(); } @@ -73,7 +73,7 @@ export class Token extends Feature { true, true ); - if (this.tokenValue !== result) { + if (tokenValue !== result) { // 如果返回空字符串,token被disabled,tokenValue置为undefined if (result) { this.tokenValue = result;