From abdd773886f216ea8de19e78b89b12ac99743d41 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Fri, 16 May 2025 23:03:58 +0800 Subject: [PATCH] =?UTF-8?q?feat(system/file):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=B9=E5=AF=BC=E8=88=AA=E3=80=81=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E6=96=87=E4=BB=B6=E5=A4=B9=E5=A4=A7=E5=B0=8F=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/system/file.ts | 14 ++- src/apis/system/type.ts | 7 +- .../FileDetailModal/ModalContent.vue | 40 +++++++- .../system/file/main/FileMain/FileList.vue | 38 ++++++-- .../file/main/FileMain/FileRightMenu.vue | 8 +- src/views/system/file/main/FileMain/index.vue | 93 ++++++++++++------- 6 files changed, 146 insertions(+), 54 deletions(-) diff --git a/src/apis/system/file.ts b/src/apis/system/file.ts index 48c5510..3f174a5 100644 --- a/src/apis/system/file.ts +++ b/src/apis/system/file.ts @@ -5,6 +5,11 @@ export type * from './type' const BASE_URL = '/system/file' +/** @desc 上传文件 */ +export function uploadFile(data: FormData) { + return http.post(`${BASE_URL}/upload`, data) +} + /** @desc 查询文件列表 */ export function listFile(query: T.FilePageQuery) { return http.get>(`${BASE_URL}`, query) @@ -31,6 +36,11 @@ export function checkFile(sha256: string) { } /** @desc 创建文件夹 */ -export function createDir(path: string, name: string) { - return http.post(`${BASE_URL}/dir`, { path, originalName: name }) +export function createDir(parentPath: string, name: string) { + return http.post(`${BASE_URL}/dir`, { parentPath, originalName: name }) +} + +/** @desc 查询文件夹大小 */ +export function calcDirSize(id: string) { + return http.get(`${BASE_URL}/dir/${id}/size`) } diff --git a/src/apis/system/type.ts b/src/apis/system/type.ts index a487cd0..d1845e0 100644 --- a/src/apis/system/type.ts +++ b/src/apis/system/type.ts @@ -205,6 +205,7 @@ export interface FileItem { originalName: string size: number url: string + parentPath: string path: string sha256: string contentType: string @@ -230,10 +231,14 @@ export interface FileStatisticsResp { unit: string data: Array } +/** 文件夹计算大小信息 */ +export interface FileDirCalcSizeResp { + size: number +} export interface FileQuery { originalName?: string type?: string - path?: string + parentPath?: string sort: Array } export interface FilePageQuery extends FileQuery, PageQuery { diff --git a/src/views/system/file/components/FileDetailModal/ModalContent.vue b/src/views/system/file/components/FileDetailModal/ModalContent.vue index a23c652..4f82daf 100644 --- a/src/views/system/file/components/FileDetailModal/ModalContent.vue +++ b/src/views/system/file/components/FileDetailModal/ModalContent.vue @@ -7,13 +7,27 @@ - + {{ data.originalName }} - {{ formatFileSize(data.size) }} - {{ `${data.path === '/' ? '' : data.path}/${data.name}` }} + + + + {{ isCalculating ? '计算中...' : '计算' }} + + + {{ formatFileSize(calculatedSize) }} + + + {{ formatFileSize(data.size) }} + + {{ `${data.parentPath === '/' ? '' : data.parentPath}/${data.name}` }} @@ -28,15 +42,31 @@