diff --git a/package-lock.json b/package-lock.json
index 218dd9c..6618580 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -35,6 +35,7 @@
"mermaid-it-markdown": "^1.0.8",
"nprogress": "^0.2.0",
"pinia": "^2.1.7",
+ "vditor": "^3.11.0",
"vue": "^3.4.5",
"vue-cropper": "1.1.1",
"vue-cropperjs": "^5.0.0",
@@ -2287,6 +2288,11 @@
"node": ">=0.3.1"
}
},
+ "node_modules/diff-match-patch": {
+ "version": "1.0.5",
+ "resolved": "https://registry.npmjs.org/diff-match-patch/-/diff-match-patch-1.0.5.tgz",
+ "integrity": "sha512-IayShXAgj/QMXgB0IWmKx+rOPuGMhqm5w6jvFxmVenXKIzRqTAAsbBPT3kWQeGANj3jGgvcvv4yK6SxqYmikgw=="
+ },
"node_modules/dom7": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/dom7/-/dom7-3.0.0.tgz",
@@ -5222,6 +5228,17 @@
"node": ">=8"
}
},
+ "node_modules/vditor": {
+ "version": "3.11.0",
+ "resolved": "https://registry.npmjs.org/vditor/-/vditor-3.11.0.tgz",
+ "integrity": "sha512-UfucKF2wstR6w92RG8BOMjbfbE241qP9qIb5i5J64vHTVdWzkWhv6DFNsKe6THBiD+RKQdeQMorCW1uDgoHaMw==",
+ "dependencies": {
+ "diff-match-patch": "^1.0.5"
+ },
+ "funding": {
+ "url": "https://ld246.com/sponsor"
+ }
+ },
"node_modules/vite": {
"version": "3.2.10",
"resolved": "https://registry.npmjs.org/vite/-/vite-3.2.10.tgz",
diff --git a/package.json b/package.json
index 59a1268..dc2d98c 100644
--- a/package.json
+++ b/package.json
@@ -35,6 +35,7 @@
"mermaid-it-markdown": "^1.0.8",
"nprogress": "^0.2.0",
"pinia": "^2.1.7",
+ "vditor": "^3.11.0",
"vue": "^3.4.5",
"vue-cropper": "1.1.1",
"vue-cropperjs": "^5.0.0",
diff --git a/src/api/tool.ts b/src/api/tool.ts
index 78b3ca9..f2c395c 100644
--- a/src/api/tool.ts
+++ b/src/api/tool.ts
@@ -59,4 +59,17 @@ export const GetDashBoardStatisticsService = (Data) => {
'token': Data.token,
}
})
+}
+
+export const SetMessageTextToDocService = (Data) => {
+ const params = new URLSearchParams();
+ for (let key in Data) {
+ params.append(key, Data[key])
+ }
+ //let request1 = getRequest();
+ return request.post('/tool/text_to_docx', params,{
+ headers: {
+ 'token': Data.token,
+ }
+ })
}
\ No newline at end of file
diff --git a/src/views/system/gen-chat.vue b/src/views/system/gen-chat.vue
index c2e0565..eb510c8 100644
--- a/src/views/system/gen-chat.vue
+++ b/src/views/system/gen-chat.vue
@@ -63,11 +63,26 @@
+
+
+
+
+
+
+
@@ -171,7 +186,7 @@
-
+
-
+
+
+
+
+
+
+
+
+ 输入文件名
+
+
+
+
+
+
+
+
+
+
+ 确认
+ 取消
+
+
@@ -279,8 +323,9 @@ import { Model } from "@/types/model";
import { File, fileUrl } from "@/types/file";
import { Session } from "@/types/session";
import { FindSessionService } from "@/api/session";
+import { SetMessageTextToDocService } from "@/api/tool";
import { ElMessage } from "element-plus";
-import { Check, DocumentCopy } from "@element-plus/icons-vue";
+import { Check, DocumentCopy,Document } from "@element-plus/icons-vue";
import MarkdownIt from "markdown-it";
import hljs from "highlight.js";
import UploadFile from "@/components/upload-file.vue";
@@ -289,6 +334,10 @@ import markdownItHighlightjs from "markdown-it-highlightjs";
import markdownItKatex from "markdown-it-katex";
import mermaidPlugin from "@agoose77/markdown-it-mermaid";
import "katex/dist/katex.min.css";
+import Vditor from 'vditor'
+import 'vditor/dist/index.css';
+
+
interface Message {
role: "user" | "assistant";
content: string;
@@ -350,6 +399,13 @@ const selectFileVisible = ref(false); // 控制文件选择对话框的显示与
const searchFileQuery = ref(""); // 用于搜索文件的查询条件
const filteredFiles = ref([]); // 用于存储过滤后的文件列表
const uploadFileVisible = ref(false); // 控制上传文件对话框的显示与隐藏
+const textToDocFileVisible = ref(false); // 控制文本创建文件对话框的显示与隐藏
+const selectFileDocType = ref("docx"); // 选择的文本类型
+const textToDocFileName = ref(""); // 文本创建文件的名称
+const textToDocFileContent = ref(""); // 文本创建文件的内容
+const vditor = ref(); // Vditor 实例
+
+
const historyMsgHtml= ref([]); // 用于存储历史消息的HTML内容
const wssUrl =
"wss://pm.ljsea.top/im/ai_chat_ws?" +
@@ -401,6 +457,11 @@ const handleUploadFileClose = async () => {
console.log("handleUploadFileClose:", uploadFileVisible.value);
};
+const handleMessageTextToDOCClose = async () => {
+ textToDocFileVisible.value = false; // 关闭文本创建文件对话框
+};
+
+
const handleUploadPicture = () => {
// 处理上传图片的逻辑
//选择图片并上传
@@ -881,6 +942,20 @@ const getMessageWithFile = async (session_id: number) => {
};
+const MessageTextToDoc = async (content: string) => {
+
+ textToDocFileContent.value = content;
+ vditor.value = new Vditor('vditor', {
+ mode: 'sv',
+ height: '600px',
+ width: '100%',
+ cache: { enable: false },
+ value: textToDocFileContent.value,
+ });
+ textToDocFileVisible.value = true;
+};
+
+
const copyMessage = (content: string) => {
navigator.clipboard
.writeText(content)
@@ -925,6 +1000,26 @@ const getFileListData = async () => {
ElMessage.error(result["msg"]);
}
};
+
+
+const HandleTextToDocFile = async () => {
+ // 处理文本创建文件的逻辑
+ //console.log("文本创建文件:", textToDocFileName.value, vditor.value.getValue(), selectFileDocType.value);
+ let req = {
+ token: localStorage.getItem("token"),
+ file_name: textToDocFileName.value,
+ text: vditor.value.getValue(),
+ file_type: selectFileDocType.value,
+ };
+ let result = await SetMessageTextToDocService(req);
+ if (result["code"] === 0) {
+ ElMessage.success("文件已加入创建队列,请等待一段时间后可在你的文件中查看!");
+ textToDocFileVisible.value = false;
+ } else {
+ ElMessage.error(result["msg"]);
+ }
+};
+