diff --git a/libs/Universal-PicGo-Core/src/plugins/uploader/awss3.ts b/libs/Universal-PicGo-Core/src/plugins/uploader/awss3.ts index b2a7e87..863ccb6 100644 --- a/libs/Universal-PicGo-Core/src/plugins/uploader/awss3.ts +++ b/libs/Universal-PicGo-Core/src/plugins/uploader/awss3.ts @@ -3,6 +3,7 @@ import { formatPath } from "./s3/utils" import { IAwsS3Config, IPicGo, IPluginConfig } from "../../types" import { ILocalesKey } from "../../i18n/zh-CN" import { IBuildInEvent } from "../../utils/enums" +import { ObjectCannedACL } from "@aws-sdk/client-s3" const handle = async (ctx: IPicGo): Promise => { const userConfig: IAwsS3Config = ctx.getConfig("picBed.awss3") @@ -24,7 +25,7 @@ const handle = async (ctx: IPicGo): Promise => { bucketName: userConfig.bucketName, path: formatPath(item, userConfig.uploadPath || ""), item: item, - acl: userConfig.acl || "public-read", + acl: userConfig.acl || ObjectCannedACL.public_read, customUrl: userConfig.customUrl || "", corsProxy: userConfig.corsProxy, }) diff --git a/libs/Universal-PicGo-Core/src/plugins/uploader/s3/uploader.ts b/libs/Universal-PicGo-Core/src/plugins/uploader/s3/uploader.ts index 2e1be1c..a87a68d 100644 --- a/libs/Universal-PicGo-Core/src/plugins/uploader/s3/uploader.ts +++ b/libs/Universal-PicGo-Core/src/plugins/uploader/s3/uploader.ts @@ -4,6 +4,7 @@ import { PutObjectCommand, GetObjectCommand, PutObjectCommandOutput, + ObjectCannedACL, } from "@aws-sdk/client-s3" import { getSignedUrl } from "@aws-sdk/s3-request-presigner" import { HttpRequest, HttpResponse } from "@smithy/protocol-http" @@ -175,7 +176,7 @@ interface createUploadTaskOpts { path: string item: IImgInfo index: number - acl: string + acl: ObjectCannedACL | undefined customUrl?: string corsProxy?: boolean } diff --git a/libs/Universal-PicGo-Core/src/types/index.d.ts b/libs/Universal-PicGo-Core/src/types/index.d.ts index 0e36573..d645ba6 100644 --- a/libs/Universal-PicGo-Core/src/types/index.d.ts +++ b/libs/Universal-PicGo-Core/src/types/index.d.ts @@ -13,6 +13,7 @@ import { ILogger } from "zhi-lib-base" import { AxiosRequestConfig } from "axios" import { IJSON } from "universal-picgo-store" import { PicgoTypeEnum } from "../utils/enums" +import { ObjectCannedACL } from "@aws-sdk/client-s3/dist-types/models/models_0" export interface IPicGo extends EventEmitter { /** @@ -242,7 +243,7 @@ export interface IAwsS3Config { customUrl?: string pathStyleAccess?: boolean rejectUnauthorized?: boolean - acl?: string + acl?: ObjectCannedACL | undefined // S3或S3兼容服务一般支持对桶设置CORS策略,优先修改桶的CORS策略 // SiYuan 桌面版没有CORS问题 // SiYuan 内置的 CORS Proxy 在iOS版上没跑通 diff --git a/packages/picgo-plugin-app/src/composables/usePicgoInitPage.ts b/packages/picgo-plugin-app/src/composables/usePicgoInitPage.ts index 795bd80..65b6261 100644 --- a/packages/picgo-plugin-app/src/composables/usePicgoInitPage.ts +++ b/packages/picgo-plugin-app/src/composables/usePicgoInitPage.ts @@ -54,7 +54,8 @@ export const usePicgoInitPage = (props: any, deps: any) => { retImgs = retImgs.concat(retImgsWithBlockId) }) // 去重 - retImgs = [...new Set([...retImgs])] + // retImgs = [...new Set([...retImgs])] + retImgs = retImgs.filter((item, index, self) => index === self.findIndex((t) => t.url === item.url)) logger.debug("解析出来的所有的图片地址=>", retImgs) // 将字符串数组格式的图片信息转换成图片对象数组