增加侧边栏的导航栏

master
joefalmko 9 months ago
parent 314a042f0c
commit cdfd97ab47

@ -8,8 +8,8 @@
} }
.main-container { .main-container {
/* --ckeditor5-preview-height: 700px; */ --ckeditor5-preview-height: 650px;
position:relative; position: relative;
font-family: '宋体'; font-family: '宋体';
width: fit-content; width: fit-content;
height: 100%; height: 100%;
@ -19,6 +19,7 @@
.ck-content { .ck-content {
font-family: '宋体'; font-family: '宋体';
font-size: 16px;
line-height: 1.6; line-height: 1.6;
word-break: break-word; word-break: break-word;
} }
@ -83,66 +84,15 @@
margin-left: 72px; margin-left: 72px;
margin-right: 72px; margin-right: 72px;
} }
/*侧边栏样式*/
.sidebar {
position: fixed;
top: 0;
left: 0;
width: 350px;
height: 100%;
overflow-y: hidden;
transition: transform 0.3s ease;
transform: translateX(-100%);
background-color: #f9f9f9;
padding-left: 8px; /* 调整内边距,使文字右移 */
padding-right: 8px; /* 调整内边距,使文字右移 */
z-index: 9;
}
.sidebar.active {
transform: translateX(0);
}
.sidebar-menu {
display: flex;
justify-content: space-between;
}
.sidebar-menu .el-menu-item {
flex: 1;
text-align: center;
}
.sidebar-menu .el-menu-item span {
display: block;
padding: 10px;
background-color: #f5f5f5;
border-radius: 4px;
margin: 5px;
transition: background-color 0.3s;
}
.sidebar-menu .el-menu-item span:hover {
background-color: #e0e0e0;
}
.chat-box {
max-height: 350px;
overflow-y: auto;
}
.preview {
margin-top: 20px; /* 调整预览区与表单之间的距离 */
border: 1px solid #ccc; /* 添加边框 */
padding: 10px; /* 添加内边距 */
border-radius: 4px; /* 添加圆角 */
}
.form-item {
margin-bottom: 1px; /* 减小表单项之间的距离 */
}
/*侧边栏出现时其他右移*/ /*侧边栏出现时其他右移*/
.main-container.sidebar-open .editor-container__menu-bar, .main-container.sidebar-open .editor-container__menu-bar,
.main-container.sidebar-open .editor-container__toolbar, .main-container.sidebar-open .editor-container__toolbar,
.main-container.sidebar-open .editor-container__editor-wrapper { .main-container.sidebar-open .editor-container__editor-wrapper {
transition: margin-left 0.3s ease; transition: margin-left 0.3s ease;
margin-left: 350px; margin-left: 350px;
} }
/*用户定义的style插件样式*/ /*用户定义的style插件样式*/
.ck-content h3.category { .ck-content h3.category {
font-family: 'Oswald'; font-family: 'Oswald';
@ -328,19 +278,4 @@
opacity: .5; opacity: .5;
} }
} }
} }
.ck-content p.add_style_test {
font-family: SimHei;
color: green;
font-size: 19px;
font-style: italic;
font-weight: bold;
text-transform: full-width;
text-decoration: underline;
text-shadow: 4px 4px 5px rgba(0, 0, 0, 0.7);
text-align: center;
line-height: 2.0;
letter-spacing: 2px;
word-spacing: 2px;
}

@ -13,19 +13,43 @@
</div> </div>
</div> </div>
</div> </div>
<el-button type="primary" @click="toggleSidebar()" style="display:none" </div>
id="toggleSidebarButton">打开/关闭侧边栏</el-button> <el-button type="primary" @click="toggleSidebar()" style="display:none"
<div class="sidebar" :class="{ 'active': isSidebarOpen }"> id="toggleSidebarButton">打开/关闭侧边栏</el-button>
<!-- 侧边栏内容 --> <div class="sidebar" :class="{ 'active': isSidebarOpen }">
<el-menu default-active="1" class="el-menu-vertical-demo sidebar-menu"> <!-- 侧边栏内容 -->
<el-menu-item index="1" @click="showForm('manual')"> <el-menu class="sidebar-menu" :class="{ 'active': isNavbarOpen }">
<span>手动输入</span> <el-sub-menu index="1">
</el-menu-item> <template #title>智能助手</template>
<el-menu-item index="2" @click="showForm('ai')"> <el-menu-item index="1-1" @click="showContent('polish')"></el-menu-item>
<span>AI 输入</span> <el-menu-item index="1-2" @click="showContent('rewrite')"></el-menu-item>
</el-menu-item> <el-menu-item index="1-3" @click="showContent('summary')"></el-menu-item>
</el-menu> <el-menu-item index="1-4" @click="showContent('edit')"></el-menu-item>
<div v-if="currentForm === 'manual'" class="p-3"> <el-menu-item index="1-5" @click="showContent('translate')"></el-menu-item>
</el-sub-menu>
<el-sub-menu index="2">
<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>
</el-sub-menu>
<el-sub-menu index="3">
<template #title>样式生成</template>
<el-menu-item index="3-1" @click="showContent('manual')"></el-menu-item>
<el-menu-item index="3-2" @click="showContent('ai')"></el-menu-item>
</el-sub-menu>
</el-menu>
<!-- Content Sections -->
<div v-if="currentContent" class="content-section">
<el-button icon="el-icon-menu" @click="toggleNavBar()"></el-button>
<!-- Dynamic content based on navigation selection -->
<div v-if="currentContent === 'polish'"></div>
<div v-if="currentContent === 'rewrite'"></div>
<div v-if="currentContent === 'summary'"></div>
<div v-if="currentContent === 'edit'"></div>
<div v-if="currentContent === 'translate'"></div>
<div v-if="currentContent === 'ocr'">OCR</div>
<div v-if="currentContent === 'mindmap'"></div>
<div v-if="currentContent === 'manual'" class="p-3">
<!-- 手动输入表单 --> <!-- 手动输入表单 -->
<el-form @submit.prevent="submitForm"> <el-form @submit.prevent="submitForm">
<el-col :span="30"> <el-col :span="30">
@ -60,12 +84,16 @@
<el-col :span="12"> <el-col :span="12">
<el-select v-model="formData.fontSize" @change="updatePreview"> <el-select v-model="formData.fontSize" @change="updatePreview">
<el-option value="">请选择</el-option> <el-option value="">请选择</el-option>
<el-option value="12px" style="font-size: 12px;">12px</el-option> <el-option value="29.3px" style="font-size: 29.3px;">二号</el-option>
<el-option value="14px" style="font-size: 14px;">14px</el-option> <el-option value="24px" style="font-size: 24px;">小二</el-option>
<el-option value="16px" style="font-size: 16px;">16px</el-option> <el-option value="21.3px" style="font-size: 21.3px;">三号</el-option>
<el-option value="18px" style="font-size: 18px;">18px</el-option> <el-option value="20px" style="font-size: 20px;">小三</el-option>
<el-option value="20px" style="font-size: 20px;">16px</el-option> <el-option value="18.6px" style="font-size: 18.6px;">四号</el-option>
<el-option value="22px" style="font-size: 22px;">18px</el-option> <el-option value="16px" style="font-size: 16px;">小四</el-option>
<el-option value="14px" style="font-size: 14px;">五号</el-option>
<el-option value="12px" style="font-size: 12px;">小五</el-option>
<el-option value="10px" style="font-size: 10px;">六号</el-option>
<el-option value="8.6px" style="font-size: 8.6px;">小六</el-option>
</el-select> </el-select>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
@ -89,7 +117,8 @@
<el-option value="Helvetica" <el-option value="Helvetica"
style="font-family: Helvetica;">Helvetica</el-option> style="font-family: Helvetica;">Helvetica</el-option>
<el-option value="Times New Roman" <el-option value="Times New Roman"
style="font-family: 'Times New Roman';">Times New Roman</el-option> style="font-family: 'Times New Roman';">Times
New Roman</el-option>
<el-option value="serif" style="font-family: serif;">serif</el-option> <el-option value="serif" style="font-family: serif;">serif</el-option>
<el-option value="sans-serif" <el-option value="sans-serif"
style="font-family: sans-serif;">sans-serif</el-option> style="font-family: sans-serif;">sans-serif</el-option>
@ -169,20 +198,24 @@
<el-form-item label="字体阴影:"> <el-form-item label="字体阴影:">
<el-select v-model="formData.textShadow" @change="updatePreview"> <el-select v-model="formData.textShadow" @change="updatePreview">
<el-option value="">请选择</el-option> <el-option value="">请选择</el-option>
<el-option value="2px 2px 4px rgba(0,0,0,0.5)" <el-option value="1px 1px 2px pink"
style="text-shadow: 2px 2px 4px rgba(0,0,0,0.5);">阴影1</el-option> style="text-shadow: 1px 1px 2px pink;">阴影1</el-option>
<el-option value="4px 4px 8px rgba(0,0,0,0.5)" <el-option value="#FC0 1px 0 10px"
style="text-shadow: 4px 4px 8px rgba(0,0,0,0.5);">阴影2</el-option> style="text-shadow: #FC0 1px 0 10px;">阴影2</el-option>
<el-option value="6px 6px 12px rgba(0,0,0,0.5)" <el-option value="1px 1px 2px red, 0 0 1em blue, 0 0 0.2em blue"
style="text-shadow: 6px 6px 12px rgba(0,0,0,0.5);">阴影3</el-option> style="text-shadow: 1px 1px 2px red, 0 0 1em blue, 0 0 0.2em blue;">阴影3</el-option>
<el-option value="-1px -1px 1px #aaa" <el-option value="2px 2px #777"
style="text-shadow: -1px -1px 1px #aaa;">阴影4</el-option> style="text-shadow: 2px 2px #777;">阴影4</el-option>
<el-option value="0px 4px 1px rgba(0, 0, 0, 0.5)" <el-option value="-1px -1px #000,-2px -2px #333,1px 1px #fff,2px 2px #eee"
style="text-shadow: 0px 4px 1px rgba(0, 0, 0, 0.5);">阴影5</el-option> style="text-shadow: -1px -1px #000,-2px -2px #333,1px 1px #fff,2px 2px #eee;">阴影5</el-option>
<el-option value="4px 4px 5px rgba(0, 0, 0, 0.7)" <el-option
style="text-shadow: 4px 4px 5px rgba(0, 0, 0, 0.7);">阴影6</el-option> value="1px 1px #BAE6EF,2px 2px #BAE6EF,3px 3px #BAE6EF,4px 4px #BAE6EF,5px 5px #BAE6EF"
<el-option value="0px 0px 7px rgba(0, 0, 0, 0.4)" style="text-shadow: 1px 1px #BAE6EF,2px 2px #BAE6EF,3px 3px #BAE6EF,4px 4px #BAE6EF,5px 5px #BAE6EF;">阴影6</el-option>
style="text-shadow: 0px 0px 7px rgba(0, 0, 0, 0.4);">阴影7</el-option> <el-option value="5px 5px #666,7px 7px #eee"
style="text-shadow: 5px 5px #666,7px 7px #eee;">阴影7</el-option>
<el-option
value="0 0 5px #FFFF66,1px 1px 1px #fff,-1px -1px 1px #fff,0 0 10px #FFFF99,0 0 20px #B9EB50"
style="text-shadow: 0 0 5px #FFFF66,1px 1px 1px #fff,-1px -1px 1px #fff,0 0 10px #FFFF99,0 0 20px #B9EB50;">阴影8</el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
@ -236,7 +269,7 @@
Aa Bb Cc 上下 左右 12345 Aa Bb Cc 上下 左右 12345 Aa Bb Cc 上下 左右 12345 Aa Bb Cc 上下 左右 12345 Aa Bb Cc 上下 左右 12345 Aa Bb Cc 上下 左右 12345
</div> </div>
</div> </div>
<div v-if="currentForm === 'ai'" class="p-3"> <div v-if="currentContent === 'ai'" class="p-3">
<!-- AI对话框 --> <!-- AI对话框 -->
<div class="chat-box border rounded p-3"> <div class="chat-box border rounded p-3">
<p v-for="message in messages" :key="message.id" class="mb-1">{{ message.text }}</p> <p v-for="message in messages" :key="message.id" class="mb-1">{{ message.text }}</p>
@ -245,15 +278,87 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<style>
/*侧边栏样式*/
.sidebar {
position: fixed;
top: 0;
left: 0;
width: 350px;
height: 100%;
overflow-y: hidden;
transition: transform 0.3s ease;
transform: translateX(-100%);
background-color: #f9f9f9;
padding-left: 8px;
/* 调整内边距,使文字右移 */
padding-right: 8px;
/* 调整内边距,使文字右移 */
z-index: 9;
}
.sidebar.active {
transform: translateX(0);
}
.sidebar-menu {
display: none;
flex-direction: column;
justify-content: space-between;
}
.sidebar-menu.active {
display: block;
}
.sidebar-menu .el-menu-item {
flex: 1;
text-align: left;
}
.sidebar-menu .el-menu-item span {
display: block;
padding: 10px;
background-color: #f5f5f5;
border-radius: 4px;
margin: 5px;
transition: background-color 0.3s;
}
.sidebar-menu .el-menu-item span:hover {
background-color: #e0e0e0;
}
.chat-box {
max-height: 350px;
overflow-y: auto;
}
.preview {
margin-top: 20px;
/* 调整预览区与表单之间的距离 */
border: 1px solid #ccc;
/* 添加边框 */
padding: 10px;
/* 添加内边距 */
border-radius: 4px;
/* 添加圆角 */
}
.form-item {
margin-bottom: 1px;
/* 减小表单项之间的距离 */
}
</style>
<script> <script>
import { import {
// DecoupledEditor, DecoupledEditor,
ClassicEditor, // ClassicEditor,
AccessibilityHelp, AccessibilityHelp,
Alignment, Alignment,
Autoformat, Autoformat,
@ -326,7 +431,7 @@ import {
} from 'ckeditor5'; } from 'ckeditor5';
import translations from 'ckeditor5/translations/zh-cn.js'; import translations from 'ckeditor5/translations/zh-cn.js';
import 'ckeditor5/ckeditor5.css'; import 'ckeditor5/ckeditor5.css';
import { ElButton, ElInput, ElSelect, ElOption, ElForm, ElFormItem, ElMenu, ElMenuItem, ElColorPicker } from 'element-plus'; import { ElButton, ElInput, ElSelect, ElOption, ElForm, ElFormItem, ElMenu, ElMenuItem, ElColorPicker, ElSubMenu } from 'element-plus';
// import {getUserConfigFromBackend,saveData,getPageContent,getAndApplyUserStyles} from './components/utils'; // import {getUserConfigFromBackend,saveData,getPageContent,getAndApplyUserStyles} from './components/utils';
import { getUserConfigFromBackend, saveData, getPageContent } from './components/utils'; import { getUserConfigFromBackend, saveData, getPageContent } from './components/utils';
import { Export2PDF, Export2Word, ToggleSideBar, Translation } from './components/plugins' import { Export2PDF, Export2Word, ToggleSideBar, Translation } from './components/plugins'
@ -337,12 +442,13 @@ export default {
return { return {
isLayoutReady: false, isLayoutReady: false,
config: null, // CKEditor needs the DOM tree before calculating the configuration. config: null, // CKEditor needs the DOM tree before calculating the configuration.
// editor: DecoupledEditor editor: DecoupledEditor,
editor: ClassicEditor, // editor: ClassicEditor,
isSidebarOpen: false,// isSidebarOpen: false,//
currentForm: '', // isNavbarOpen: false,//
currentContent: '', //
formData: { formData: {
fontFamily: '', fontFamily: '',
color: '', color: '',
@ -627,10 +733,15 @@ export default {
// / // /
toggleSidebar() { toggleSidebar() {
this.isSidebarOpen = !this.isSidebarOpen; this.isSidebarOpen = !this.isSidebarOpen;
this.isNavbarOpen = this.isSidebarOpen;
},
toggleNavBar() {
this.isNavbarOpen = !this.isNavbarOpen;
}, },
// //
showForm(formType) { showContent(formType) {
this.currentForm = formType; this.currentContent = formType;
this.isNavbarOpen=false;
}, },
// //
submitForm() { submitForm() {
@ -678,7 +789,7 @@ export default {
}, },
components: { components: {
// //
ElButton, ElInput, ElSelect, ElOption, ElForm, ElFormItem, ElMenu, ElMenuItem, ElColorPicker ElButton, ElInput, ElSelect, ElOption, ElForm, ElFormItem, ElMenu, ElMenuItem, ElColorPicker, ElSubMenu
} }
}; };
</script> </script>

@ -29,7 +29,7 @@ export function getUserConfigFromBackend() {
'Times New Roman' 'Times New Roman'
], ],
// 五号,小四,四号,小三,三号,小二,二号 // 五号,小四,四号,小三,三号,小二,二号
fontSizeOptions = [10.5, 12, 14, 15, 'default', 18, 22], fontSizeOptions = [14, 'default', 16,18.6,20, 21.3,24,29.3],
styleDefinitions = [ styleDefinitions = [
{ {
name: 'Article category', name: 'Article category',
@ -109,13 +109,6 @@ export function saveData(data) {
console.log(data); console.log(data);
} }
// TODO 手动保存
// function saveByHand(){
// this.editor.plugins.get('Autosave').save().then(() => {
// console.log('Data saved successfully');
// });
// }
// 将当前页面的样式转为内联 // 将当前页面的样式转为内联
export function getStyle() { export function getStyle() {
@ -133,7 +126,8 @@ export function getStyle() {
// 获取用户编辑的内容 <html> // 获取用户编辑的内容 <html>
export function getPageContent() { export function getPageContent() {
const pageContent = document.querySelector("#app > div > div > div > div.editor-container__editor-wrapper > div > div > div.ck.ck-reset.ck-editor.ck-rounded-corners > div.ck.ck-editor__main > div"); // const pageContent = document.querySelector("#app > div > div > div > div.editor-container__editor-wrapper > div > div > div.ck.ck-reset.ck-editor.ck-rounded-corners > div.ck.ck-editor__main > div");
const pageContent = document.querySelector("#app > div > div > div > div.editor-container__editor-wrapper > div > div > div");
return pageContent.innerHTML; return pageContent.innerHTML;
} }

Loading…
Cancel
Save