From 8660c6a1e3a4baad80d5677a8cf8a2c534116733 Mon Sep 17 00:00:00 2001 From: qcqcqc <1220204124@zust.edu.cn> Date: Mon, 19 Jan 2026 15:09:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8D=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E7=82=B9=E5=B0=8Fbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- es/features/token.js | 4 ++-- es/triggers/extraFile.js | 8 ++++---- es/utils/cos/index.backend.js | 2 +- lib/features/token.js | 2 +- lib/triggers/extraFile.js | 8 ++++---- lib/utils/cos/index.backend.js | 2 +- src/features/token.ts | 4 ++-- src/triggers/extraFile.ts | 8 ++++---- src/utils/cos/index.backend.ts | 2 +- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/es/features/token.js b/es/features/token.js index 07cf5c88b..2011f9913 100644 --- a/es/features/token.js +++ b/es/features/token.js @@ -1,7 +1,7 @@ import { Feature } from 'oak-frontend-base/es/types/Feature'; import { isOakException, OakUnloggedInException, OakNetworkException, OakServerProxyException, OakPreConditionUnsetException, OakRequestTimeoutException, OakClockDriftException } from 'oak-domain/lib/types/Exception'; import { tokenProjection } from '../types/Projection'; -import { OakPasswordUnset, OakUserInfoLoadingException } from '../types/Exception'; +import { OakApplicationLoadingException, OakPasswordUnset, OakUserInfoLoadingException } from '../types/Exception'; import { LOCAL_STORAGE_KEYS } from '../config/constants'; import { cloneDeep } from 'oak-domain/lib/utils/lodash'; export class Token extends Feature { @@ -10,7 +10,7 @@ export class Token extends Feature { cache; storage; application; - ignoreExceptionList = [OakNetworkException, OakServerProxyException, OakRequestTimeoutException, OakClockDriftException]; + ignoreExceptionList = [OakNetworkException, OakServerProxyException, OakRequestTimeoutException, OakClockDriftException, OakApplicationLoadingException]; async loadSavedToken() { this.tokenValue = await this.storage.load(LOCAL_STORAGE_KEYS.token); await this.refreshTokenData(this.tokenValue); diff --git a/es/triggers/extraFile.js b/es/triggers/extraFile.js index e9a9a2dfa..0f75cccaa 100644 --- a/es/triggers/extraFile.js +++ b/es/triggers/extraFile.js @@ -63,10 +63,10 @@ const triggers = [ }); return; } - const cos = getCosBackend(configOrigin); - if (!cos) { + if (!configOrigin) { throw new OakException(`origin为${configOrigin}的extraFile没有定义Cos类,请调用registerCos注入`); } + const cos = getCosBackend(configOrigin); await cos.formUploadMeta(context.getApplication(), data, context); Object.assign(data, { uploadState: 'uploading', @@ -105,10 +105,10 @@ const triggers = [ // 计算partCount 是否正确 const expectedPartCount = Math.ceil(data.size / data.chunkInfo.chunkSize); assert(data.chunkInfo.partCount === expectedPartCount, `chunkInfo.partCount计算错误,预期值为${expectedPartCount},但实际值为${data.chunkInfo.partCount}`); - const cos = getCosBackend(data.origin); - if (!cos) { + if (!data.origin) { throw new OakException(`origin为${data.origin}的extraFile没有定义Cos类,请调用registerCos注入`); } + const cos = getCosBackend(data.origin); const infos = await cos.prepareChunkedUpload(context.getApplication(), data, context); Object.assign(data, { chunkInfo: { diff --git a/es/utils/cos/index.backend.js b/es/utils/cos/index.backend.js index 75984f32a..c7dde5e07 100644 --- a/es/utils/cos/index.backend.js +++ b/es/utils/cos/index.backend.js @@ -24,7 +24,7 @@ export function registerCosBackend(clazz) { CosBackendDict[instance.name] = instance; } export function getCosBackend(origin) { - assert(CosBackendDict.hasOwnProperty(origin)); + assert(CosBackendDict.hasOwnProperty(origin), `不存在类型为"${origin}"的CosBackend类`); return CosBackendDict[origin]; } export async function composeFileUrlBackend(application, extraFile, context, style) { diff --git a/lib/features/token.js b/lib/features/token.js index bc30633d4..20ec1f559 100644 --- a/lib/features/token.js +++ b/lib/features/token.js @@ -13,7 +13,7 @@ class Token extends Feature_1.Feature { cache; storage; application; - ignoreExceptionList = [Exception_1.OakNetworkException, Exception_1.OakServerProxyException, Exception_1.OakRequestTimeoutException, Exception_1.OakClockDriftException]; + ignoreExceptionList = [Exception_1.OakNetworkException, Exception_1.OakServerProxyException, Exception_1.OakRequestTimeoutException, Exception_1.OakClockDriftException, Exception_2.OakApplicationLoadingException]; async loadSavedToken() { this.tokenValue = await this.storage.load(constants_1.LOCAL_STORAGE_KEYS.token); await this.refreshTokenData(this.tokenValue); diff --git a/lib/triggers/extraFile.js b/lib/triggers/extraFile.js index def7f0cda..b7311fe93 100644 --- a/lib/triggers/extraFile.js +++ b/lib/triggers/extraFile.js @@ -66,10 +66,10 @@ const triggers = [ }); return; } - const cos = (0, index_backend_1.getCosBackend)(configOrigin); - if (!cos) { + if (!configOrigin) { throw new Exception_1.OakException(`origin为${configOrigin}的extraFile没有定义Cos类,请调用registerCos注入`); } + const cos = (0, index_backend_1.getCosBackend)(configOrigin); await cos.formUploadMeta(context.getApplication(), data, context); Object.assign(data, { uploadState: 'uploading', @@ -108,10 +108,10 @@ const triggers = [ // 计算partCount 是否正确 const expectedPartCount = Math.ceil(data.size / data.chunkInfo.chunkSize); (0, assert_1.default)(data.chunkInfo.partCount === expectedPartCount, `chunkInfo.partCount计算错误,预期值为${expectedPartCount},但实际值为${data.chunkInfo.partCount}`); - const cos = (0, index_backend_1.getCosBackend)(data.origin); - if (!cos) { + if (!data.origin) { throw new Exception_1.OakException(`origin为${data.origin}的extraFile没有定义Cos类,请调用registerCos注入`); } + const cos = (0, index_backend_1.getCosBackend)(data.origin); const infos = await cos.prepareChunkedUpload(context.getApplication(), data, context); Object.assign(data, { chunkInfo: { diff --git a/lib/utils/cos/index.backend.js b/lib/utils/cos/index.backend.js index dda8157e6..c25809402 100644 --- a/lib/utils/cos/index.backend.js +++ b/lib/utils/cos/index.backend.js @@ -30,7 +30,7 @@ function registerCosBackend(clazz) { CosBackendDict[instance.name] = instance; } function getCosBackend(origin) { - (0, assert_1.assert)(CosBackendDict.hasOwnProperty(origin)); + (0, assert_1.assert)(CosBackendDict.hasOwnProperty(origin), `不存在类型为"${origin}"的CosBackend类`); return CosBackendDict[origin]; } async function composeFileUrlBackend(application, extraFile, context, style) { diff --git a/src/features/token.ts b/src/features/token.ts index 0a34ea718..495ee36b5 100644 --- a/src/features/token.ts +++ b/src/features/token.ts @@ -16,7 +16,7 @@ import { Application } from './application'; import { WebEnv, WechatMpEnv, NativeEnv } from 'oak-domain/lib/types/Environment'; import { EntityDict } from '../oak-app-domain'; import { tokenProjection } from '../types/Projection'; -import { OakPasswordUnset, OakUserInfoLoadingException } from '../types/Exception'; +import { OakApplicationLoadingException, OakPasswordUnset, OakUserInfoLoadingException } from '../types/Exception'; import { LOCAL_STORAGE_KEYS } from '../config/constants'; import { cloneDeep } from 'oak-domain/lib/utils/lodash'; @@ -26,7 +26,7 @@ export class Token extends Feature { protected cache: Cache; protected storage: LocalStorage; protected application: Application; - protected ignoreExceptionList: typeof OakException[] = [OakNetworkException, OakServerProxyException, OakRequestTimeoutException, OakClockDriftException]; + protected ignoreExceptionList: typeof OakException[] = [OakNetworkException, OakServerProxyException, OakRequestTimeoutException, OakClockDriftException, OakApplicationLoadingException]; protected async loadSavedToken() { this.tokenValue = await this.storage.load(LOCAL_STORAGE_KEYS.token); diff --git a/src/triggers/extraFile.ts b/src/triggers/extraFile.ts index f3c87cde5..c0dfdec30 100644 --- a/src/triggers/extraFile.ts +++ b/src/triggers/extraFile.ts @@ -80,10 +80,10 @@ const triggers: Trigger>[] = [ }); return; } - const cos = getCosBackend(configOrigin!); - if (!cos) { + if (!configOrigin) { throw new OakException(`origin为${configOrigin}的extraFile没有定义Cos类,请调用registerCos注入`); } + const cos = getCosBackend(configOrigin!); await cos.formUploadMeta(context.getApplication() as EntityDict['application']['Schema'], data, context); Object.assign(data, { uploadState: 'uploading', @@ -128,10 +128,10 @@ const triggers: Trigger>[] = [ const expectedPartCount = Math.ceil(data.size! / data.chunkInfo!.chunkSize); assert(data.chunkInfo!.partCount === expectedPartCount, `chunkInfo.partCount计算错误,预期值为${expectedPartCount},但实际值为${data.chunkInfo!.partCount}`); - const cos = getCosBackend(data.origin!) - if (!cos) { + if (!data.origin) { throw new OakException(`origin为${data.origin}的extraFile没有定义Cos类,请调用registerCos注入`); } + const cos = getCosBackend(data.origin!) const infos = await cos.prepareChunkedUpload( context.getApplication() as EntityDict['application']['Schema'], diff --git a/src/utils/cos/index.backend.ts b/src/utils/cos/index.backend.ts index d057e003b..3d900219b 100644 --- a/src/utils/cos/index.backend.ts +++ b/src/utils/cos/index.backend.ts @@ -33,7 +33,7 @@ export function registerCosBackend(clazz: new () => CosBa } export function getCosBackend(origin: string) { - assert(CosBackendDict.hasOwnProperty(origin)); + assert(CosBackendDict.hasOwnProperty(origin), `不存在类型为"${origin}"的CosBackend类`); return CosBackendDict[origin] as CosBackend; }