|
@@ -9,7 +9,7 @@
|
|
|
<el-scrollbar ref="scrollbar" @scroll="handleScroll">
|
|
|
<div class="messages">
|
|
|
<div v-for="(message, index) in messages" :key="index"
|
|
|
- :class="['message-item', message.isSelf ? 'self' : 'other']">
|
|
|
+ :class="['message-item', message.isSelf ? 'self' : 'other']">
|
|
|
<el-avatar :size="32" :src="message.avatar" />
|
|
|
<div class="message-content">
|
|
|
<div class="content" v-if="!message.isSelf" :class="{ 'loading-content': message.content === '' }">
|
|
@@ -22,14 +22,14 @@
|
|
|
</span>
|
|
|
</div>
|
|
|
<document v-else-if="message.type === 'document' && message.isSelf" :content="message.content"
|
|
|
- :rawContent="message.rawContent" />
|
|
|
+ :rawContent="message.rawContent" />
|
|
|
<div v-else class="content">
|
|
|
<span v-if="message.type === ''">{{ message.content }}</span>
|
|
|
<span class="loading-indicator" v-if="sendLoading && index === messages.length - 1">
|
|
|
- <span class="dot"></span>
|
|
|
- <span class="dot"></span>
|
|
|
- <span class="dot"></span>
|
|
|
- </span>
|
|
|
+ <span class="dot"></span>
|
|
|
+ <span class="dot"></span>
|
|
|
+ <span class="dot"></span>
|
|
|
+ </span>
|
|
|
</div>
|
|
|
<div class="timestamp ">{{ moment(message.timestamp).format('MM-DD HH:mm') }}
|
|
|
<span v-if="message.add" style="cursor: pointer;" @click="handleInput">填充</span>
|
|
@@ -41,21 +41,17 @@
|
|
|
<ScrollToBottom :target="scrollbar" ref="scrollToBottomRef" />
|
|
|
</div>
|
|
|
|
|
|
- <Tools @read-click="readClick"
|
|
|
- @upload-file="handleUpload"
|
|
|
- @handle-capture="handleCapture"
|
|
|
- @his-records="hisRecords"
|
|
|
- @add-new-dialogue="addNewDialogue"
|
|
|
- @handle-current-change="handleCurrentChange"
|
|
|
- @handel-intelligent-filling-click="handelIntelligentFillingClick" />
|
|
|
+ <Tools @read-click="readClick" @upload-file="handleUpload" @handle-capture="handleCapture" @his-records="hisRecords"
|
|
|
+ @add-new-dialogue="addNewDialogue" @handle-current-change="handleCurrentChange"
|
|
|
+ @handel-intelligent-filling-click="handelIntelligentFillingClick" />
|
|
|
|
|
|
<div>
|
|
|
<!-- 输入区域 -->
|
|
|
<div class="input-area">
|
|
|
<div v-show="isShowPage" style="border-bottom: 1px solid #F0F0F0;">
|
|
|
<div class="card_list">
|
|
|
- <div v-for="(v,i) in pageInfoList" :key="i"
|
|
|
- :class="`card-content ${pageInfoList.length > 1 ? 'card_width' : ''}`">
|
|
|
+ <div v-for="(v, i) in pageInfoList" :key="i"
|
|
|
+ :class="`card-content ${pageInfoList.length > 1 ? 'card_width' : ''}`">
|
|
|
<img :src="v?.favIconUrl" style="width: 24px;display: block" />
|
|
|
<div class="title-wrapper">
|
|
|
<span class="els title-scroller">{{ v?.title }}</span>
|
|
@@ -75,7 +71,7 @@
|
|
|
</div>
|
|
|
|
|
|
<el-input ref="textareaRef" v-model="inputMessage" type="textarea" :rows="3" placeholder="输入消息..."
|
|
|
- @keyup.enter="handleAsk" />
|
|
|
+ @keyup.enter="handleAsk" />
|
|
|
<div class="chat_area_op">
|
|
|
<el-button
|
|
|
:style="`background-color:${inputMessage.trim() ? '#4d6bfe' : '#d6dee8'};border-color:${inputMessage.trim() ? '#4d6bfe' : '#d6dee8'}`"
|
|
@@ -84,7 +80,7 @@
|
|
|
<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
|
|
|
- @click="handleStopAsk">
|
|
|
+ @click="handleStopAsk">
|
|
|
<svg-icon icon-class="stop" color="red" />
|
|
|
</el-button>
|
|
|
|
|
@@ -95,7 +91,7 @@
|
|
|
|
|
|
|
|
|
<!-- 历史记录 -->
|
|
|
- <historyComponent :msgUuid="msgUuid" ref="historyComponentRef" @currentData="(e)=>handleCurrentData(e)" />
|
|
|
+ <historyComponent :msgUuid="msgUuid" ref="historyComponentRef" @currentData="(e) => handleCurrentData(e)" />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -181,7 +177,7 @@ function handleScroll({ scrollTop }) {
|
|
|
* **/
|
|
|
async function addMessage(msg, raw, type) {
|
|
|
console.log(msg);
|
|
|
-
|
|
|
+
|
|
|
// 添加indexDB Store配置
|
|
|
if (msgUuid.value === '') {
|
|
|
msgUuid.value = 'D' + Date.now().toString()
|
|
@@ -343,14 +339,14 @@ async function handleAsk() {
|
|
|
const str = inputMessage.value.trim()
|
|
|
inputMessage.value = ''
|
|
|
if (sendLoading.value) return
|
|
|
- await addMessage(str)
|
|
|
+ await addMessage(str)
|
|
|
if (type.value === FunctionList.Intelligent_Form_filling) {
|
|
|
const res = await fetchRes(str)
|
|
|
console.log(res);
|
|
|
|
|
|
if (res.status === 'ok') {
|
|
|
formInfo.value = res.data
|
|
|
- console.log(res,55558)
|
|
|
+ console.log(res, 55558)
|
|
|
} else {
|
|
|
type.value = FunctionList.File_Operation
|
|
|
isShowPage.value = false
|
|
@@ -394,36 +390,36 @@ const handleUpload = async (file) => {
|
|
|
xlsxData.value[header] = readData[1][i]
|
|
|
})
|
|
|
addMessage(`已上传文件:${file.name}`, buildExcelUnderstandingPrompt(readData[0], file?.name, formInfo.value))
|
|
|
- const {rawContent,status} = await streamRes()
|
|
|
- if (status === 'ok') {
|
|
|
+ const { rawContent, status } = await streamRes()
|
|
|
+ if (status === 'ok') {
|
|
|
let form = []
|
|
|
- if (rawContent.includes('json')) form = JSON.parse(rawContent.split('json')[1].split('```')[0])
|
|
|
- else form = JSON.parse(rawContent)
|
|
|
- handleInput(xlsxData.value, form)
|
|
|
- }
|
|
|
+ if (rawContent.includes('json')) form = JSON.parse(rawContent.split('json')[1].split('```')[0])
|
|
|
+ else form = JSON.parse(rawContent)
|
|
|
+ handleInput(xlsxData.value, form)
|
|
|
+ }
|
|
|
} else {
|
|
|
- try {
|
|
|
- const { data, msg } = await getFileValue(file)
|
|
|
- const res2 = await getFormKeyAndValue(data, formInfo.value)
|
|
|
- xlsxData.value = res2.data
|
|
|
- msg.rawContent = buildObjPrompt(res2.data, formInfo.value)
|
|
|
- console.log(msg.rawContent);
|
|
|
- console.log(messages);
|
|
|
-
|
|
|
- const { rawContent, status } = await streamRes()
|
|
|
- console.log(22555);
|
|
|
-
|
|
|
- if (status === 'ok') {
|
|
|
- let form = []
|
|
|
- if (rawContent.includes('json')) form = JSON.parse(rawContent.split('json')[1].split('```')[0])
|
|
|
- else form = JSON.parse(rawContent)
|
|
|
- handleInput(xlsxData.value, form)
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- msg.content = '文件解析出错'
|
|
|
- } finally {
|
|
|
- sendLoading.value = false
|
|
|
- }
|
|
|
+ try {
|
|
|
+ const { data, msg } = await getFileValue(file)
|
|
|
+ const res2 = await getFormKeyAndValue(data, formInfo.value)
|
|
|
+ xlsxData.value = res2.data
|
|
|
+ msg.rawContent = buildObjPrompt(res2.data, formInfo.value)
|
|
|
+ console.log(msg.rawContent);
|
|
|
+ console.log(messages);
|
|
|
+
|
|
|
+ const { rawContent, status } = await streamRes()
|
|
|
+ console.log(22555);
|
|
|
+
|
|
|
+ if (status === 'ok') {
|
|
|
+ let form = []
|
|
|
+ if (rawContent.includes('json')) form = JSON.parse(rawContent.split('json')[1].split('```')[0])
|
|
|
+ else form = JSON.parse(rawContent)
|
|
|
+ handleInput(xlsxData.value, form)
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ msg.content = '文件解析出错'
|
|
|
+ } finally {
|
|
|
+ sendLoading.value = false
|
|
|
+ }
|
|
|
}
|
|
|
type.value = FunctionList.File_Operation
|
|
|
isShowPage.value = false
|
|
@@ -449,18 +445,18 @@ const handleUpload = async (file) => {
|
|
|
|
|
|
async function getFileValue(file) {
|
|
|
const msg = await addMessage(`文件上传中`)
|
|
|
- console.log(msg,messages);
|
|
|
-
|
|
|
+ console.log(msg, messages);
|
|
|
+
|
|
|
sendLoading.value = true
|
|
|
let formData = new FormData()
|
|
|
formData.append('file', file)
|
|
|
const res = await getFileContent(formData)
|
|
|
- console.log(res,5555);
|
|
|
-
|
|
|
+ console.log(res, 5555);
|
|
|
+
|
|
|
sendLoading.value = false
|
|
|
msg.content = `已上传文件:${file.name}`
|
|
|
console.log(msg.content);
|
|
|
-
|
|
|
+
|
|
|
msg.rawContent = res.data
|
|
|
return {
|
|
|
data: res.data,
|