From 08939bec64156d383777bba5864645537d37804d Mon Sep 17 00:00:00 2001 From: Seven Date: Thu, 8 Jan 2026 13:13:35 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20S3=20=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=8C=85=E5=90=AB=E9=A2=84?= =?UTF-8?q?=E7=AD=BE=E5=90=8D=20URL=20=E8=8E=B7=E5=8F=96=E5=92=8C=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auto-imports.d.ts | 3 +++ src/utils/aws/s3.ts | 19 +++++++++++++++++++ src/utils/index.ts | 1 + 3 files changed, 23 insertions(+) create mode 100644 src/utils/aws/s3.ts diff --git a/auto-imports.d.ts b/auto-imports.d.ts index 7327015..776f1c9 100644 --- a/auto-imports.d.ts +++ b/auto-imports.d.ts @@ -138,6 +138,7 @@ declare global { const unref: typeof import('vue').unref const unrefElement: typeof import('@vueuse/core').unrefElement const until: typeof import('@vueuse/core').until + const uploadToS3: typeof import('./src/utils/aws/s3').uploadToS3 const useActiveElement: typeof import('@vueuse/core').useActiveElement const useAnimate: typeof import('@vueuse/core').useAnimate const useAppUpdate: typeof import('./src/composables/useAppUpdate').useAppUpdate @@ -308,6 +309,7 @@ declare global { const useToggle: typeof import('@vueuse/core').useToggle const useTradingView: typeof import('./src/composables/useTradingView').useTradingView const useTransition: typeof import('@vueuse/core').useTransition + const useUploadToS3: typeof import('./src/composables/useUploadToS3').useUploadToS3 const useUrlSearchParams: typeof import('@vueuse/core').useUrlSearchParams const useUserMedia: typeof import('@vueuse/core').useUserMedia const useUserStore: typeof import('./src/store/user').useUserStore @@ -503,6 +505,7 @@ declare module 'vue' { readonly unref: UnwrapRef readonly unrefElement: UnwrapRef readonly until: UnwrapRef + readonly uploadToS3: UnwrapRef readonly useActiveElement: UnwrapRef readonly useAnimate: UnwrapRef readonly useAppUpdate: UnwrapRef diff --git a/src/utils/aws/s3.ts b/src/utils/aws/s3.ts new file mode 100644 index 0000000..29822ae --- /dev/null +++ b/src/utils/aws/s3.ts @@ -0,0 +1,19 @@ +import { client, safeClient } from "@/api"; + +interface PresignedUrlResponse { + uploadUrl: string; + fileUrl: string; + key: string; + expiresIn: number; +} + +interface UploadOptions { + onProgress?: (progress: number) => void; + signal?: AbortSignal; +} + +export function uploadToS3(file: File, options: UploadOptions = {}) { + const { onProgress, signal } = options || {}; + + // 1. 获取预签名 URL +} diff --git a/src/utils/index.ts b/src/utils/index.ts index 7ad319f..de24259 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,3 +1,4 @@ +export * from "./aws/s3"; export * from "./ionic-helper"; export * from "./is"; export * from "./pattern";