From 9f814077adb541291d16ebe57dad9a215d12593d Mon Sep 17 00:00:00 2001 From: zhengkunwang223 Date: Fri, 9 Sep 2022 18:27:50 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E5=A2=9E=E5=8A=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api/interface/file.ts | 1 + frontend/src/utils/util.ts | 18 ++++++++++++++++++ .../src/views/host/file-management/index.vue | 12 ++++++------ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/frontend/src/api/interface/file.ts b/frontend/src/api/interface/file.ts index 200954f08..d993d5689 100644 --- a/frontend/src/api/interface/file.ts +++ b/frontend/src/api/interface/file.ts @@ -17,6 +17,7 @@ export namespace File { mimeType: string; dirSize: number; items: File[]; + extension: string; } export interface ReqFile { diff --git a/frontend/src/utils/util.ts b/frontend/src/utils/util.ts index 108af921f..1af0661f4 100644 --- a/frontend/src/utils/util.ts +++ b/frontend/src/utils/util.ts @@ -82,3 +82,21 @@ export function computeSize(size: number): string { if (size < Math.pow(num, 4)) return (size / Math.pow(num, 3)).toFixed(2) + ' GB'; return (size / Math.pow(num, 4)).toFixed(2) + ' TB'; } + +let icons = new Map([ + ['.zip', 'p-file-zip'], + ['.gz', 'p-file-zip'], + ['.tar.bz2', 'p-file-zip'], + ['.tar', 'p-file-zip'], + ['.tar.gz', 'p-file-zip'], + ['.tar.xz', 'p-file-zip'], +]); + +export function getIcon(extention: string): string { + if (icons.get(extention) != undefined) { + const icon = icons.get(extention); + return String(icon); + } else { + return 'p-file-normal'; + } +} diff --git a/frontend/src/views/host/file-management/index.vue b/frontend/src/views/host/file-management/index.vue index 66273a136..3f1cbd9ed 100644 --- a/frontend/src/views/host/file-management/index.vue +++ b/frontend/src/views/host/file-management/index.vue @@ -84,16 +84,12 @@ {{ $t('file.download') }} - - @@ -190,7 +186,7 @@ import { SaveFileContent, ComputeDirSize, } from '@/api/modules/files'; -import { computeSize, dateFromat, getRandomStr } from '@/utils/util'; +import { computeSize, dateFromat, getIcon, getRandomStr } from '@/utils/util'; import { File } from '@/api/interface/file'; import { useDeleteData } from '@/hooks/use-delete-data'; import { ElMessage } from 'element-plus'; @@ -363,6 +359,10 @@ const getDirSize = async (row: any) => { }); }; +const getIconName = (extension: string) => { + return getIcon(extension); +}; + const closeCreate = () => { filePage.open = false; search(req);