Skip to content

Commit e160278

Browse files
committed
update blog editor 👍
1 parent 90097c8 commit e160278

File tree

3 files changed

+57
-22
lines changed

3 files changed

+57
-22
lines changed

src/main.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@ import App from "./App.vue";
33
import store from "./store";
44
import router from "./router.js";
55

6-
import VueQuillEditor from "vue-quill-editor"
7-
// require styles
8-
import 'quill/dist/quill.core.css'
9-
import 'quill/dist/quill.snow.css'
10-
import 'quill/dist/quill.bubble.css'
6+
// import VueQuillEditor from "vue-quill-editor"
7+
// Vue.use(VueQuillEditor);
8+
119

1210
import ElementUI from "element-ui";
1311
import "element-ui/lib/theme-chalk/index.css";
1412
Vue.use(ElementUI);
15-
Vue.use(VueQuillEditor);
1613

1714

1815
// 引用API文件

src/router.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Login from "./views/Login";
88
import LoginCallbackView from "./views/LoginCallbackView";
99
import Editor from "./views/Editor";
1010

11-
import applicationUserManager from "./Auth/applicationusermanager";
11+
// import applicationUserManager from "./Auth/applicationusermanager";
1212

1313
Vue.use(Router);
1414

src/views/Editor.vue

+53-15
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,27 @@
77
-->
88
<el-col :span="24" class="warp-main">
99
<el-form ref="infoForm" :model="infoForm" :rules="rules" label-width="120px">
10-
<el-form-item label="标题" prop="a_title">
11-
<el-input v-model="infoForm.a_title"></el-input>
10+
<el-form-item label="标题" prop="btitle">
11+
<el-input v-model="infoForm.btitle"></el-input>
1212
</el-form-item>
1313

14-
<el-form-item label="来源" prop="a_source">
15-
<el-input v-model="infoForm.a_source"></el-input>
14+
<el-form-item label="分类">
15+
<el-select v-model="infoForm.bcategory" placeholder="请选择文章分类">
16+
<el-option label="技术博文" value="技术博文"></el-option>
17+
</el-select>
18+
</el-form-item>
19+
20+
<el-form-item label="作者" prop="bsubmitter">
21+
<el-input v-model="infoForm.bsubmitter"></el-input>
1622
</el-form-item>
1723
<!--使用编辑器
1824
-->
19-
<el-form-item label="详细">
25+
<el-form-item label="详细" prop="bcontent">
2026
<div class="edit_container">
21-
<quill-editor v-model="infoForm.a_content"
27+
<quill-editor v-model="infoForm.bcontent"
2228
ref="myQuillEditor"
2329
class="editer"
24-
:options="infoForm.editorOption" @ready="onEditorReady($event)">
30+
:options="editorOption" @ready="onEditorReady($event)">
2531
</quill-editor>
2632
</div>
2733
</el-form-item>
@@ -39,19 +45,26 @@
3945

4046
<script>
4147
import {quillEditor} from "vue-quill-editor"; //调用编辑器
48+
// require styles
49+
import 'quill/dist/quill.core.css'
50+
import 'quill/dist/quill.snow.css'
51+
import 'quill/dist/quill.bubble.css'
52+
53+
4254
export default {
4355
data() {
4456
return {
4557
infoForm: {
46-
a_title: "",
47-
a_source: "",
48-
a_content: "",
49-
editorOption: {}
58+
btitle: "",
59+
bsubmitter: "",
60+
bcategory:"技术博文",
61+
bcontent: ""
5062
},
63+
editorOption: {},
5164
//表单验证
5265
rules: {
53-
a_title: [{required: true, message: "请输入标题", trigger: "blur"}],
54-
a_content: [
66+
btitle: [{required: true, message: "请输入标题", trigger: "blur"}],
67+
bcontent: [
5568
{required: true, message: "请输入详细内容", trigger: "blur"}
5669
]
5770
}
@@ -73,8 +86,33 @@
7386
//this.$refs.infoForm.validate,这是表单验证
7487
this.$refs.infoForm.validate(valid => {
7588
if (valid) {
76-
debugger
89+
console.log(this.infoForm)
90+
var postPara=this.infoForm;
91+
this.$api.post("Blog", postPara, r => {
92+
debugger
93+
if(r.success){
94+
var id=r.response
95+
this.$notify({
96+
type: "success",
97+
message: "添加成功,感谢技术分享!",
98+
duration: 3000
99+
});
100+
this.$router.replace(`/content/${id}`);
101+
102+
}else{
103+
var errorMsg=r.msg
104+
this.$message({
105+
type: "error",
106+
message: errorMsg,
107+
showClose: true
108+
});
77109
110+
}
111+
this.list = r.data;
112+
this.page = r.page;
113+
this.TotalCount = r.pageCount;
114+
this.isShow = false;
115+
});
78116
}
79117
});
80118
}
@@ -93,7 +131,7 @@
93131
width: 75%;
94132
margin: 0 auto;
95133
}
96-
.ql-editor.ql-blank {
134+
.ql-container.ql-snow,.ql-editor.ql-blank {
97135
min-height: 300px !important;
98136
}
99137
.el-form{

0 commit comments

Comments
 (0)