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'):
|
if file_name.endswith(".md") or file_name.endswith('.txt'):
|
||||||
return True
|
return True
|
||||||
result = detect(buffer)
|
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 True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
@ -31,18 +31,21 @@ export const randomId = function () {
|
|||||||
*/
|
*/
|
||||||
export function fileType(name: string) {
|
export function fileType(name: string) {
|
||||||
const suffix = name.split('.')
|
const suffix = name.split('.')
|
||||||
|
return suffix[suffix.length - 1]
|
||||||
return suffix[suffix.length - 1] === 'docx' ? 'doc' : suffix[suffix.length - 1]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
获得文件对应图片
|
获得文件对应图片
|
||||||
*/
|
*/
|
||||||
export function getImgUrl(name: string) {
|
export function getImgUrl(name: string) {
|
||||||
const typeList = ['txt', 'pdf', 'doc', 'csv', 'md']
|
const type = isRightType(name) ? fileType(name) : 'unknow'
|
||||||
const type = typeList.includes(fileType(name)) ? fileType(name) : 'unknow'
|
|
||||||
return new URL(`../assets/${type}-icon.svg`, import.meta.url).href
|
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="#"
|
action="#"
|
||||||
:auto-upload="false"
|
:auto-upload="false"
|
||||||
:show-file-list="false"
|
:show-file-list="false"
|
||||||
accept=".txt, .md, .csv, .log, .doc, .docx, .pdf"
|
accept=".txt, .md, .csv, .log, .docx, .pdf"
|
||||||
:limit="50"
|
:limit="50"
|
||||||
:on-exceed="onExceed"
|
:on-exceed="onExceed"
|
||||||
:on-change="filehandleChange"
|
:on-change="filehandleChange"
|
||||||
@ -29,7 +29,7 @@
|
|||||||
</p>
|
</p>
|
||||||
<div class="upload__decoration">
|
<div class="upload__decoration">
|
||||||
<p>
|
<p>
|
||||||
支持格式:TXT、Markdown、PDF、DOC、DOCX,每次最多上传50个文件,每个文件不超过 100MB
|
支持格式:TXT、Markdown、PDF、DOCX,每次最多上传50个文件,每个文件不超过 100MB
|
||||||
</p>
|
</p>
|
||||||
<p>若使用【高级分段】建议上传前规范文件的分段标识</p>
|
<p>若使用【高级分段】建议上传前规范文件的分段标识</p>
|
||||||
</div>
|
</div>
|
||||||
@ -61,7 +61,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, onUnmounted, onMounted, computed, watch } from 'vue'
|
import { ref, reactive, onUnmounted, onMounted, computed, watch } from 'vue'
|
||||||
import type { UploadFile, UploadFiles } from 'element-plus'
|
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 { MsgError } from '@/utils/message'
|
||||||
import useStore from '@/stores'
|
import useStore from '@/stores'
|
||||||
const { dataset } = useStore()
|
const { dataset } = useStore()
|
||||||
@ -91,6 +91,11 @@ const filehandleChange = (file: any, fileList: UploadFiles) => {
|
|||||||
fileList.splice(-1, 1) //移除当前超出大小的文件
|
fileList.splice(-1, 1) //移除当前超出大小的文件
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if (!isRightType(file?.name)) {
|
||||||
|
MsgError('文件格式不支持')
|
||||||
|
fileList.splice(-1, 1)
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onExceed = () => {
|
const onExceed = () => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user