Compare commits

...

3 Commits

7 changed files with 147 additions and 12 deletions

17
package-lock.json generated
View File

@ -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",

View File

@ -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",

View File

@ -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,
}
})
}

View File

@ -120,7 +120,7 @@ const rules = {
};
//
const login = ref(null);
const maxLoginRepeatRequest = 30; //
const maxLoginRepeatRequest = 60; //
const currentLoginRequest = ref(0); //
const thirdPartyLogoInfoList = ref([
@ -158,13 +158,6 @@ var loginData = ref({
password: "",
ip: "",
});
const thirdPartyPlatform = ref([
{ label: 'QQ', value: 'qq' },
{ label: 'Github', value: 'github' },
{ label: 'Gitee', value: 'gitee' },
{ label: 'Google', value: 'google' },
{ label: 'Facebook', value: 'facebook'}
]);
const thirdLogin = async (type) => {
//uuid

View File

@ -158,7 +158,7 @@ const avatarImg = ref('');
const imgSrc = ref('');
const cropImg = ref('');
const cropper: any = ref();
const maxLoginRepeatRequest = 30; //
const maxLoginRepeatRequest = 60; //
const currentLoginRequest = ref(0); //
const thirdPartyUserInfo = ref<ThirdPartyUserInfo[]>([]);

View File

@ -63,11 +63,26 @@
<div v-html="renderMarkdown(message,index)"></div>
<!-- 添加复制 -->
<div>
<el-tooltip content="复制" placement="top">
<el-button
type="text"
:icon="DocumentCopy"
@click="copyMessage(message.content)"
></el-button>
</el-tooltip>
<!-- <el-button
type="text"
:icon="Document"
@click="MessageTextToDoc(message.content)"
></el-button> -->
<el-tooltip content="预览、文本创建文件" placement="top">
<el-button
type="text"
:icon="Document"
@click="MessageTextToDoc(message.content)"
>
</el-button>
</el-tooltip>
</div>
</div>
</div>
@ -171,7 +186,7 @@
</el-col>
<el-col :span="3" style="text-align: center">
<el-select v-model="selectModel" placeholder="选择模型">
<el-select v-model="selectModel" placeholder="选择模型" style="width: 320px;">
<el-option
v-for="item in ModelList"
:key="item.ID"
@ -180,10 +195,12 @@
></el-option>
</el-select>
</el-col>
<el-col :span="1" style="text-align: center">
<el-col :span="10" style="text-align: center">
<el-tooltip content="文件选择" placement="top">
<el-button @click="handleSelectFileVisible"
><el-icon><Files /></el-icon
></el-button>
</el-tooltip>
</el-col>
<!-- <el-col :span="1" style="text-align: center">
<el-button @click="handleUploadPicture"><el-icon><Picture /></el-icon></el-button>
@ -266,6 +283,33 @@
<UploadFile></UploadFile>
</el-dialog>
</div>
<div>
<!-- 文本创建文件对话 -->
<el-dialog
title="文本创建文件"
v-model="textToDocFileVisible"
width="70%"
heigth="80vh"
:before-close="handleMessageTextToDOCClose">
<!-- <textarea v-model="textToDocFileContent"></textarea> -->
<div id="vditor"></div>
<el-col>
<!-- 提示 -->
<el-input v-model="textToDocFileName" placeholder="输入文件名..." style="width: 30%;">输入文件名</el-input>
</el-col>
<!-- <el-input v-model="textToDocFileName" placeholder="输入文件名..." width="30%">输入文件名</el-input> -->
<el-col>
<el-select v-model="selectFileDocType" placeholder="选择文本类型" style="width: 30%;">
<el-option label="docx" value="docx"></el-option>
<el-option label="txt" value="txt"></el-option>
<el-option label="md" value="md"></el-option>
</el-select>
</el-col>
<el-button type="primary" @click="HandleTextToDocFile">确认</el-button>
<el-button @click="textToDocFileVisible = false">取消</el-button>
</el-dialog>
</div>
</div>
</template>
@ -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<File[]>([]); //
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,30 @@ const getFileListData = async () => {
ElMessage.error(result["msg"]);
}
};
const HandleTextToDocFile = async () => {
//
//console.log(":", textToDocFileName.value, vditor.value.getValue(), selectFileDocType.value);
if (textToDocFileName.value.trim() === "") {
ElMessage.warning("文件名不能为空");
return;
}
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"]);
}
};
</script>
<style scoped>
.chat-app {

View File

@ -1563,6 +1563,11 @@ dequal@^2.0.0:
resolved "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz"
integrity sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==
diff-match-patch@^1.0.5:
version "1.0.5"
resolved "https://registry.npmjs.org/diff-match-patch/-/diff-match-patch-1.0.5.tgz"
integrity sha512-IayShXAgj/QMXgB0IWmKx+rOPuGMhqm5w6jvFxmVenXKIzRqTAAsbBPT3kWQeGANj3jGgvcvv4yK6SxqYmikgw==
diff@^5.0.0:
version "5.2.0"
resolved "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz"
@ -3281,6 +3286,13 @@ uvu@^0.5.0:
kleur "^4.0.3"
sade "^1.7.3"
vditor@^3.11.0:
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"
vite-plugin-vue-setup-extend@^0.4.0:
version "0.4.0"
resolved "https://registry.npmjs.org/vite-plugin-vue-setup-extend/-/vite-plugin-vue-setup-extend-0.4.0.tgz"