This commit is contained in:
udf_admin@163.com
2020-05-23 21:37:45 +08:00
parent 1c170df5e8
commit a7a4a8032b
9 changed files with 215 additions and 55 deletions
+2 -1
View File
@@ -13,7 +13,8 @@
"build": "node build/build.js"
},
"dependencies": {
"babel-polyfill": "^6.26.0"
"babel-polyfill": "^6.26.0",
"mavon-editor": "^2.9.0"
},
"devDependencies": {
"autoprefixer": "^7.1.2",
+6 -2
View File
@@ -18,7 +18,7 @@
</div>
<div v-show="showSearchInput" class="searchInputDiv">
<el-input ref="searchInput" v-model="searchInputText" :style="searchInputStyle" clearable
placeholder="请输入要搜索的内容">
placeholder="请输入要搜索的内容" @keyup.enter.native="searchInputHandle">
</el-input>
</div>
<div v-show="!showSearchInput" class="toolDiv">
@@ -267,7 +267,7 @@
//设定框宽度
this.searchInputStyle.width = window.innerWidth - 200 - 10 + 'px';
//判断是否显示菜单栏
this.elAsideShow = window.innerWidth > 1366 ? true : false;
this.elAsideShow = window.innerWidth > glob.minWidth ? true : false;
},
//log点击事件
mainLogoBtnClick() {
@@ -298,6 +298,10 @@
if (this.leftMenuDrawerShow) {
this.leftMenuDrawerShow = false;
}
},
//搜索框输入
searchInputHandle() {
this.$EventBus.$emit(glob.eventNames.globSearchEventName, this.searchInputText);
}
}
}
+7
View File
@@ -2,6 +2,13 @@ import router from "../../router";
import {Message} from 'element-ui';
const glob = {
//最小宽度
minWidth: 1366,
//事件名称
eventNames: {
//全局搜索事件名称
globSearchEventName: 'globSearch',
},
//初始化
inti() {
//初始化NProgress
+120
View File
@@ -0,0 +1,120 @@
<template>
<div class="main top-form">
<el-form ref="form" :model="form" label-position="top" size="medium">
<el-card class="contentBar">
<el-form-item label="* 文章标题">
<el-input v-model="form.title" placeholder="文章标题,100个字符以内"></el-input>
</el-form-item>
<el-form-item label="* 文章内容">
<mavon-editor v-model="form.content"
:subfield="false"
:toolbarsFlag="true"
:toolbars="toolbars"
style="min-height: 600px;z-index: 0;"
/>
</el-form-item>
<el-form-item>
<el-button type="success">发布文章</el-button>
<el-button type="success">保存草稿</el-button>
</el-form-item>
</el-card>
</el-form>
</div>
</template>
<script>
import glob from "../../assets/js/glob";
export default {
name: "artice-add",
data() {
return {
form: {
title: null,
content: ''
},
toolbars: {},
toolbarsFull: {
bold: true, // 粗体
italic: true, // 斜体
header: true, // 标题
underline: true, // 下划线
strikethrough: true, // 中划线
mark: true, // 标记
superscript: true, // 上角标
subscript: true, // 下角标
quote: true, // 引用
ol: true, // 有序列表
ul: true, // 无序列表
link: true, // 链接
imagelink: true, // 图片链接
code: true, // code
table: true, // 表格
fullscreen: false, // 全屏编辑
readmodel: false, // 沉浸式阅读
htmlcode: false, // 展示html源码
help: true, // 帮助
/* 1.3.5 */
undo: true, // 上一步
redo: true, // 下一步
trash: true, // 清空
save: false, // 保存(触发events中的save事件)
/* 1.4.2 */
navigation: true, // 导航目录
/* 2.1.8 */
alignleft: true, // 左对齐
aligncenter: true, // 居中
alignright: true, // 右对齐
/* 2.2.1 */
subfield: true, // 单双栏模式
preview: true, // 预览
},
toolbarsMin: {
imagelink: true, // 图片链接
help: true, // 帮助
undo: true, // 上一步
redo: true, // 下一步
preview: true, // 预览
}
}
},
activated() {
//重置
this.reset();
},
deactivated() {
},
methods: {
//重置
reset() {
//重置表单
this.form = {
title: null,
content: ''
};
//设置工具栏
if (window.innerWidth > glob.minWidth) {
this.toolbars = this.toolbarsFull;
} else {
this.toolbars = this.toolbarsMin;
}
}
}
}
</script>
<style lang="scss" scoped>
.main {
padding: 10px 10px 10px 10px;
.el-card {
border-radius: 0px;
}
.contentBar {
}
}
</style>
+66
View File
@@ -0,0 +1,66 @@
<template>
<div class="main">
<el-card class="searcBar">
<el-button type="success" icon="el-icon-edit-outline" @click="addArticeClickHandle">写文章</el-button>
</el-card>
<el-card class="listBar">
<ul v-infinite-scroll="loadData">
<li v-for="i in count" :key="i">{{ i }}</li>
</ul>
</el-card>
</div>
</template>
<script>
import glob from "../../assets/js/glob";
export default {
name: "artice-main",
data() {
return {
count: 0
}
},
activated() {
this.$EventBus.$on(glob.eventNames.globSearchEventName, this.globSearchHandle);
},
deactivated() {
this.$EventBus.$off(glob.eventNames.globSearchEventName);
},
methods: {
//全局搜索事件处理器
globSearchHandle(searchText) {
console.log(searchText);
},
//写文章点击事件
addArticeClickHandle() {
this.$router.push({name: 'article-add'});
},
//加载数据
loadData() {
if (this.count < 500) {
console.log('load');
this.count += 10;
}
}
}
}
</script>
<style lang="scss" scoped>
.main {
padding: 10px 10px 10px 10px;
.el-card {
border-radius: 0px;
}
.searcBar {
}
.listBar {
margin-top: 10px;
}
}
</style>
-49
View File
@@ -1,49 +0,0 @@
<template>
<div class="article">
<el-card class="searcBar">
searchBar
</el-card>
<el-card class="listBar">
<ul v-infinite-scroll="load">
<li v-for="i in count" :key="i">{{ i }}</li>
</ul>
</el-card>
</div>
</template>
<script>
export default {
name: "article",
data() {
return {
count: 0
}
},
methods: {
load() {
if (this.count < 500) {
console.log('load');
this.count += 10;
}
}
}
}
</script>
<style lang="scss" scoped>
.article {
padding: 10px 10px 10px 10px;
.el-card {
border-radius: 0px;
}
.searcBar {
}
.listBar {
margin-top: 10px;
}
}
</style>
+1 -1
View File
@@ -5,7 +5,7 @@
<i class="el-icon-menu"></i>
<span slot="title">首页</span>
</el-menu-item>
<el-menu-item index="article">
<el-menu-item index="article-main">
<i class="el-icon-edit-outline"></i>
<span slot="title">文章</span>
</el-menu-item>
+6
View File
@@ -5,9 +5,15 @@ import router from './router/index'
import "babel-polyfill";
import './assets/scss/glob.scss';
import glob from './assets/js/glob.js';
import mavonEditor from 'mavon-editor'
import 'mavon-editor/dist/css/index.css'
//use
Vue.config.productionTip = false;
//EventBus
Vue.prototype.$EventBus = new Vue();
//mavonEditor
Vue.use(mavonEditor);
//init
glob.inti();
/* eslint-disable no-new */
+7 -2
View File
@@ -9,8 +9,13 @@ export default new VueRouter({
},
{
path: '/article',
name: 'article',
component: () => import('../components/article'),
name: 'article-main',
component: () => import('../components/artice/main'),
},
{
path: '/article/add',
name: 'article-add',
component: () => import('../components/artice/add'),
}
]
});