Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #639 duplicate images in pic list #647

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading