|
@@ -8,11 +8,12 @@
|
|
<el-scrollbar v-else class="message-list" ref="scrollbar">
|
|
<el-scrollbar v-else class="message-list" ref="scrollbar">
|
|
<div class="messages">
|
|
<div class="messages">
|
|
<div v-for="(message, index) in messages" :key="index"
|
|
<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" />
|
|
<el-avatar :size="32" :src="message.avatar" />
|
|
<div class="message-content">
|
|
<div class="message-content">
|
|
<div class="content" v-if="!message.isSelf" :class="{ 'loading-content': message.content === '' }">
|
|
<div class="content" v-if="!message.isSelf" :class="{ 'loading-content': message.content === '' }">
|
|
- <span v-html="message.content"></span>
|
|
|
|
|
|
+ <formTable v-if="message.type === 'form'" :content="message.rawContent" />
|
|
|
|
+ <span v-else v-html="message.content"></span>
|
|
<span class="loading-indicator" v-if="sendLoading && index === messages.length - 1">
|
|
<span class="loading-indicator" v-if="sendLoading && index === messages.length - 1">
|
|
<span class="dot"></span>
|
|
<span class="dot"></span>
|
|
<span class="dot"></span>
|
|
<span class="dot"></span>
|
|
@@ -20,7 +21,7 @@
|
|
</span>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
<document v-else-if="message.type === 'document' && message.isSelf" :content="message.content"
|
|
<document v-else-if="message.type === 'document' && message.isSelf" :content="message.content"
|
|
- :rawContent="message.rawContent" />
|
|
|
|
|
|
+ :rawContent="message.rawContent" />
|
|
<div v-else class="content">
|
|
<div v-else class="content">
|
|
<span v-if="message.type === ''">{{ message.content }}</span>
|
|
<span v-if="message.type === ''">{{ message.content }}</span>
|
|
<span class="loading-indicator" v-if="sendLoading && index === messages.length - 1">
|
|
<span class="loading-indicator" v-if="sendLoading && index === messages.length - 1">
|
|
@@ -37,13 +38,9 @@
|
|
</div>
|
|
</div>
|
|
</el-scrollbar>
|
|
</el-scrollbar>
|
|
|
|
|
|
- <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>
|
|
<!-- 输入区域 -->
|
|
<!-- 输入区域 -->
|
|
@@ -51,7 +48,7 @@
|
|
<div v-show="isShowPage" style="border-bottom: 1px solid #F0F0F0;">
|
|
<div v-show="isShowPage" style="border-bottom: 1px solid #F0F0F0;">
|
|
<div class="card_list">
|
|
<div class="card_list">
|
|
<div v-for="(v,i) in pageInfoList" :key="i"
|
|
<div v-for="(v,i) in pageInfoList" :key="i"
|
|
- :class="`card-content ${pageInfoList.length > 1 ? 'card_width' : ''}`">
|
|
|
|
|
|
+ :class="`card-content ${pageInfoList.length > 1 ? 'card_width' : ''}`">
|
|
<img :src="v?.favIconUrl" style="width: 24px;display: block" />
|
|
<img :src="v?.favIconUrl" style="width: 24px;display: block" />
|
|
<div class="title-wrapper">
|
|
<div class="title-wrapper">
|
|
<span class="els title-scroller">{{ v?.title }}</span>
|
|
<span class="els title-scroller">{{ v?.title }}</span>
|
|
@@ -77,7 +74,7 @@
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<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 type="primary" link @click="handleAsk" :disabled="!inputMessage.trim() || sendLoading">
|
|
<el-button type="primary" link @click="handleAsk" :disabled="!inputMessage.trim() || sendLoading">
|
|
<el-icon size="18" :color="inputMessage.trim() ? 'black' : 'gray'">
|
|
<el-icon size="18" :color="inputMessage.trim() ? 'black' : 'gray'">
|
|
@@ -114,6 +111,8 @@ import Tools from '@/entrypoints/sidepanel/component/tools.vue'
|
|
import historyComponent from '@/entrypoints/sidepanel/component/historyComponent.vue'
|
|
import historyComponent from '@/entrypoints/sidepanel/component/historyComponent.vue'
|
|
import document from '@/entrypoints/sidepanel/component/document.vue'
|
|
import document from '@/entrypoints/sidepanel/component/document.vue'
|
|
import pageMask from '@/entrypoints/sidepanel/component/pageMask.vue'
|
|
import pageMask from '@/entrypoints/sidepanel/component/pageMask.vue'
|
|
|
|
+import formTable from '@/entrypoints/sidepanel/component/formTable.vue'
|
|
|
|
+
|
|
import { mockData, startMsg, mockData2, options, FunctionList } from '@/entrypoints/sidepanel/mock'
|
|
import { mockData, startMsg, mockData2, 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, getXlsxValue, handleInput } from './utils/index.js'
|
|
@@ -220,7 +219,7 @@ async function handelIntelligentFillingClick() {
|
|
taklToHtml.value = true
|
|
taklToHtml.value = true
|
|
const tempPageInfo = await getPageInfo()
|
|
const tempPageInfo = await getPageInfo()
|
|
pageInfo.value = tempPageInfo
|
|
pageInfo.value = tempPageInfo
|
|
- pageInfoList.value.unshift(tempPageInfo)
|
|
|
|
|
|
+ pageInfoList.value = [tempPageInfo]
|
|
inputMessage.value = '/智能填表 '
|
|
inputMessage.value = '/智能填表 '
|
|
type.value = FunctionList.Intelligent_Form_filling
|
|
type.value = FunctionList.Intelligent_Form_filling
|
|
}
|
|
}
|
|
@@ -273,6 +272,7 @@ function deletePageInfo(i) {
|
|
if (pageInfoList.value.length === 0) {
|
|
if (pageInfoList.value.length === 0) {
|
|
isShowPage.value = false
|
|
isShowPage.value = false
|
|
taklToHtml.value = false
|
|
taklToHtml.value = false
|
|
|
|
+ if (type.value === FunctionList.Intelligent_Form_filling) inputMessage.value = ''
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -297,12 +297,19 @@ async function handleAsk() {
|
|
keyPath: 'id'
|
|
keyPath: 'id'
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- addMessage(inputMessage.value.trim())
|
|
|
|
|
|
+ addMessage(str)
|
|
if (type.value === FunctionList.Intelligent_Form_filling) {
|
|
if (type.value === FunctionList.Intelligent_Form_filling) {
|
|
- const res = await fetchRes(inputMessage.value.trim())
|
|
|
|
|
|
+ const res = await fetchRes(str)
|
|
|
|
+ console.log(res);
|
|
|
|
+
|
|
if (res.status === 'ok') {
|
|
if (res.status === 'ok') {
|
|
formInfo.value = res.data
|
|
formInfo.value = res.data
|
|
console.log(res)
|
|
console.log(res)
|
|
|
|
+ } else {
|
|
|
|
+ type.value = FunctionList.File_Operation
|
|
|
|
+ isShowPage.value = false
|
|
|
|
+ taklToHtml.value = false
|
|
|
|
+ pageInfoList.value = []
|
|
}
|
|
}
|
|
} else streamRes(taklToHtml.value)
|
|
} else streamRes(taklToHtml.value)
|
|
inputMessage.value = ''
|
|
inputMessage.value = ''
|
|
@@ -342,18 +349,36 @@ const handleUpload = async (file) => {
|
|
xlsxData.value[header] = readData[1][i]
|
|
xlsxData.value[header] = readData[1][i]
|
|
})
|
|
})
|
|
addMessage(`已上传文件:${file.name}`, buildExcelUnderstandingPrompt(readData[0], file?.name, formInfo.value))
|
|
addMessage(`已上传文件:${file.name}`, buildExcelUnderstandingPrompt(readData[0], file?.name, formInfo.value))
|
|
- const a = await streamRes()
|
|
|
|
- console.log(a)
|
|
|
|
- handleInput(xlsxData.value, JSON.parse(a.split('json')[1].split('```')[0]))
|
|
|
|
|
|
+ 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)
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
- const { data, msg } = await getFileValue(file)
|
|
|
|
- const res2 = await getFormKeyAndValue(data, formInfo.value)
|
|
|
|
- xlsxData.value = res2.data
|
|
|
|
- msg.rawContent = buildObjPrompt(res2.data, formInfo.value)
|
|
|
|
- const a = await streamRes()
|
|
|
|
- handleInput(xlsxData.value, JSON.parse(a.split('json')[1].split('```')[0]))
|
|
|
|
|
|
+ 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)
|
|
|
|
+ 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)
|
|
|
|
+ }
|
|
|
|
+ } catch (error) {
|
|
|
|
+ msg.content = '文件解析出错'
|
|
|
|
+ } finally {
|
|
|
|
+ sendLoading.value = false
|
|
|
|
+ }
|
|
}
|
|
}
|
|
type.value = FunctionList.File_Operation
|
|
type.value = FunctionList.File_Operation
|
|
|
|
+ isShowPage.value = false
|
|
|
|
+ taklToHtml.value = false
|
|
|
|
+ pageInfoList.value = []
|
|
return
|
|
return
|
|
}
|
|
}
|
|
if (type.value === FunctionList.File_Operation) {
|
|
if (type.value === FunctionList.File_Operation) {
|