|
|
@@ -11,15 +11,18 @@
|
|
|
<p>{{ open }}</p>
|
|
|
</footer>
|
|
|
</div>
|
|
|
- <div class="section-suggestions">
|
|
|
+
|
|
|
+ <!-- <div class="section-suggestions">
|
|
|
<div :class="['section-suggestion', readonly ? 'disabled' : '']" v-for="(suggestion, key) in suggestions"
|
|
|
:key="key" @click="selectSuggestion(suggestion)">
|
|
|
{{ suggestion }}<icon-arrow-right />
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ </div> -->
|
|
|
+
|
|
|
+ <Suggestion :suggestions="suggestions" :readonly="readonly"/>
|
|
|
|
|
|
<div class="dialog-list" v-if="dialogList.length > 0" :key="randomKey">
|
|
|
- <div :class="['dialog-item', isSetting ? '' : 'dialog-absolute']" v-for="(item, key) in dialogList"
|
|
|
+ <div :class="['dialog-item', isSetting ? '' : 'dialog-absolute', 'dialog-item-' + key]" v-for="(item, key) in dialogList"
|
|
|
:key="item.key" :data-item-index="key">
|
|
|
<div class="dialog-header" v-if="item?.question">
|
|
|
<div class="user-name" style="background-color: rgb(255, 110, 110)">
|
|
|
@@ -179,7 +182,7 @@
|
|
|
<span>{{ item.other.token }}</span>
|
|
|
</p>
|
|
|
<p v-else></p>
|
|
|
- <div>
|
|
|
+ <div v-if="show_info_btns">
|
|
|
<a-tooltip content="重新生成">
|
|
|
<p @click="reQuestion(item.question)" :class="[readonly ? 'disabled' : '']">
|
|
|
<img src="@/assets/icons/refresh.png" width="15" />
|
|
|
@@ -228,15 +231,30 @@ import { defineComponent, ref, onBeforeUnmount, onMounted, reactive, nextTick, i
|
|
|
|
|
|
import formatAnwserString from './refference-effect/format-anwser-string';
|
|
|
import applyRefferencePopover from './refference-effect/apply-refference-popover';
|
|
|
+import applyImageDisplay from './refference-effect/apply-image-display';
|
|
|
import initTempHistory, {getChatIdFromUrl} from './refference-effect/temp-history';
|
|
|
|
|
|
import { getDocumentUrl } from '../ajax/document';
|
|
|
|
|
|
+import Suggestion from './dialog-wrap/Suggestion.vue';
|
|
|
+
|
|
|
export default defineComponent({
|
|
|
components: {
|
|
|
- DialogFeedback
|
|
|
+ DialogFeedback,
|
|
|
+
|
|
|
+ Suggestion
|
|
|
},
|
|
|
- props: ["open", "suggestions", "isSetting", "readonly", "type", "list", "agentId", "dialogId", 'reference'],
|
|
|
+ props: [
|
|
|
+ "open",
|
|
|
+ "suggestions",
|
|
|
+ "isSetting",
|
|
|
+ "readonly",
|
|
|
+ "type",
|
|
|
+ "list",
|
|
|
+ "agentId",
|
|
|
+ "dialogId",
|
|
|
+ 'reference'
|
|
|
+ ],
|
|
|
setup(props, { emit }) {
|
|
|
const knowledgeList = ref([[{}]]);
|
|
|
const DOCUMENT_RESULT = {};
|
|
|
@@ -252,6 +270,8 @@ export default defineComponent({
|
|
|
const { helper, ajax } = inject("$global");
|
|
|
const userName = ref(helper.read("userName") || "");
|
|
|
|
|
|
+ const show_info_btns = ref(false);
|
|
|
+
|
|
|
/**
|
|
|
* 初始化临时历史记录
|
|
|
* 在对话过程中,消息记录是一条一条的呈现
|
|
|
@@ -343,11 +363,11 @@ export default defineComponent({
|
|
|
const handleCancel = () => {
|
|
|
showFeedback.value = false;
|
|
|
};
|
|
|
- const selectSuggestion = (text) => {
|
|
|
- if (!props.readonly) {
|
|
|
+ // const selectSuggestion = (text) => {
|
|
|
+ // if (!props.readonly) {
|
|
|
|
|
|
- }
|
|
|
- };
|
|
|
+ // }
|
|
|
+ // };
|
|
|
|
|
|
const copyAnswer = (text) => {
|
|
|
if (!props.readonly) {
|
|
|
@@ -435,7 +455,7 @@ export default defineComponent({
|
|
|
helper.$bus.off("send-message");
|
|
|
helper.$bus.off("clear-message");
|
|
|
helper.$bus.off("stop-writing");
|
|
|
- helper.webSocket.close();
|
|
|
+ helper.webSocket?.close();
|
|
|
});
|
|
|
|
|
|
onMounted(() => {
|
|
|
@@ -445,9 +465,14 @@ export default defineComponent({
|
|
|
* 答案中 引用图标(感叹号)点击时,浮层显示引用内容
|
|
|
*/
|
|
|
applyRefferencePopover(props.list);
|
|
|
+ applyImageDisplay(props.list);
|
|
|
|
|
|
- // socket 消息队列
|
|
|
- // TODO: 只允许保存一条消息
|
|
|
+ /**
|
|
|
+ * TODO: 只允许保存一条消息,避免出现多条消息同时发送的情况
|
|
|
+ * 当网络状况不佳,用户发送第一条数据时,socket还未连接成功,紧接着又发送第二条数据,第三条数据....
|
|
|
+ * 此时,消息队列里将会有多条数据等待发送
|
|
|
+ * 当socket连接成功后,遍历消息队列里的数据,会将这多条数据一同发送,此时就会出现异常情况。
|
|
|
+ */
|
|
|
let msg_list = [];
|
|
|
|
|
|
function createSocket() {
|
|
|
@@ -501,20 +526,14 @@ export default defineComponent({
|
|
|
// 创建socket链接
|
|
|
createSocket();
|
|
|
|
|
|
- helper.webSocket.onmessage = (event) => {
|
|
|
- /**
|
|
|
- * 例如:ws://localhost/api/chat/ws/42e4fcdc9bea11efac300242ac160006/765f672c700f49b79a473fc906fe388c?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyIiwidXNlcl9pZCI6MjEsImV4cCI6MTczMjQzNzkzNH0.7SPOZpnaTUu2KPzWIJrhhkRehjePeuL8TABo7rNgnCY
|
|
|
- */
|
|
|
- const socket_url = event.target.url; // socket连接地址
|
|
|
- const cur_chat_id = getChatIdFromUrl(socket_url);
|
|
|
-
|
|
|
- // setTempHistory(event);
|
|
|
- tempHistory.setHistory(event);
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 处理socket数据
|
|
|
+ */
|
|
|
+ function handleSocketMessage(evt_dt, cur_chat_id){
|
|
|
let res_data = null;
|
|
|
|
|
|
try{
|
|
|
- res_data = JSON.parse(event.data);
|
|
|
+ res_data = JSON.parse(evt_dt);
|
|
|
}catch(err){
|
|
|
console.log(err);
|
|
|
}
|
|
|
@@ -576,7 +595,7 @@ export default defineComponent({
|
|
|
if (props.type == 'smartData') {
|
|
|
answerData.value = '正在处理中...'
|
|
|
// 以下是智能数据对话的变量
|
|
|
- const { image_url, excel_url, excel_name, code, sql } = JSON.parse(event.data);
|
|
|
+ const { image_url, excel_url, excel_name, code, sql } = JSON.parse(evt_dt);
|
|
|
const port = window.location.port ? `:${window.location.port}` : '';
|
|
|
|
|
|
// 如果有图片或excel,则更新图片或excel地址
|
|
|
@@ -600,7 +619,7 @@ export default defineComponent({
|
|
|
}
|
|
|
// 出题
|
|
|
if (props.type == 'question') {
|
|
|
- const { file_url, file_name } = JSON.parse(event.data);
|
|
|
+ const { file_url, file_name } = JSON.parse(evt_dt);
|
|
|
const port = window.location.port ? `:${window.location.port}` : '';
|
|
|
|
|
|
if (file_url) {
|
|
|
@@ -634,6 +653,24 @@ export default defineComponent({
|
|
|
// 获取所有的临时历史记录
|
|
|
const full_history = tempHistory.getHistory();
|
|
|
applyRefferencePopover(full_history);
|
|
|
+ const current_index = tempHistory.getChatIndex(cur_chat_id);
|
|
|
+ applyImageDisplay(full_history, current_index);
|
|
|
+ }
|
|
|
+
|
|
|
+ helper.webSocket.onmessage = (event) => {
|
|
|
+ const evt_dt = event.data;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 例如:ws://localhost/api/chat/ws/42e4fcdc9bea11efac300242ac160006/765f672c700f49b79a473fc906fe388c?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyIiwidXNlcl9pZCI6MjEsImV4cCI6MTczMjQzNzkzNH0.7SPOZpnaTUu2KPzWIJrhhkRehjePeuL8TABo7rNgnCY
|
|
|
+ */
|
|
|
+ const socket_url = event.target.url; // socket连接地址
|
|
|
+ const cur_chat_id = getChatIdFromUrl(socket_url);
|
|
|
+
|
|
|
+ // setTempHistory(event);
|
|
|
+ tempHistory.setHistory(event);
|
|
|
+
|
|
|
+ // 处理socket数据
|
|
|
+ handleSocketMessage(evt_dt, cur_chat_id);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
@@ -656,6 +693,21 @@ export default defineComponent({
|
|
|
sendData.doc_ids = [helper.read('docId')];
|
|
|
}
|
|
|
|
|
|
+ // 小数绘图
|
|
|
+ if(props.type === 'huitu'){
|
|
|
+ const img_file = helper.read('sendData');
|
|
|
+ const upload_file_id = img_file.upload_file_id;
|
|
|
+
|
|
|
+ sendData = {
|
|
|
+ message: value,
|
|
|
+ upload_file_id: upload_file_id
|
|
|
+ }
|
|
|
+
|
|
|
+ setTimeout(() => {
|
|
|
+ helper.write('sendData', {});
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
const dt = JSON.stringify(sendData);
|
|
|
|
|
|
// 发送socket数据
|
|
|
@@ -681,7 +733,7 @@ export default defineComponent({
|
|
|
copyAnswer,
|
|
|
dialogList,
|
|
|
getHTML,
|
|
|
- selectSuggestion,
|
|
|
+ // selectSuggestion,
|
|
|
dialogScroll,
|
|
|
reQuestion,
|
|
|
menuList,
|
|
|
@@ -697,7 +749,9 @@ export default defineComponent({
|
|
|
downloadFile,
|
|
|
|
|
|
openDocument,
|
|
|
- openDocuementPage
|
|
|
+ openDocuementPage,
|
|
|
+
|
|
|
+ show_info_btns
|
|
|
};
|
|
|
}
|
|
|
});
|
|
|
@@ -1255,6 +1309,7 @@ export default defineComponent({
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
.section-suggestions {
|
|
|
margin: 12px 0 20px;
|
|
|
|
|
|
@@ -1280,6 +1335,7 @@ export default defineComponent({
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ */
|
|
|
|
|
|
.dialog-other {
|
|
|
margin-bottom: 16px;
|