Skip to content

Commit

Permalink
Merge pull request #647 from terwer/dev
Browse files Browse the repository at this point in the history
fix: #639 duplicate images in pic list
  • Loading branch information
terwer authored Dec 11, 2024
2 parents 764e078 + 4b01c7e commit 9699a25
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion libs/Universal-PicGo-Core/src/plugins/uploader/awss3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<IPicGo> => {
const userConfig: IAwsS3Config = ctx.getConfig("picBed.awss3")
Expand All @@ -24,7 +25,7 @@ const handle = async (ctx: IPicGo): Promise<IPicGo> => {
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,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -175,7 +176,7 @@ interface createUploadTaskOpts {
path: string
item: IImgInfo
index: number
acl: string
acl: ObjectCannedACL | undefined
customUrl?: string
corsProxy?: boolean
}
Expand Down
3 changes: 2 additions & 1 deletion libs/Universal-PicGo-Core/src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down Expand Up @@ -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版上没跑通
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

// 将字符串数组格式的图片信息转换成图片对象数组
Expand Down

0 comments on commit 9699a25

Please sign in to comment.