|
@@ -5,63 +5,13 @@ import generateClientUniqueId from '../../utils/generate-client-unique-id';
|
|
|
import { getIcon4Answer } from './get-icon-4-dialog';
|
|
import { getIcon4Answer } from './get-icon-4-dialog';
|
|
|
|
|
|
|
|
import formatAnwserString from './format-anwser-string';
|
|
import formatAnwserString from './format-anwser-string';
|
|
|
|
|
+import { formatStaticAssetsUrl } from '../../utils/utils';
|
|
|
|
|
|
|
|
-/**
|
|
|
|
|
- * 格式化文档引用的数据
|
|
|
|
|
- * 将对象转换为字符串
|
|
|
|
|
- * @param {object} refference
|
|
|
|
|
- * @param {string} field_key - 数据中的相关字段
|
|
|
|
|
- */
|
|
|
|
|
-function formatRefferenceString(refference, field_key) {
|
|
|
|
|
- if (!refference) {
|
|
|
|
|
- return '';
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- const doc_aggs = refference.doc_aggs;
|
|
|
|
|
-
|
|
|
|
|
- if (!doc_aggs) {
|
|
|
|
|
- return '';
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- const refs_markdown = [];
|
|
|
|
|
- if (Array.isArray(doc_aggs)) {
|
|
|
|
|
- doc_aggs.forEach((item, index) => {
|
|
|
|
|
- refs_markdown.push(
|
|
|
|
|
- `<li
|
|
|
|
|
- class="client-formated-markdown-element-item client-formated-markdown-doc-refference-item"
|
|
|
|
|
- data-doc-id="${item.doc_id}"
|
|
|
|
|
- data-real-index="${index}"
|
|
|
|
|
- data-ref-key="${field_key}"
|
|
|
|
|
- >
|
|
|
|
|
- <span class="refference-index">${index + 1}</span>
|
|
|
|
|
- <span class="refference-label">${item.doc_name}</span>
|
|
|
|
|
- </li>`
|
|
|
|
|
- );
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- const li_str = refs_markdown.join('');
|
|
|
|
|
-
|
|
|
|
|
- return `<ul class="client-formated-markdown-element-item client-formated-markdown-doc-refference-container" data-ref-key="${field_key}">${li_str}</ul>`;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-function formatRefferenceFlag(answer) {
|
|
|
|
|
- let cur_text = answer;
|
|
|
|
|
-
|
|
|
|
|
- cur_text = cur_text.replace(/##\d\$\$/g, function (match, index, full) {
|
|
|
|
|
- // console.log(match, index, full);
|
|
|
|
|
- // match示例数据 ##1$$ ##2$$
|
|
|
|
|
- // 通过两次替换,字符串只剩下序号
|
|
|
|
|
- const match_v1 = match.replace('##', '');
|
|
|
|
|
- const match_v2 = match_v1.replace('$$', '');
|
|
|
|
|
-
|
|
|
|
|
- const ref_idx = match_v2;
|
|
|
|
|
-
|
|
|
|
|
- return `<span class="client-formated-markdown-element-item client-formated-markdown-doc-refference-flag" data-ref-index="${ref_idx}"></span>`;
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- return cur_text;
|
|
|
|
|
-}
|
|
|
|
|
|
|
+import {
|
|
|
|
|
+ formatRefferenceString,
|
|
|
|
|
+ formatRefferenceFlag,
|
|
|
|
|
+ formatFileDownloadStr
|
|
|
|
|
+} from './format-dialog-answer-custom-markdown-str';
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 格式化websocket发送消息的参数
|
|
* 格式化websocket发送消息的参数
|
|
@@ -101,6 +51,16 @@ export default function formatDialogAnswerFromWebsocketReceiveMessage(message_st
|
|
|
const resCode = res_content.code; // 代码内容
|
|
const resCode = res_content.code; // 代码内容
|
|
|
const resSQL = res_content.sql; // SQL内容
|
|
const resSQL = res_content.sql; // SQL内容
|
|
|
|
|
|
|
|
|
|
+ // 文档出卷返回的数据
|
|
|
|
|
+ // 需要进行文件下载
|
|
|
|
|
+ // file_name: "76157b5884554a56bf3ed27990d44f97_1734603024"
|
|
|
|
|
+ // file_url: "/api/files/download/?agent_id=basic_question_talk&file_id=76157b5884554a56bf3ed27990d44f97_1734603024&file_type=word"
|
|
|
|
|
+ // message: "已经为您生成了10道中等难度的选择题,并已将这些题目保存到名为76157b5884554a56bf3ed27990d44f97_1734603024的docx文件中。希望这些题目符合您的需求!如果有其他要求,请随时告知。"
|
|
|
|
|
+ // type: "message"
|
|
|
|
|
+ // ------------------------------------
|
|
|
|
|
+
|
|
|
|
|
+ // 报表合并返回的数据:需要进行文件下载
|
|
|
|
|
+
|
|
|
// 本次对话的消息内容
|
|
// 本次对话的消息内容
|
|
|
const currentMsg = {
|
|
const currentMsg = {
|
|
|
/**
|
|
/**
|
|
@@ -162,42 +122,70 @@ export default function formatDialogAnswerFromWebsocketReceiveMessage(message_st
|
|
|
|
|
|
|
|
if (resExcelUrl && resExcelName) {
|
|
if (resExcelUrl && resExcelName) {
|
|
|
// 智能数据需要用到的值
|
|
// 智能数据需要用到的值
|
|
|
- const port = window.location.port ? `:${window.location.port}` : '';
|
|
|
|
|
|
|
+ // const port = window.location.port ? `:${window.location.port}` : '';
|
|
|
|
|
|
|
|
- const file = {
|
|
|
|
|
- file_type: 'excel',
|
|
|
|
|
- file_url: `http://${window.location.hostname}${port}${resExcelUrl}`,
|
|
|
|
|
- file_name: `${resExcelName}.xlsx` || '点击下载'
|
|
|
|
|
|
|
+ // const file = {
|
|
|
|
|
+ // file_type: 'excel',
|
|
|
|
|
+ // file_url: `http://${window.location.hostname}${port}${resExcelUrl}`,
|
|
|
|
|
+ // file_name: `${resExcelName}.xlsx` || '点击下载'
|
|
|
|
|
+ // };
|
|
|
|
|
+
|
|
|
|
|
+ // currentMsg.file = file;
|
|
|
|
|
+
|
|
|
|
|
+ currentMsg.client_custom_linked_download_files = {
|
|
|
|
|
+ file_name: resExcelName,
|
|
|
|
|
+ file_url: resExcelUrl
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- currentMsg.file = file;
|
|
|
|
|
|
|
+ // const download_file_str = formatFileDownloadStr(resExcelName, resExcelUrl);
|
|
|
|
|
+
|
|
|
|
|
+ // currentMsg.answer = currentMsg.agentInfo + download_file_str;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (resFileUrl && resFileName) {
|
|
if (resFileUrl && resFileName) {
|
|
|
// 出题组卷可能存在此数据
|
|
// 出题组卷可能存在此数据
|
|
|
- const port = window.location.port ? `:${window.location.port}` : '';
|
|
|
|
|
|
|
+ // const port = window.location.port ? `:${window.location.port}` : '';
|
|
|
|
|
+
|
|
|
|
|
+ // const file = {
|
|
|
|
|
+ // file_type: 'word',
|
|
|
|
|
+ // file_url: `http://${window.location.hostname}${port}${resFileUrl}`,
|
|
|
|
|
+ // file_name: `${resFileName}.docx` || '点击下载'
|
|
|
|
|
+ // };
|
|
|
|
|
|
|
|
- const file = {
|
|
|
|
|
- file_type: 'word',
|
|
|
|
|
- file_url: `http://${window.location.hostname}${port}${resFileUrl}`,
|
|
|
|
|
- file_name: `${resFileName}.docx` || '点击下载'
|
|
|
|
|
|
|
+ // currentMsg.file = file;
|
|
|
|
|
+
|
|
|
|
|
+ currentMsg.client_custom_linked_download_files = {
|
|
|
|
|
+ file_name: resFileName,
|
|
|
|
|
+ file_url: resFileUrl
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- currentMsg.file = file;
|
|
|
|
|
|
|
+ // const download_file_str = formatFileDownloadStr(resFileName, resFileUrl);
|
|
|
|
|
+
|
|
|
|
|
+ // currentMsg.answer = currentMsg.agentInfo + download_file_str;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (resDownloadUrl) {
|
|
if (resDownloadUrl) {
|
|
|
// 文档报告可能存在此数据(type document_report)
|
|
// 文档报告可能存在此数据(type document_report)
|
|
|
|
|
+ const real_url = decodeURIComponent(resDownloadUrl);
|
|
|
|
|
+
|
|
|
const file_url_arr = decodeURIComponent(resDownloadUrl).split('/');
|
|
const file_url_arr = decodeURIComponent(resDownloadUrl).split('/');
|
|
|
const file_name = file_url_arr[file_url_arr.length - 1];
|
|
const file_name = file_url_arr[file_url_arr.length - 1];
|
|
|
|
|
|
|
|
- const file = {
|
|
|
|
|
- file_type: 'word',
|
|
|
|
|
- file_url: resDownloadUrl,
|
|
|
|
|
- file_name: `${file_name}.docx` || '点击下载'
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ // const file = {
|
|
|
|
|
+ // file_type: 'word',
|
|
|
|
|
+ // file_url: resDownloadUrl,
|
|
|
|
|
+ // file_name: `${file_name}.docx` || '点击下载'
|
|
|
|
|
+ // };
|
|
|
|
|
+
|
|
|
|
|
+ // currentMsg.file = file;
|
|
|
|
|
|
|
|
- currentMsg.file = file;
|
|
|
|
|
|
|
+ // const download_file_str = formatFileDownloadStr(file_name, real_url);
|
|
|
|
|
+
|
|
|
|
|
+ // currentMsg.answer = currentMsg.agentInfo + download_file_str;
|
|
|
|
|
+ currentMsg.client_custom_linked_download_files = {
|
|
|
|
|
+ file_name: file_name,
|
|
|
|
|
+ file_url: real_url
|
|
|
|
|
+ };
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------
|
|
// -------------------------------------------------------------
|
|
@@ -278,27 +266,39 @@ export default function formatDialogAnswerFromWebsocketReceiveMessage(message_st
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (resFiles) {
|
|
if (resFiles) {
|
|
|
|
|
+ // 文档合并有此数据
|
|
|
const file_name = resFiles[0].file_name;
|
|
const file_name = resFiles[0].file_name;
|
|
|
- const file_info_arr = file_name.split('.');
|
|
|
|
|
- const end_fix = file_info_arr[file_info_arr.length - 1];
|
|
|
|
|
|
|
+ // const file_info_arr = file_name.split('.');
|
|
|
|
|
+ // const end_fix = file_info_arr[file_info_arr.length - 1];
|
|
|
|
|
+
|
|
|
|
|
+ // const file = {
|
|
|
|
|
+ // file_name: resFiles[0].file_name,
|
|
|
|
|
+ // file_url: resFiles[0].file_url
|
|
|
|
|
+ // };
|
|
|
|
|
+
|
|
|
|
|
+ // // 理论上报表合并,只能是 excel
|
|
|
|
|
+ // // if(chat_type === 'excel'){
|
|
|
|
|
+ // // file.file_type = 'excel'
|
|
|
|
|
+ // // }
|
|
|
|
|
+ // if (end_fix === 'xlsx') {
|
|
|
|
|
+ // file.file_type = 'excel';
|
|
|
|
|
+ // }
|
|
|
|
|
+ // if (end_fix === 'docx') {
|
|
|
|
|
+ // file.file_type = 'word';
|
|
|
|
|
+ // }
|
|
|
|
|
|
|
|
- const file = {
|
|
|
|
|
- file_name: resFiles[0].file_name,
|
|
|
|
|
- file_url: resFiles[0].file_url
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ // currentMsg.file = file;
|
|
|
|
|
|
|
|
- // 理论上报表合并,只能是 excel
|
|
|
|
|
- // if(chat_type === 'excel'){
|
|
|
|
|
- // file.file_type = 'excel'
|
|
|
|
|
- // }
|
|
|
|
|
- if (end_fix === 'xlsx') {
|
|
|
|
|
- file.file_type = 'excel';
|
|
|
|
|
- }
|
|
|
|
|
- if (end_fix === 'docx') {
|
|
|
|
|
- file.file_type = 'word';
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (resFiles[0]) {
|
|
|
|
|
+ // console.log('报表合并,所有文件', resFiles);
|
|
|
|
|
+ // const download_file_str = formatFileDownloadStr(resFiles[0].file_name, resFiles[0].file_url);
|
|
|
|
|
+ // console.log('报表合并,所有文件', download_file_str);
|
|
|
|
|
|
|
|
- currentMsg.file = file;
|
|
|
|
|
|
|
+ currentMsg.client_custom_linked_download_files = {
|
|
|
|
|
+ file_name: resFiles[0].file_name,
|
|
|
|
|
+ file_url: resFiles[0].file_url
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|