From d9abe8d675b99330f0e20f08b8874f369964d8e1 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 <80892890+shaohuzhang1@users.noreply.github.com> Date: Sun, 9 Feb 2025 15:09:55 +0800 Subject: [PATCH] fix: Dealing with the issue of filename exceeding 128 characters when uploading documents(#2144) Co-authored-by: wangdan-fit2cloud --- ui/src/utils/utils.ts | 10 +++++++++- ui/src/views/dataset/component/SetRules.vue | 14 +++++++++---- .../dataset/component/UploadComponent.vue | 20 +++++++++++++++---- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/ui/src/utils/utils.ts b/ui/src/utils/utils.ts index a926a4074..b7a9f8941 100644 --- a/ui/src/utils/utils.ts +++ b/ui/src/utils/utils.ts @@ -1,3 +1,5 @@ +import { number } from 'echarts' + export function toThousands(num: any) { return num?.toString().replace(/\d+/, function (n: any) { return n.replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') @@ -51,7 +53,6 @@ export function getImgUrl(name: string) { } // 是否是白名单后缀 export function isRightType(name: string, type: string) { - console.log(name, type) return typeList[type].includes(fileType(name).toLowerCase()) } @@ -100,3 +101,10 @@ export function downloadByURL(url: string, name: string) { a.click() document.body.removeChild(a) } + +// 截取文件名 +export function cutFilename(filename: string, num: number) { + const lastIndex = filename.lastIndexOf('.') + const suffix = lastIndex === -1 ? '' : filename.substring(lastIndex + 1) + return filename.substring(0, num - suffix.length - 1) + '.' + suffix +} diff --git a/ui/src/views/dataset/component/SetRules.vue b/ui/src/views/dataset/component/SetRules.vue index a377af44e..07e9acdec 100644 --- a/ui/src/views/dataset/component/SetRules.vue +++ b/ui/src/views/dataset/component/SetRules.vue @@ -121,6 +121,7 @@