|
@@ -90,16 +90,18 @@
|
|
<el-input ref="textareaRef" v-model="inputMessage" type="textarea" :rows="3" placeholder="输入消息..."
|
|
<el-input ref="textareaRef" v-model="inputMessage" type="textarea" :rows="3" placeholder="输入消息..."
|
|
@keyup.enter="() => handleAsk()" />
|
|
@keyup.enter="() => handleAsk()" />
|
|
<div class="chat_area_op">
|
|
<div class="chat_area_op">
|
|
- <el-button
|
|
|
|
- :style="`background-color:${inputMessage.trim() ? '#4d6bfe' : '#d6dee8'};border-color:${inputMessage.trim() ? '#4d6bfe' : '#d6dee8'}`"
|
|
|
|
- v-if="inputMessage.trim() || !sendLoading" type="primary" circle @click="() => handleAsk()"
|
|
|
|
- :disabled="!inputMessage.trim() || sendLoading">
|
|
|
|
- <svg-icon icon-class="send" color="#000000" />
|
|
|
|
- </el-button>
|
|
|
|
- <el-button style="background-color:#ffffff;border:2px solid rgb(134 143 153);" v-else circle
|
|
|
|
|
|
+
|
|
|
|
+ <el-button v-if="sendLoading" style="background-color:#ffffff;border:2px solid rgb(134 143 153);" circle
|
|
@click="handleStopAsk">
|
|
@click="handleStopAsk">
|
|
<svg-icon icon-class="stop" color="red" />
|
|
<svg-icon icon-class="stop" color="red" />
|
|
</el-button>
|
|
</el-button>
|
|
|
|
+ <el-button
|
|
|
|
+ v-else
|
|
|
|
+ :style="`background-color:${inputMessage.trim() ? '#4d6bfe' : '#d6dee8'};border-color:${inputMessage.trim() ? '#4d6bfe' : '#d6dee8'}`"
|
|
|
|
+ type="primary" circle @click="() => handleAsk()"
|
|
|
|
+ :disabled="disSend">
|
|
|
|
+ <svg-icon icon-class="send" color="#000000" />
|
|
|
|
+ </el-button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
@@ -135,7 +137,7 @@ import userAvatar from '@/assets/images/user.png'
|
|
import avatar from '@/public/icon/32.png'
|
|
import avatar from '@/public/icon/32.png'
|
|
import { options, FunctionList } from '@/entrypoints/sidepanel/mock'
|
|
import { options, FunctionList } from '@/entrypoints/sidepanel/mock'
|
|
import { useAutoResizeTextarea } from '@/entrypoints/sidepanel/hook/useAutoResizeTextarea.ts'
|
|
import { useAutoResizeTextarea } from '@/entrypoints/sidepanel/hook/useAutoResizeTextarea.ts'
|
|
-import { getPageInfo, getXlsxValue, handleInput } from './utils/index.js'
|
|
|
|
|
|
+import { getPageInfo, getPageInfoClean, handleInput,downloadFile } from './utils/index.js'
|
|
import { useMsgStore } from '@/store/modules/msg.ts'
|
|
import { useMsgStore } from '@/store/modules/msg.ts'
|
|
import { useUserStore } from '@/store/modules/user'
|
|
import { useUserStore } from '@/store/modules/user'
|
|
import { putChat, uploadFile } from "@/api/index.js";
|
|
import { putChat, uploadFile } from "@/api/index.js";
|
|
@@ -152,6 +154,12 @@ const xlsxData = ref({})
|
|
const isShowPage = ref(false)
|
|
const isShowPage = ref(false)
|
|
const tareRef = useTemplateRef('textareaRef')
|
|
const tareRef = useTemplateRef('textareaRef')
|
|
const drawerRef = useTemplateRef('historyComponentRef')
|
|
const drawerRef = useTemplateRef('historyComponentRef')
|
|
|
|
+const disSend = computed(() => {
|
|
|
|
+ if (pageInfoList.value.length && type.value === FunctionList.Intelligent_Form_filling) return true
|
|
|
|
+ if (sendLoading.value) return true
|
|
|
|
+ if (inputMessage.value.trim()) return false
|
|
|
|
+ return true
|
|
|
|
+})
|
|
// 获取父组件提供的 Hook 实例
|
|
// 获取父组件提供的 Hook 实例
|
|
const msgStore = useMsgStore()
|
|
const msgStore = useMsgStore()
|
|
const { pageInfoList, messages, msgUuid, AIModel,page,hasNext,msgLoading } = storeToRefs(useMsgStore())
|
|
const { pageInfoList, messages, msgUuid, AIModel,page,hasNext,msgLoading } = storeToRefs(useMsgStore())
|
|
@@ -161,18 +169,17 @@ const {
|
|
sendLoading,
|
|
sendLoading,
|
|
type,
|
|
type,
|
|
fetchRes
|
|
fetchRes
|
|
|
|
+
|
|
} = useMsg(scrollbar)
|
|
} = useMsg(scrollbar)
|
|
const inputMessage = ref('')
|
|
const inputMessage = ref('')
|
|
const pageInfo = ref('')
|
|
const pageInfo = ref('')
|
|
const summaryHtml = ref(false)
|
|
const summaryHtml = ref(false)
|
|
function handleStopAsk() {
|
|
function handleStopAsk() {
|
|
- if (type.value === FunctionList.Intelligent_Form_filling) {
|
|
|
|
inputMessage.value = ''
|
|
inputMessage.value = ''
|
|
pageInfoList.value = []
|
|
pageInfoList.value = []
|
|
isShowPage.value = false
|
|
isShowPage.value = false
|
|
taklToHtml.value = false
|
|
taklToHtml.value = false
|
|
type.value = FunctionList.File_Operation
|
|
type.value = FunctionList.File_Operation
|
|
- }
|
|
|
|
controllerList.value[0].abort()
|
|
controllerList.value[0].abort()
|
|
controllerList.value = []
|
|
controllerList.value = []
|
|
sendLoading.value = false
|
|
sendLoading.value = false
|
|
@@ -276,7 +283,7 @@ const handleSummaryFile = async () => {
|
|
// conversationId: msgUuid.value,
|
|
// conversationId: msgUuid.value,
|
|
// })
|
|
// })
|
|
// messages.value.push(msg)
|
|
// messages.value.push(msg)
|
|
- isShowPage.value = false
|
|
|
|
|
|
+ // isShowPage.value = false
|
|
pageInfoList.value = []
|
|
pageInfoList.value = []
|
|
// const resForm = await askQues({
|
|
// const resForm = await askQues({
|
|
// conversationId: msgUuid.value,
|
|
// conversationId: msgUuid.value,
|
|
@@ -346,8 +353,10 @@ watchEffect(() => {
|
|
summaryHtml.value = false
|
|
summaryHtml.value = false
|
|
type.value = FunctionList.File_Operation
|
|
type.value = FunctionList.File_Operation
|
|
SystemMsg = null
|
|
SystemMsg = null
|
|
|
|
+ inputMessage.value = ''
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
+const htmlIcon = ref('')
|
|
async function readClick() {
|
|
async function readClick() {
|
|
if (type.value === FunctionList.Intelligent_Form_filling) {
|
|
if (type.value === FunctionList.Intelligent_Form_filling) {
|
|
pageInfoList.value = []
|
|
pageInfoList.value = []
|
|
@@ -361,12 +370,20 @@ async function readClick() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
const tempPageInfo = await getPageInfo()
|
|
const tempPageInfo = await getPageInfo()
|
|
|
|
+ htmlIcon.value = tempPageInfo.favIconUrl
|
|
const blob = new Blob([tempPageInfo.content.mainContent], { type: 'text/plain' })
|
|
const blob = new Blob([tempPageInfo.content.mainContent], { type: 'text/plain' })
|
|
- const file = new File([blob], tempPageInfo.title + '.txt', { type: 'text/plain' })
|
|
|
|
|
|
+ const file = new File([blob], '页面' + '.txt', { type: 'text/plain' })
|
|
|
|
+ // console.log(file);
|
|
|
|
+ // 下载文件到本地
|
|
|
|
+ // downloadFile(file);
|
|
|
|
+ console.log(tempPageInfo);
|
|
|
|
+
|
|
await createFileObj(file)
|
|
await createFileObj(file)
|
|
// await handleUpload(file,tempPageInfo.title + '.txt')
|
|
// await handleUpload(file,tempPageInfo.title + '.txt')
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 添加下载文件的函数
|
|
|
|
+
|
|
function deletePageInfo(i) {
|
|
function deletePageInfo(i) {
|
|
pageInfoList.value.splice(i, 1)
|
|
pageInfoList.value.splice(i, 1)
|
|
if (pageInfoList.value.length === 0) {
|
|
if (pageInfoList.value.length === 0) {
|
|
@@ -403,6 +420,7 @@ function closePageInfo() {
|
|
formInfo.value = null
|
|
formInfo.value = null
|
|
}
|
|
}
|
|
async function handleAsk(value) {
|
|
async function handleAsk(value) {
|
|
|
|
+ if (sendLoading.value) return
|
|
const str = value ?? inputMessage.value.trim()
|
|
const str = value ?? inputMessage.value.trim()
|
|
inputMessage.value = ''
|
|
inputMessage.value = ''
|
|
if (type.value === FunctionList.Intelligent_Form_filling) {
|
|
if (type.value === FunctionList.Intelligent_Form_filling) {
|
|
@@ -435,9 +453,8 @@ async function handleAsk(value) {
|
|
*
|
|
*
|
|
* @param msg 用户消息对象,调用askQues时需要
|
|
* @param msg 用户消息对象,调用askQues时需要
|
|
*/
|
|
*/
|
|
-function createWS(msg) {
|
|
|
|
- try {
|
|
|
|
- sendLoading.value = true
|
|
|
|
|
|
+async function createWS(msg) {
|
|
|
|
+ sendLoading.value = true
|
|
const obj = reactive({
|
|
const obj = reactive({
|
|
type: type.value === FunctionList.Intelligent_Form_filling ? 'form' : '',
|
|
type: type.value === FunctionList.Intelligent_Form_filling ? 'form' : '',
|
|
rawContent: '',
|
|
rawContent: '',
|
|
@@ -448,6 +465,7 @@ function createWS(msg) {
|
|
role: 'system',
|
|
role: 'system',
|
|
conversationId: msgUuid.value,
|
|
conversationId: msgUuid.value,
|
|
})
|
|
})
|
|
|
|
+ try {
|
|
messages.value.push(obj)
|
|
messages.value.push(obj)
|
|
nextTick(() => {
|
|
nextTick(() => {
|
|
if (scrollbar.value && scrollbar.value.wrapRef) {
|
|
if (scrollbar.value && scrollbar.value.wrapRef) {
|
|
@@ -462,10 +480,16 @@ function createWS(msg) {
|
|
question: type.value === FunctionList.File_Operation ? msg.rawContent : buildObjPrompt(xlsxData.value,formInfo.value),
|
|
question: type.value === FunctionList.File_Operation ? msg.rawContent : buildObjPrompt(xlsxData.value,formInfo.value),
|
|
id: '699637194561691650',
|
|
id: '699637194561691650',
|
|
redisKey:msg.redisKey
|
|
redisKey:msg.redisKey
|
|
- })
|
|
|
|
|
|
+ }).catch(res => {
|
|
|
|
+ obj.rawContent = '接口出错,请重试。'
|
|
|
|
+ obj.content = '接口出错,请重试。'
|
|
|
|
+ socket.close()
|
|
|
|
+ })
|
|
socket.onmessage = (event) => {
|
|
socket.onmessage = (event) => {
|
|
try {
|
|
try {
|
|
if (event.data === '') {
|
|
if (event.data === '') {
|
|
|
|
+ console.log(23223);
|
|
|
|
+
|
|
socket.close()
|
|
socket.close()
|
|
if (type.value === FunctionList.Intelligent_Form_filling) {
|
|
if (type.value === FunctionList.Intelligent_Form_filling) {
|
|
const formResult = obj.rawContent
|
|
const formResult = obj.rawContent
|
|
@@ -477,10 +501,9 @@ function createWS(msg) {
|
|
|
|
|
|
handleInput(xlsxData.value, form)
|
|
handleInput(xlsxData.value, form)
|
|
}
|
|
}
|
|
|
|
+ isShowPage.value = false
|
|
} else {
|
|
} else {
|
|
obj.rawContent += event.data;
|
|
obj.rawContent += event.data;
|
|
- console.log( obj.rawContent );
|
|
|
|
-
|
|
|
|
obj.content = obj.type === 'form' ? obj.rawContent : formatMessage(obj.rawContent);
|
|
obj.content = obj.type === 'form' ? obj.rawContent : formatMessage(obj.rawContent);
|
|
// 滚动到底部
|
|
// 滚动到底部
|
|
nextTick(() => {
|
|
nextTick(() => {
|
|
@@ -519,6 +542,10 @@ function createWS(msg) {
|
|
sendLoading.value = false;
|
|
sendLoading.value = false;
|
|
// 显示错误消息
|
|
// 显示错误消息
|
|
obj.content = '连接失败,请重试';
|
|
obj.content = '连接失败,请重试';
|
|
|
|
+ putChat({
|
|
|
|
+ ...obj,
|
|
|
|
+ content:''
|
|
|
|
+ });
|
|
} finally {
|
|
} finally {
|
|
|
|
|
|
}
|
|
}
|
|
@@ -537,11 +564,7 @@ const createFileObj = async (file) => {
|
|
handleUpload(file)
|
|
handleUpload(file)
|
|
}
|
|
}
|
|
const handleUpload = async (file) => {
|
|
const handleUpload = async (file) => {
|
|
- if (type.value === FunctionList.Intelligent_Form_filling) {
|
|
|
|
- pageInfoList.value = []
|
|
|
|
- }
|
|
|
|
- isShowPage.value = true
|
|
|
|
- const obj = reactive({
|
|
|
|
|
|
+ const obj = reactive({
|
|
title: file.name,
|
|
title: file.name,
|
|
state: '上传中...',
|
|
state: '上传中...',
|
|
favIconUrl: fileLogo,
|
|
favIconUrl: fileLogo,
|
|
@@ -553,6 +576,23 @@ const handleUpload = async (file) => {
|
|
mainContent: ''
|
|
mainContent: ''
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
+ if (type.value === FunctionList.Intelligent_Form_filling) {
|
|
|
|
+ pageInfoList.value = []
|
|
|
|
+ }
|
|
|
|
+ if (summaryHtml.value) obj.favIconUrl = htmlIcon.value
|
|
|
|
+ isShowPage.value = true
|
|
|
|
+ // const obj = reactive({
|
|
|
|
+ // title: file.name,
|
|
|
|
+ // state: '上传中...',
|
|
|
|
+ // favIconUrl: fileLogo,
|
|
|
|
+ // loading: true,
|
|
|
|
+ // url:'',
|
|
|
|
+ // fileId: '',
|
|
|
|
+ // redisKey:'',
|
|
|
|
+ // content: {
|
|
|
|
+ // mainContent: ''
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
pageInfoList.value = [obj]
|
|
pageInfoList.value = [obj]
|
|
try {
|
|
try {
|
|
let formData = new FormData()
|
|
let formData = new FormData()
|