mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
parent
33762f26bf
commit
8e3e46a96d
|
|
@ -287,7 +287,7 @@
|
|||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted, nextTick, watch } from 'vue'
|
||||
import { ref, computed, onMounted, nextTick, watch, reactive } from 'vue'
|
||||
import Recorder from 'recorder-core'
|
||||
import TouchChat from './TouchChat.vue'
|
||||
import applicationApi from '@/api/application'
|
||||
|
|
@ -392,17 +392,7 @@ const checkMaxFilesLimit = () => {
|
|||
uploadOtherList.value.length
|
||||
)
|
||||
}
|
||||
const file_name_eq = (str: string, str1: string) => {
|
||||
return (
|
||||
str.replaceAll(' ', '') === str1.replaceAll(' ', '') ||
|
||||
decodeHtmlEntities(str) === decodeHtmlEntities(str1)
|
||||
)
|
||||
}
|
||||
function decodeHtmlEntities(str: string) {
|
||||
const tempDiv = document.createElement('div')
|
||||
tempDiv.innerHTML = str
|
||||
return tempDiv.textContent || tempDiv.innerText || ''
|
||||
}
|
||||
|
||||
const uploadFile = async (file: any, fileList: any) => {
|
||||
const { maxFiles, fileLimit } = props.applicationDetails.file_upload_setting
|
||||
// 单次上传文件数量限制
|
||||
|
|
@ -427,6 +417,7 @@ const uploadFile = async (file: any, fileList: any) => {
|
|||
const formData = new FormData()
|
||||
formData.append('file', file.raw, file.name)
|
||||
//
|
||||
file = reactive(file)
|
||||
const extension = file.name.split('.').pop().toUpperCase() // 获取文件后缀名并转为小写
|
||||
if (imageExtensions.includes(extension)) {
|
||||
uploadImageList.value.push(file)
|
||||
|
|
@ -460,41 +451,9 @@ const uploadFile = async (file: any, fileList: any) => {
|
|||
)
|
||||
.then((response) => {
|
||||
fileList.splice(0, fileList.length)
|
||||
uploadImageList.value.forEach((file: any) => {
|
||||
const f = response.data.filter((f: any) => file_name_eq(f.name, file.name))
|
||||
if (f.length > 0) {
|
||||
file.url = f[0].url
|
||||
file.file_id = f[0].file_id
|
||||
}
|
||||
})
|
||||
uploadDocumentList.value.forEach((file: any) => {
|
||||
const f = response.data.filter((f: any) => file_name_eq(f.name, file.name))
|
||||
if (f.length > 0) {
|
||||
file.url = f[0].url
|
||||
file.file_id = f[0].file_id
|
||||
}
|
||||
})
|
||||
uploadAudioList.value.forEach((file: any) => {
|
||||
const f = response.data.filter((f: any) => file_name_eq(f.name, file.name))
|
||||
if (f.length > 0) {
|
||||
file.url = f[0].url
|
||||
file.file_id = f[0].file_id
|
||||
}
|
||||
})
|
||||
uploadVideoList.value.forEach((file: any) => {
|
||||
const f = response.data.filter((f: any) => file_name_eq(f.name, file.name))
|
||||
if (f.length > 0) {
|
||||
file.url = f[0].url
|
||||
file.file_id = f[0].file_id
|
||||
}
|
||||
})
|
||||
uploadOtherList.value.forEach((file: any) => {
|
||||
const f = response.data.filter((f: any) => file_name_eq(f.name, file.name))
|
||||
if (f.length > 0) {
|
||||
file.url = f[0].url
|
||||
file.file_id = f[0].file_id
|
||||
}
|
||||
})
|
||||
file.url = response.data[0].url
|
||||
file.file_id = response.data[0].file_id
|
||||
|
||||
if (!inputValue.value && uploadImageList.value.length > 0) {
|
||||
inputValue.value = t('chat.uploadFile.imageMessage')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ const prologue = computed(() => {
|
|||
]
|
||||
let _temp = temp
|
||||
for (const index in tag_list) {
|
||||
_temp = _temp.replaceAll(tag_list[index], '')
|
||||
_temp = _temp.replace(new RegExp(tag_list[index], 'g'), '')
|
||||
}
|
||||
const quick_question_list = _temp.match(/-\s.+/g)
|
||||
let result = temp
|
||||
|
|
|
|||
Loading…
Reference in New Issue