From 9d9e26aa56ddb6da65cefa9a95ebb34a66b648b0 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 24 Aug 2022 18:24:55 +0800 Subject: [PATCH] =?UTF-8?q?style(=E6=96=87=E4=BB=B6=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=90=8E=E7=BC=80=E4=BC=98=E5=8C=96=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1016286 --user=赵勇 除了图片外,不能预览的展示文件类型,如JAR、XLSX https://www.tapd.cn/55049933/s/1233267 --- .../controller/FileMetadataController.java | 4 ++++ .../metadata/service/FileMetadataService.java | 4 ++++ .../scenario/variable/CsvFileUpload.vue | 18 ++++++++++++++++-- .../components/body/ApiBodyFileUpload.vue | 19 ++++++++++++++----- .../menu/file/edit/EditFileMetadata.vue | 4 ++-- .../project/menu/file/list/FileThumbnail.vue | 8 ++++---- 6 files changed, 44 insertions(+), 13 deletions(-) diff --git a/backend/src/main/java/io/metersphere/metadata/controller/FileMetadataController.java b/backend/src/main/java/io/metersphere/metadata/controller/FileMetadataController.java index 45d3651a9c..8f2a4fdb5d 100644 --- a/backend/src/main/java/io/metersphere/metadata/controller/FileMetadataController.java +++ b/backend/src/main/java/io/metersphere/metadata/controller/FileMetadataController.java @@ -108,4 +108,8 @@ public class FileMetadataController { return fileMetadataService.myFiles(createUser, projectId); } + @GetMapping(value = "/exist/{fileId}") + public boolean exist(@PathVariable("fileId") String fileId) { + return fileMetadataService.exist(fileId); + } } diff --git a/backend/src/main/java/io/metersphere/metadata/service/FileMetadataService.java b/backend/src/main/java/io/metersphere/metadata/service/FileMetadataService.java index e54978938f..d08f3f8421 100644 --- a/backend/src/main/java/io/metersphere/metadata/service/FileMetadataService.java +++ b/backend/src/main/java/io/metersphere/metadata/service/FileMetadataService.java @@ -426,4 +426,8 @@ public class FileMetadataService { fileMetadata.setUpdateUser(SessionUtils.getUserId()); } } + + public boolean exist(String fileId) { + return fileMetadataMapper.selectByPrimaryKey(fileId) != null; + } } diff --git a/frontend/src/business/components/api/automation/scenario/variable/CsvFileUpload.vue b/frontend/src/business/components/api/automation/scenario/variable/CsvFileUpload.vue index 31e794affe..c397a612bb 100644 --- a/frontend/src/business/components/api/automation/scenario/variable/CsvFileUpload.vue +++ b/frontend/src/business/components/api/automation/scenario/variable/CsvFileUpload.vue @@ -32,11 +32,12 @@ -
+
{{ file.file && file.file.name ? file.file.name : file.name }} + {{ file.isExist ? '文件已经被删除' : '' }} @@ -56,7 +57,6 @@ - @@ -71,6 +71,7 @@ export default { data() { return { disabled: false, + loading: false, }; }, components: { @@ -83,7 +84,19 @@ export default { return {} } }, + mounted() { + this.exist(); + }, methods: { + exist() { + this.loading = true; + this.parameter.files.forEach(file => { + this.$get('/file/metadata/exist/' + file.fileId, response => { + file.isExist = !response.data; + this.loading = false; + }); + }); + }, setModuleId(moduleId) { let files = []; if (this.file && this.file.file) { @@ -203,6 +216,7 @@ export default { if (!this.parameter.files) { this.parameter.files = []; } + this.exist(); } } diff --git a/frontend/src/business/components/api/definition/components/body/ApiBodyFileUpload.vue b/frontend/src/business/components/api/definition/components/body/ApiBodyFileUpload.vue index 982140707a..223cf04abc 100644 --- a/frontend/src/business/components/api/definition/components/body/ApiBodyFileUpload.vue +++ b/frontend/src/business/components/api/definition/components/body/ApiBodyFileUpload.vue @@ -27,11 +27,12 @@
{{ file.file && file.file.name ? file.file.name : file.name }} - - - - - + + + + {{ file.isExist ? '文件已经被删除' : '' }} + + @@ -73,6 +74,13 @@ export default { } }, methods: { + exist() { + this.parameter.files.forEach(file => { + this.$get('/file/metadata/exist/' + file.fileId, response => { + file.isExist = !response.data; + }); + }); + }, setModuleId(moduleId) { let files = []; if (this.file && this.file.file) { @@ -125,6 +133,7 @@ export default { if (!this.parameter.files) { this.parameter.files = []; } + this.exist(); } } diff --git a/frontend/src/business/components/project/menu/file/edit/EditFileMetadata.vue b/frontend/src/business/components/project/menu/file/edit/EditFileMetadata.vue index 3bbd49de64..f0dab91487 100644 --- a/frontend/src/business/components/project/menu/file/edit/EditFileMetadata.vue +++ b/frontend/src/business/components/project/menu/file/edit/EditFileMetadata.vue @@ -200,7 +200,7 @@ export default { }); }, getType(type) { - return type ? type.substr(0, 1).toUpperCase() : ""; + return type || ""; }, isImage(type) { return (type && this.images.indexOf(type.toLowerCase()) !== -1); @@ -332,7 +332,7 @@ export default { .icon-title { color: #fff; text-align: center; - font-size: 22px; + font-size: 16px; } diff --git a/frontend/src/business/components/project/menu/file/list/FileThumbnail.vue b/frontend/src/business/components/project/menu/file/list/FileThumbnail.vue index 0d111c4c7b..787cefd7c2 100644 --- a/frontend/src/business/components/project/menu/file/list/FileThumbnail.vue +++ b/frontend/src/business/components/project/menu/file/list/FileThumbnail.vue @@ -44,7 +44,7 @@ export default { currentPage: 1, pageSize: 10, total: 0, - images: ["bmp", "jpg", "png", "tif", "gif", "pcx", "tga", "exif", "fpx", "svg", "psd", "cdr", "pcd", "dxf", "ufo", "eps", "ai", "raw", "WMF", "webp", "avif", "apng","jpeg"] + images: ["bmp", "jpg", "png", "tif", "gif", "pcx", "tga", "exif", "fpx", "svg", "psd", "cdr", "pcd", "dxf", "ufo", "eps", "ai", "raw", "WMF", "webp", "avif", "apng", "jpeg"] }; }, props: { @@ -83,7 +83,7 @@ export default { this.$refs.editMetadata.open(row, this.pageSize, this.currentPage, this.total); }, getType(type) { - return type ? type.substr(0, 1).toUpperCase() : "X"; + return type || ""; }, change() { this.$emit("change", this.pageSize, this.currentPage); @@ -114,7 +114,7 @@ export default { .ms-file { text-align: center; - padding-top: 90px + padding-top: 85px } .ms-file-name-width { @@ -132,7 +132,7 @@ export default { .icon-title { color: #fff; text-align: center; - font-size: 22px; + font-size: 16px; }