|
|
|
@ -16,7 +16,7 @@
|
|
|
|
|
</div>
|
|
|
|
|
<el-button type="primary" @click="toggleSidebar()" style="display:none"
|
|
|
|
|
id="toggleSidebarButton">打开/关闭侧边栏</el-button>
|
|
|
|
|
<div class="sidebar" :class="{ 'active': isSidebarOpen }" >
|
|
|
|
|
<div class="sidebar" :class="{ 'active': isSidebarOpen }">
|
|
|
|
|
<!-- 侧边栏内容 -->
|
|
|
|
|
<el-menu class="sidebar-menu" :class="{ 'active': isNavbarOpen }" :collapse="isNavbarOpen">
|
|
|
|
|
<el-sub-menu index="1" class="horizontal-sub-menu">
|
|
|
|
@ -28,9 +28,9 @@
|
|
|
|
|
<el-menu-item index="1-5" @click="showRefineDOCContent('translation')">翻译</el-menu-item>
|
|
|
|
|
</el-sub-menu>
|
|
|
|
|
<el-sub-menu index="2" class="horizontal-sub-menu">
|
|
|
|
|
<template #title>图文转换</template>
|
|
|
|
|
<el-menu-item index="2-1" @click="showContent('ocr')">OCR</el-menu-item>
|
|
|
|
|
<el-menu-item index="2-2" @click="showContent('mindmap')">脑图生成</el-menu-item>
|
|
|
|
|
<template #title>智能识别</template>
|
|
|
|
|
<el-menu-item index="2-1" @click="showAiRecgContent('pic_recognition')">图片识别</el-menu-item>
|
|
|
|
|
<!-- <el-menu-item index="2-2" @click="showAiRecgContent('voc_recognition')">语音识别</el-menu-item>-->
|
|
|
|
|
</el-sub-menu>
|
|
|
|
|
<el-sub-menu index="3" class="horizontal-sub-menu">
|
|
|
|
|
<template #title>样式生成</template>
|
|
|
|
@ -43,7 +43,14 @@
|
|
|
|
|
<!-- Dynamic content based on navigation selection -->
|
|
|
|
|
<div v-if="currentContent === 'refine_doc'" id='refine_doc_block'>
|
|
|
|
|
<div class="refine_docs" id="refine_docs">
|
|
|
|
|
<el-button style="margin-left: 10px; width: 40px; height: 40px;" @click="clearRefineDOCContent()"><svg t="1731509926355" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8154" width="20" height="20"><path d="M1011.43552 981.92384l-68.4032-394.40384h23.10144c18.5856 0 33.54624-14.97088 33.54624-33.55648V306.16576c0-18.5856-14.97088-33.55648-33.54624-33.55648H648.6528V37.71392c0-18.5856-14.97088-33.55648-33.55648-33.55648H408.59648c-18.5856 0-33.55648 14.97088-33.55648 33.55648v234.88512H57.5488c-18.5856 0-33.54624 14.97088-33.54624 33.55648v247.79776c0 18.5856 14.97088 33.55648 33.54624 33.55648h23.10144L12.24704 981.9136c-0.38912 1.9456-0.512 3.87072-0.512 5.6832 0 18.5856 14.97088 33.54624 33.55648 33.54624h933.10976c1.93536 0 3.88096-0.12288 5.6832-0.512 18.31936-3.08224 30.57664-20.51072 27.35104-38.7072zM114.33984 362.94656h351.03744V94.50496h92.928v268.4416h351.03744v134.22592H114.33984V362.94656zM718.336 930.816V729.48736c0-5.6832-4.64896-10.33216-10.32192-10.33216h-61.952c-5.67296 0-10.32192 4.64896-10.32192 10.33216V930.816H387.9424V729.48736c0-5.6832-4.64896-10.33216-10.32192-10.33216h-61.952c-5.67296 0-10.32192 4.64896-10.32192 10.33216V930.816H112.78336l58.20416-335.55456h681.5744L910.76608 930.816H718.336z m0 0" fill="#2C2C2C" p-id="8155"></path></svg></el-button>
|
|
|
|
|
<el-button style="margin-left: 10px; width: 40px; height: 40px;"
|
|
|
|
|
@click="clearRefineDOCContent()"><svg t="1731509926355" class="icon"
|
|
|
|
|
viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8154"
|
|
|
|
|
width="20" height="20">
|
|
|
|
|
<path
|
|
|
|
|
d="M1011.43552 981.92384l-68.4032-394.40384h23.10144c18.5856 0 33.54624-14.97088 33.54624-33.55648V306.16576c0-18.5856-14.97088-33.55648-33.54624-33.55648H648.6528V37.71392c0-18.5856-14.97088-33.55648-33.55648-33.55648H408.59648c-18.5856 0-33.55648 14.97088-33.55648 33.55648v234.88512H57.5488c-18.5856 0-33.54624 14.97088-33.54624 33.55648v247.79776c0 18.5856 14.97088 33.55648 33.54624 33.55648h23.10144L12.24704 981.9136c-0.38912 1.9456-0.512 3.87072-0.512 5.6832 0 18.5856 14.97088 33.54624 33.55648 33.54624h933.10976c1.93536 0 3.88096-0.12288 5.6832-0.512 18.31936-3.08224 30.57664-20.51072 27.35104-38.7072zM114.33984 362.94656h351.03744V94.50496h92.928v268.4416h351.03744v134.22592H114.33984V362.94656zM718.336 930.816V729.48736c0-5.6832-4.64896-10.33216-10.32192-10.33216h-61.952c-5.67296 0-10.32192 4.64896-10.32192 10.33216V930.816H387.9424V729.48736c0-5.6832-4.64896-10.33216-10.32192-10.33216h-61.952c-5.67296 0-10.32192 4.64896-10.32192 10.33216V930.816H112.78336l58.20416-335.55456h681.5744L910.76608 930.816H718.336z m0 0"
|
|
|
|
|
fill="#2C2C2C" p-id="8155"></path>
|
|
|
|
|
</svg></el-button>
|
|
|
|
|
<div v-for="(item, index) in currentRefineDocContent" :key="index" class="messages">
|
|
|
|
|
<div class="message">
|
|
|
|
|
<p>{{ item.oldContent }}</p>
|
|
|
|
@ -51,11 +58,26 @@
|
|
|
|
|
<div class="message-answer">
|
|
|
|
|
<pre>{{ item.newContent }}</pre>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-if="currentContent === 'ai_recg'">
|
|
|
|
|
<div class="ai_recgs" id="ai_recgs">
|
|
|
|
|
<el-button style="margin-left: 10px; width: 40px; height: 40px;"
|
|
|
|
|
@click="clearAiRecgContent()"><svg t="1731509926355" class="icon"
|
|
|
|
|
viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8154"
|
|
|
|
|
width="20" height="20">
|
|
|
|
|
<path
|
|
|
|
|
d="M1011.43552 981.92384l-68.4032-394.40384h23.10144c18.5856 0 33.54624-14.97088 33.54624-33.55648V306.16576c0-18.5856-14.97088-33.55648-33.54624-33.55648H648.6528V37.71392c0-18.5856-14.97088-33.55648-33.55648-33.55648H408.59648c-18.5856 0-33.55648 14.97088-33.55648 33.55648v234.88512H57.5488c-18.5856 0-33.54624 14.97088-33.54624 33.55648v247.79776c0 18.5856 14.97088 33.55648 33.54624 33.55648h23.10144L12.24704 981.9136c-0.38912 1.9456-0.512 3.87072-0.512 5.6832 0 18.5856 14.97088 33.54624 33.55648 33.54624h933.10976c1.93536 0 3.88096-0.12288 5.6832-0.512 18.31936-3.08224 30.57664-20.51072 27.35104-38.7072zM114.33984 362.94656h351.03744V94.50496h92.928v268.4416h351.03744v134.22592H114.33984V362.94656zM718.336 930.816V729.48736c0-5.6832-4.64896-10.33216-10.32192-10.33216h-61.952c-5.67296 0-10.32192 4.64896-10.32192 10.33216V930.816H387.9424V729.48736c0-5.6832-4.64896-10.33216-10.32192-10.33216h-61.952c-5.67296 0-10.32192 4.64896-10.32192 10.33216V930.816H112.78336l58.20416-335.55456h681.5744L910.76608 930.816H718.336z m0 0"
|
|
|
|
|
fill="#2C2C2C" p-id="8155"></path>
|
|
|
|
|
</svg></el-button>
|
|
|
|
|
<div v-for="(item, index) in currentAiRecgContent" :key="index" class="messages">
|
|
|
|
|
<div class="message-answer">
|
|
|
|
|
<pre>{{ item.newContent }}</pre>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-if="currentContent === 'ocr'">OCR内容</div>
|
|
|
|
|
<div v-if="currentContent === 'mindmap'">脑图生成内容</div>
|
|
|
|
|
<div v-if="currentContent === 'manual'">
|
|
|
|
|
<!-- 手动输入表单 -->
|
|
|
|
|
<el-form @submit.prevent="submitForm">
|
|
|
|
@ -300,6 +322,7 @@ import {
|
|
|
|
|
} from 'ckeditor5';
|
|
|
|
|
import 'ckeditor5/ckeditor5.css';
|
|
|
|
|
import '../public/sidebar.css';
|
|
|
|
|
import '../public/generatedStyle.css';
|
|
|
|
|
import { ElButton, ElInput, ElSelect, ElOption, ElForm, ElFormItem, ElMenu, ElMenuItem, ElColorPicker, ElSubMenu } from 'element-plus';
|
|
|
|
|
import emitter, { setConfig } from '../components/plugins'
|
|
|
|
|
// import {getUserConfigFromBackend,saveData,getPageContent,getAndApplyUserStyles} from './components/utils';
|
|
|
|
@ -320,6 +343,7 @@ export default {
|
|
|
|
|
isNavbarOpen: false,// 侧边栏是否打开
|
|
|
|
|
currentContent: '', // 当前侧边栏显示的表单
|
|
|
|
|
currentRefineDocContent: [], //当前侧边栏显示的文档优化的内容
|
|
|
|
|
currentAiRecgContent: [], //当前侧边栏显示的智能识别的内容
|
|
|
|
|
formData: {
|
|
|
|
|
fontFamily: '',
|
|
|
|
|
color: '',
|
|
|
|
@ -345,10 +369,13 @@ export default {
|
|
|
|
|
this.$refs.editorToolbarElement.appendChild(editor.ui.view.toolbar.element);
|
|
|
|
|
this.$refs.editorMenuBarElement.appendChild(editor.ui.view.menuBarView.element);
|
|
|
|
|
// 这里向后端获取要打开文件地内容
|
|
|
|
|
// DFZ
|
|
|
|
|
const pageContent = this.store.state.user.filecontent;
|
|
|
|
|
editor.setData(pageContent);
|
|
|
|
|
// 将editor保存到window中,便于别的地方使用|官方推荐做法
|
|
|
|
|
window.editor = editor;
|
|
|
|
|
window.username = this.store.state.user.username;
|
|
|
|
|
// 获取样式 CSS 文件 DFZ
|
|
|
|
|
},
|
|
|
|
|
// sidebar
|
|
|
|
|
// 打开/关闭侧边栏
|
|
|
|
@ -361,20 +388,34 @@ export default {
|
|
|
|
|
this.currentContent = formType;
|
|
|
|
|
},
|
|
|
|
|
// 展示文本优化表单
|
|
|
|
|
showRefineDOCContent(tag){
|
|
|
|
|
showRefineDOCContent(tag) {
|
|
|
|
|
this.currentContent = 'refine_doc';
|
|
|
|
|
this.store.commit('setCurrentTag', tag);
|
|
|
|
|
if (this.store.getters.getCurrentContent){
|
|
|
|
|
this.currentRefineDocContent = this.store.getters.getCurrentContent.reduce((acc, current) => [current,...acc], []);
|
|
|
|
|
if (this.store.getters.getCurrentContent) {
|
|
|
|
|
this.currentRefineDocContent = this.store.getters.getCurrentContent.reduce((acc, current) => [current, ...acc], []);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
clearRefineDOCContent(){
|
|
|
|
|
showAiRecgContent(tag) {
|
|
|
|
|
this.currentContent = 'ai_recg';
|
|
|
|
|
this.store.commit('setCurrentTag', tag);
|
|
|
|
|
if (this.store.getters.getCurrentContent) {
|
|
|
|
|
this.currentAiRecgContent = this.store.getters.getCurrentContent.reduce((acc, current) => [current, ...acc], []);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
clearRefineDOCContent() {
|
|
|
|
|
this.store.commit('clearContentsForTag', this.store.getters.getCurrentTag);
|
|
|
|
|
if (this.store.getters.getCurrentContent){
|
|
|
|
|
this.currentRefineDocContent = this.store.getters.getCurrentContent.reduce((acc, current)=> [current,...acc], []);
|
|
|
|
|
if (this.store.getters.getCurrentContent) {
|
|
|
|
|
this.currentRefineDocContent = this.store.getters.getCurrentContent.reduce((acc, current) => [current, ...acc], []);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
clearAiRecgContent() {
|
|
|
|
|
this.store.commit('clearContentsForTag', this.store.getters.getCurrentTag);
|
|
|
|
|
if (this.store.getters.getCurrentContent) {
|
|
|
|
|
this.currentAiRecgContent = this.store.getters.getCurrentContent.reduce((acc, current) => [current, ...acc], []);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 保存用户定义样式
|
|
|
|
|
// DFZ
|
|
|
|
|
submitForm() {
|
|
|
|
|
const selectedStyles = {};
|
|
|
|
|
for (const key in this.formData) {
|
|
|
|
@ -393,7 +434,36 @@ export default {
|
|
|
|
|
cssClass += `}`;
|
|
|
|
|
|
|
|
|
|
console.log(cssClass); // 这里可以将cssClass发送到后端或其他处理逻辑
|
|
|
|
|
alert(cssClass);
|
|
|
|
|
|
|
|
|
|
const formData = new FormData();
|
|
|
|
|
formData.append('user_name', this.store.state.user.username);
|
|
|
|
|
formData.append('style_name', className);
|
|
|
|
|
formData.append('element_name', 'p');
|
|
|
|
|
formData.append('style_classes', [className]);
|
|
|
|
|
formData.append('style_content', cssClass);
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
body: formData
|
|
|
|
|
};
|
|
|
|
|
console.log(requestOptions);
|
|
|
|
|
fetch("http://localhost:14514/admin/user_config/user_style_save", requestOptions)
|
|
|
|
|
.then(response => {
|
|
|
|
|
if (!response.ok) {
|
|
|
|
|
throw new Error("请求出错");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 根据返回的数据格式进行相应处理,这里假设返回的数据是JSON格式,所以使用response.json()解析
|
|
|
|
|
return response.json();
|
|
|
|
|
})
|
|
|
|
|
.then(data => {
|
|
|
|
|
console.log("POST请求成功:", data);
|
|
|
|
|
alert("保存成功!");
|
|
|
|
|
})
|
|
|
|
|
.catch(error => {
|
|
|
|
|
console.error("POST请求出错:", error);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
alert("类名不能为空!");
|
|
|
|
|
}
|
|
|
|
@ -455,7 +525,7 @@ export default {
|
|
|
|
|
|
|
|
|
|
// 向后端调用API并接受response
|
|
|
|
|
try {
|
|
|
|
|
const response = await fetch('/web_api/admin/ai_layout/style_generate', {
|
|
|
|
|
const response = await fetch('http://localhost:14514/admin/ai_layout/style_generate', {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
@ -572,17 +642,37 @@ export default {
|
|
|
|
|
saveButton.onclick = () => {
|
|
|
|
|
// save
|
|
|
|
|
// TODO 将生成的样式保存到后端
|
|
|
|
|
// DFZ
|
|
|
|
|
// 确认样式的名称 这是用户选择使用style时看到的
|
|
|
|
|
// styleDefinition:[name: 'styleName',element: 'element',classes: [className]]
|
|
|
|
|
const styleName = prompt("请输入样式名称:");
|
|
|
|
|
// 构造styleDefiniton发送到后端
|
|
|
|
|
const styleDefinition = {
|
|
|
|
|
name: styleName,
|
|
|
|
|
element: previewElement.tagName,
|
|
|
|
|
classes: classNames
|
|
|
|
|
const formData = new FormData();
|
|
|
|
|
formData.append('user_name', this.store.state.user.username);
|
|
|
|
|
formData.append('style_name', styleName);
|
|
|
|
|
formData.append('element_name', previewElement.tagName);
|
|
|
|
|
formData.append('style_classes', classNames);
|
|
|
|
|
formData.append('style_content', cssText);
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
body: formData
|
|
|
|
|
};
|
|
|
|
|
console.log(styleDefinition);
|
|
|
|
|
console.log(cssText);// 保存的css代码
|
|
|
|
|
console.log(requestOptions);
|
|
|
|
|
fetch("http://localhost:14514/admin/user_config/user_style_save", requestOptions)
|
|
|
|
|
.then(response => {
|
|
|
|
|
if (!response.ok) {
|
|
|
|
|
throw new Error("请求出错");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 根据返回的数据格式进行相应处理,这里假设返回的数据是JSON格式,所以使用response.json()解析
|
|
|
|
|
return response.json();
|
|
|
|
|
})
|
|
|
|
|
.then(data => {
|
|
|
|
|
console.log("POST请求成功:", data);
|
|
|
|
|
alert("保存成功!");
|
|
|
|
|
})
|
|
|
|
|
.catch(error => {
|
|
|
|
|
console.error("POST请求出错:", error);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
// 显示按钮
|
|
|
|
|
buttonsMessageDiv.appendChild(saveButton);
|
|
|
|
@ -631,16 +721,22 @@ export default {
|
|
|
|
|
return clearButton;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
this.config = setConfig();
|
|
|
|
|
this.isLayoutReady = true;
|
|
|
|
|
emitter.on('show-refine-doc-sidebar', (id) => {
|
|
|
|
|
this.isSidebarOpen = true;
|
|
|
|
|
this.isNavbarOpen = true;
|
|
|
|
|
this.showRefineDOCContent(id);
|
|
|
|
|
console.log(this.currentContent)
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
async mounted() {
|
|
|
|
|
this.config = await setConfig();
|
|
|
|
|
this.isLayoutReady = true;
|
|
|
|
|
emitter.on('show-refine-doc-sidebar', (id) => {
|
|
|
|
|
this.isSidebarOpen = true;
|
|
|
|
|
this.isNavbarOpen = true;
|
|
|
|
|
this.showRefineDOCContent(id);
|
|
|
|
|
console.log(this.currentContent)
|
|
|
|
|
});
|
|
|
|
|
emitter.on('show-ai-recg-sidebar', (id) => {
|
|
|
|
|
this.isSidebarOpen = true;
|
|
|
|
|
this.isNavbarOpen = true;
|
|
|
|
|
this.showAiRecgContent(id);
|
|
|
|
|
console.log(this.currentContent)
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
components: {
|
|
|
|
|
// 导入组件
|
|
|
|
|
ElButton, ElInput, ElSelect, ElOption, ElForm, ElFormItem, ElMenu, ElMenuItem, ElColorPicker, ElSubMenu
|
|
|
|
@ -652,6 +748,7 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
beforeUnmount() {
|
|
|
|
|
emitter.off('show-refine-doc-sidebar');
|
|
|
|
|
emitter.off('show-ai-recg-sidebar');
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|