From 9ad45192fad4c9d8e3c9da0d607b210ea40f4734 Mon Sep 17 00:00:00 2001 From: Xc Date: Wed, 10 Apr 2024 18:52:11 +0800 Subject: [PATCH] =?UTF-8?q?composeFileUrl=E4=BF=AE=E6=94=B9=E4=BA=86?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- es/aspects/token.js | 2 +- es/utils/cos/index.d.ts | 3 +-- es/utils/cos/index.js | 4 ++-- lib/aspects/token.js | 2 +- lib/utils/cos/index.d.ts | 3 +-- lib/utils/cos/index.js | 4 ++-- src/aspects/token.ts | 2 +- src/utils/cos/index.ts | 8 ++++---- 8 files changed, 13 insertions(+), 15 deletions(-) diff --git a/es/aspects/token.js b/es/aspects/token.js index dd9ce4703..b376cb4e8 100644 --- a/es/aspects/token.js +++ b/es/aspects/token.js @@ -548,7 +548,7 @@ async function setUserInfoFromWechat(user, userInfo, context) { } if (avatar && (extraFile$entity?.length === 0 || - composeFileUrl(extraFile$entity[0], context) !== avatar)) { + composeFileUrl(extraFile$entity[0], application) !== avatar)) { // 需要更新新的avatar extra file const extraFileOperations = [ { diff --git a/es/utils/cos/index.d.ts b/es/utils/cos/index.d.ts index 52e03ffb9..a1e2b0a23 100644 --- a/es/utils/cos/index.d.ts +++ b/es/utils/cos/index.d.ts @@ -1,4 +1,3 @@ -import { BRC, FRC } from '../../types/RuntimeCxt'; import { EntityDict } from '../../oak-app-domain'; import Cos from '../../types/Cos'; /** @@ -7,4 +6,4 @@ import Cos from '../../types/Cos'; */ export declare function registerCos(clazz: new () => Cos): void; export declare function getCos(origin: string): Cos; -export declare function composeFileUrl(extraFile: ED['extraFile']['OpSchema'], context: BRC | FRC, style?: string): any; +export declare function composeFileUrl(extraFile: ED['extraFile']['OpSchema'], application: ED['application']['Schema'], style?: string): string; diff --git a/es/utils/cos/index.js b/es/utils/cos/index.js index 2c3e2e6ef..91a725be5 100644 --- a/es/utils/cos/index.js +++ b/es/utils/cos/index.js @@ -22,8 +22,8 @@ export function getCos(origin) { assert(CosDict.hasOwnProperty(origin)); return CosDict[origin]; } -export function composeFileUrl(extraFile, context, style) { +export function composeFileUrl(extraFile, application, style) { const { origin } = extraFile; const cos = CosDict[origin]; - return cos.composeFileUrl(extraFile, context, style); + return cos.composeFileUrl(extraFile, application, style); } diff --git a/lib/aspects/token.js b/lib/aspects/token.js index e5ee13a5f..3ad8a833e 100644 --- a/lib/aspects/token.js +++ b/lib/aspects/token.js @@ -553,7 +553,7 @@ async function setUserInfoFromWechat(user, userInfo, context) { } if (avatar && (extraFile$entity?.length === 0 || - (0, cos_1.composeFileUrl)(extraFile$entity[0], context) !== avatar)) { + (0, cos_1.composeFileUrl)(extraFile$entity[0], application) !== avatar)) { // 需要更新新的avatar extra file const extraFileOperations = [ { diff --git a/lib/utils/cos/index.d.ts b/lib/utils/cos/index.d.ts index 52e03ffb9..a1e2b0a23 100644 --- a/lib/utils/cos/index.d.ts +++ b/lib/utils/cos/index.d.ts @@ -1,4 +1,3 @@ -import { BRC, FRC } from '../../types/RuntimeCxt'; import { EntityDict } from '../../oak-app-domain'; import Cos from '../../types/Cos'; /** @@ -7,4 +6,4 @@ import Cos from '../../types/Cos'; */ export declare function registerCos(clazz: new () => Cos): void; export declare function getCos(origin: string): Cos; -export declare function composeFileUrl(extraFile: ED['extraFile']['OpSchema'], context: BRC | FRC, style?: string): any; +export declare function composeFileUrl(extraFile: ED['extraFile']['OpSchema'], application: ED['application']['Schema'], style?: string): string; diff --git a/lib/utils/cos/index.js b/lib/utils/cos/index.js index 6d8cfebec..1bcb9ab3b 100644 --- a/lib/utils/cos/index.js +++ b/lib/utils/cos/index.js @@ -28,9 +28,9 @@ function getCos(origin) { return CosDict[origin]; } exports.getCos = getCos; -function composeFileUrl(extraFile, context, style) { +function composeFileUrl(extraFile, application, style) { const { origin } = extraFile; const cos = CosDict[origin]; - return cos.composeFileUrl(extraFile, context, style); + return cos.composeFileUrl(extraFile, application, style); } exports.composeFileUrl = composeFileUrl; diff --git a/src/aspects/token.ts b/src/aspects/token.ts index ec46a5817..890442f6a 100644 --- a/src/aspects/token.ts +++ b/src/aspects/token.ts @@ -744,7 +744,7 @@ async function setUserInfoFromWechat( if ( avatar && (extraFile$entity?.length === 0 || - composeFileUrl(extraFile$entity![0], context) !== avatar) + composeFileUrl(extraFile$entity![0], application as ED['application']['Schema']) !== avatar) ) { // 需要更新新的avatar extra file const extraFileOperations: ExtraFileOperation['data'][] = [ diff --git a/src/utils/cos/index.ts b/src/utils/cos/index.ts index 58e25e766..a7eaa930d 100644 --- a/src/utils/cos/index.ts +++ b/src/utils/cos/index.ts @@ -11,7 +11,7 @@ const ctyun = new CTYun(); const qiniu = new Qiniu(); const wechat = new Wechat(); -const CosDict: Record = { +const CosDict: Record> = { [qiniu.name]: qiniu, [wechat.name]: wechat, [ctyun.name]: ctyun, @@ -23,7 +23,7 @@ const CosDict: Record = { */ export function registerCos(clazz: new () => Cos) { const instance = new clazz(); - CosDict[instance.name] = instance; + CosDict[instance.name] = instance as Cos; } export function getCos(origin: string) { @@ -33,10 +33,10 @@ export function getCos(origin: string) { export function composeFileUrl( extraFile: ED['extraFile']['OpSchema'], - context: BRC | FRC, + application: ED['application']['Schema'], style?: string ) { const { origin } = extraFile; const cos = CosDict[origin]; - return cos.composeFileUrl(extraFile, context as any, style); + return cos.composeFileUrl(extraFile, application, style); }