feat: add editor

This commit is contained in:
xiaoxian521
2021-04-04 17:52:30 +08:00
parent 42dfb536bd
commit b76e199b6d
6 changed files with 112 additions and 0 deletions

View File

@@ -3,6 +3,7 @@
"LoginOut": "退出系统",
"usermanagement": "用户管理",
"baseinfo": "基础信息",
"editor": "编辑器",
"error": "错误页面",
"404": "404",
"401": "401",

View File

@@ -3,6 +3,7 @@
"LoginOut": "Login Out",
"usermanagement": "User Manage",
"baseinfo": "Base Info",
"editor": "Editor",
"error": "Error Page",
"404": "404",
"401": "401",

View File

@@ -109,6 +109,30 @@ const routes: Array<RouteRecordRaw> = [
savedPosition: true
}
},
{
path: '/editor',
name: 'editor',
component: Layout,
redirect: '/editor/index',
children: [
{
path: '/editor/index',
component: () => import(/* webpackChunkName: "user" */ '../views/editor/index.vue'),
meta: {
// icon: 'el-icon-edit-outline',
title: 'editor',
showLink: false,
savedPosition: true
}
},
],
meta: {
icon: 'el-icon-edit-outline',
title: 'editor',
showLink: true,
savedPosition: true
}
},
{
path: '/error',
name: 'error',

View File

@@ -0,0 +1,49 @@
<template>
<div>
<div ref="editor"></div>
<div :innerHTML="content.html"></div>
</div>
</template>
<script>
import { onMounted, onBeforeUnmount, ref, reactive } from 'vue'
import WangEditor from 'wangeditor'
export default {
name: 'editor',
setup() {
const editor = ref()
const content = reactive({
html: '',
text: '',
})
let instance
onMounted(() => {
instance = new WangEditor(editor.value)
Object.assign(instance.config, {
onchange() {
content.html = instance.txt.html()
},
})
instance.create()
})
onBeforeUnmount(() => {
instance.destroy()
instance = null
})
return {
editor,
content,
}
},
};
</script>
<style lang="scss" scoped>
:deep(.w-e-text-container) {
z-index: 999 !important;
}
</style>