mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
fix: Dealing with the issue of filename exceeding 128 characters when uploading documents(#2144)
Co-authored-by: wangdan-fit2cloud <dan.wang@fit2cloud.com>
This commit is contained in:
parent
761b686214
commit
d9abe8d675
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted, reactive, watch } from 'vue'
|
||||
import ParagraphPreview from '@/views/dataset/component/ParagraphPreview.vue'
|
||||
import { cutFilename } from '@/utils/utils'
|
||||
import documentApi from '@/api/document'
|
||||
import useStore from '@/stores'
|
||||
import type { KeyValue } from '@/api/type/common'
|
||||
|
|
@ -186,8 +187,12 @@ function splitDocument() {
|
|||
.postSplitDocument(fd)
|
||||
.then((res: any) => {
|
||||
const list = res.data
|
||||
if (checkedConnect.value) {
|
||||
list.map((item: any) => {
|
||||
|
||||
list.map((item: any) => {
|
||||
if (item.name.length > 128) {
|
||||
item.name = cutFilename(item.name, 128)
|
||||
}
|
||||
if (checkedConnect.value) {
|
||||
item.content.map((v: any) => {
|
||||
v['problem_list'] = v.title.trim()
|
||||
? [
|
||||
|
|
@ -197,8 +202,9 @@ function splitDocument() {
|
|||
]
|
||||
: []
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
paragraphList.value = list
|
||||
loading.value = false
|
||||
})
|
||||
|
|
|
|||
|
|
@ -161,7 +161,11 @@
|
|||
</em>
|
||||
</p>
|
||||
<div class="upload__decoration">
|
||||
<p>{{ $t('views.document.upload.formats') }}TXT、Markdown、PDF、DOCX、HTML、XLS、XLSX、CSV、ZIP</p>
|
||||
<p>
|
||||
{{
|
||||
$t('views.document.upload.formats')
|
||||
}}TXT、Markdown、PDF、DOCX、HTML、XLS、XLSX、CSV、ZIP
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</el-upload>
|
||||
|
|
@ -207,7 +211,9 @@ const form = ref({
|
|||
})
|
||||
|
||||
const rules = reactive({
|
||||
fileList: [{ required: true, message: t('views.document.upload.requiredMessage'), trigger: 'change' }]
|
||||
fileList: [
|
||||
{ required: true, message: t('views.document.upload.requiredMessage'), trigger: 'change' }
|
||||
]
|
||||
})
|
||||
const FormRef = ref()
|
||||
|
||||
|
|
@ -217,11 +223,17 @@ watch(form.value, (value) => {
|
|||
})
|
||||
|
||||
function downloadTemplate(type: string) {
|
||||
documentApi.exportQATemplate(`${type}${t('views.document.upload.template')}.${type == 'csv' ? type : 'xlsx'}`, type)
|
||||
documentApi.exportQATemplate(
|
||||
`${type}${t('views.document.upload.template')}.${type == 'csv' ? type : 'xlsx'}`,
|
||||
type
|
||||
)
|
||||
}
|
||||
|
||||
function downloadTableTemplate(type: string) {
|
||||
documentApi.exportTableTemplate(`${type}${t('views.document.upload.template')}.${type == 'csv' ? type : 'xlsx'}`, type)
|
||||
documentApi.exportTableTemplate(
|
||||
`${type}${t('views.document.upload.template')}.${type == 'csv' ? type : 'xlsx'}`,
|
||||
type
|
||||
)
|
||||
}
|
||||
|
||||
function radioChange() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue