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 @@