mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
fix: 去掉.doc分段支持
This commit is contained in:
commit
de1d1c2c2c
|
|
@ -29,7 +29,8 @@ class TextSplitHandle(BaseSplitHandle):
|
|||
if file_name.endswith(".md") or file_name.endswith('.txt'):
|
||||
return True
|
||||
result = detect(buffer)
|
||||
if result['encoding'] != 'ascii' and result['confidence'] > 0.5:
|
||||
if result['encoding'] is not None and result['confidence'] is not None and result['encoding'] != 'ascii' and \
|
||||
result['confidence'] > 0.5:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
|
|
|||
|
|
@ -31,18 +31,21 @@ export const randomId = function () {
|
|||
*/
|
||||
export function fileType(name: string) {
|
||||
const suffix = name.split('.')
|
||||
|
||||
return suffix[suffix.length - 1] === 'docx' ? 'doc' : suffix[suffix.length - 1]
|
||||
return suffix[suffix.length - 1]
|
||||
}
|
||||
|
||||
/*
|
||||
获得文件对应图片
|
||||
*/
|
||||
export function getImgUrl(name: string) {
|
||||
const typeList = ['txt', 'pdf', 'doc', 'csv', 'md']
|
||||
const type = typeList.includes(fileType(name)) ? fileType(name) : 'unknow'
|
||||
const type = isRightType(name) ? fileType(name) : 'unknow'
|
||||
return new URL(`../assets/${type}-icon.svg`, import.meta.url).href
|
||||
}
|
||||
// 是否是白名单后缀
|
||||
export function isRightType(name: string) {
|
||||
const typeList = ['txt', 'pdf', 'docx', 'csv', 'md']
|
||||
return typeList.includes(fileType(name))
|
||||
}
|
||||
|
||||
/*
|
||||
从指定数组中过滤出对应的对象
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
action="#"
|
||||
:auto-upload="false"
|
||||
:show-file-list="false"
|
||||
accept=".txt, .md, .csv, .log, .doc, .docx, .pdf"
|
||||
accept=".txt, .md, .csv, .log, .docx, .pdf"
|
||||
:limit="50"
|
||||
:on-exceed="onExceed"
|
||||
:on-change="filehandleChange"
|
||||
|
|
@ -29,7 +29,7 @@
|
|||
</p>
|
||||
<div class="upload__decoration">
|
||||
<p>
|
||||
支持格式:TXT、Markdown、PDF、DOC、DOCX,每次最多上传50个文件,每个文件不超过 100MB
|
||||
支持格式:TXT、Markdown、PDF、DOCX,每次最多上传50个文件,每个文件不超过 100MB
|
||||
</p>
|
||||
<p>若使用【高级分段】建议上传前规范文件的分段标识</p>
|
||||
</div>
|
||||
|
|
@ -61,7 +61,7 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, reactive, onUnmounted, onMounted, computed, watch } from 'vue'
|
||||
import type { UploadFile, UploadFiles } from 'element-plus'
|
||||
import { filesize, getImgUrl } from '@/utils/utils'
|
||||
import { filesize, getImgUrl, isRightType } from '@/utils/utils'
|
||||
import { MsgError } from '@/utils/message'
|
||||
import useStore from '@/stores'
|
||||
const { dataset } = useStore()
|
||||
|
|
@ -91,6 +91,11 @@ const filehandleChange = (file: any, fileList: UploadFiles) => {
|
|||
fileList.splice(-1, 1) //移除当前超出大小的文件
|
||||
return false
|
||||
}
|
||||
if (!isRightType(file?.name)) {
|
||||
MsgError('文件格式不支持')
|
||||
fileList.splice(-1, 1)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
const onExceed = () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue