feat: 修复了一点小bug

This commit is contained in:
Pan Qiancheng 2026-01-19 15:09:24 +08:00
parent 7312545eda
commit 8660c6a1e3
9 changed files with 20 additions and 20 deletions

View File

@ -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);

View File

@ -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: {

View File

@ -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) {

View File

@ -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);

View File

@ -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: {

View File

@ -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) {

View File

@ -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<ED extends EntityDict> extends Feature {
protected cache: Cache<ED>;
protected storage: LocalStorage;
protected application: Application<ED>;
protected ignoreExceptionList: typeof OakException<ED>[] = [OakNetworkException, OakServerProxyException, OakRequestTimeoutException, OakClockDriftException];
protected ignoreExceptionList: typeof OakException<ED>[] = [OakNetworkException, OakServerProxyException, OakRequestTimeoutException, OakClockDriftException, OakApplicationLoadingException];
protected async loadSavedToken() {
this.tokenValue = await this.storage.load(LOCAL_STORAGE_KEYS.token);

View File

@ -80,10 +80,10 @@ const triggers: Trigger<EntityDict, 'extraFile', BRC<EntityDict>>[] = [
});
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<EntityDict, 'extraFile', BRC<EntityDict>>[] = [
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'],

View File

@ -33,7 +33,7 @@ export function registerCosBackend<ED extends EntityDict>(clazz: new () => CosBa
}
export function getCosBackend<ED extends EntityDict>(origin: string) {
assert(CosBackendDict.hasOwnProperty(origin));
assert(CosBackendDict.hasOwnProperty(origin), `不存在类型为"${origin}"的CosBackend类`);
return CosBackendDict[origin] as CosBackend<ED>;
}