From 1cb33bd3ad8590882ede66a9f3ab3f1cec047131 Mon Sep 17 00:00:00 2001 From: rd <1344903914@qq.com> Date: Thu, 31 Jul 2025 18:18:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A7=86=E9=A2=91=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/all/common.ts | 12 +- src/utils/tools.ts | 22 +++ .../manuscript/components/edit-form/index.vue | 156 ++++++++++++++---- 3 files changed, 157 insertions(+), 33 deletions(-) diff --git a/src/api/all/common.ts b/src/api/all/common.ts index d06e4f4..574d7e9 100644 --- a/src/api/all/common.ts +++ b/src/api/all/common.ts @@ -61,4 +61,14 @@ export const postBatchDownload = (params = {}) => { // 任务中心-批量查询任务状态 export const batchQueryTaskStatus = (params = {}) => { return Http.get(`/v1/tasks/batch-query-status`, params); -}; \ No newline at end of file +}; + +// 获取图片上传地址 +export const getImagePreSignedUrl = (params = {}) => { + return Http.get('/v1/oss/image-pre-signed-url', params); +}; + +// 获取视频上传地址 +export const getVideoPreSignedUrl = (params = {}) => { + return Http.get('/v1/oss/video-pre-signed-url', params); +}; diff --git a/src/utils/tools.ts b/src/utils/tools.ts index 7fa94db..02e2178 100644 --- a/src/utils/tools.ts +++ b/src/utils/tools.ts @@ -109,4 +109,26 @@ export function downloadByUrl(url: string, filename?: string) { export function genRandomId() { return `id_${Date.now()}_${Math.floor(Math.random() * 10000)}`; +} + +export function formatFileSize(bytes: number): string { + if (bytes === 0) return '0 Bytes'; + + const k = 1024; + const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; + const i = Math.floor(Math.log(bytes) / Math.log(k)); + + return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]; +} + +export function getVideoDuration(file: any) { + return new Promise((resolve) => { + const video = document.createElement('video'); + video.preload = 'metadata'; + video.onloadedmetadata = function() { + window.URL.revokeObjectURL(video.src); + resolve(video.duration); + }; + video.src = URL.createObjectURL(file); + }); } \ No newline at end of file diff --git a/src/views/creative-generation-workshop/manuscript/components/edit-form/index.vue b/src/views/creative-generation-workshop/manuscript/components/edit-form/index.vue index 120f59e..6a1d3fd 100644 --- a/src/views/creative-generation-workshop/manuscript/components/edit-form/index.vue +++ b/src/views/creative-generation-workshop/manuscript/components/edit-form/index.vue @@ -1,10 +1,13 @@