feat: reset style only (#108)

* reset style only
* close #107
This commit is contained in:
Yang Libin 2021-11-30 00:13:27 +08:00 committed by GitHub
parent 449617fd23
commit bc4a629222
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 16 deletions

View File

@ -31,11 +31,11 @@
> >
<i class="el-icon-document" size="medium" @click="$emit('export')"></i> <i class="el-icon-document" size="medium" @click="$emit('export')"></i>
</el-tooltip> </el-tooltip>
<!-- 页面重置 --> <!-- 样式重置 -->
<el-tooltip <el-tooltip
class="header__item" class="header__item"
:effect="effect" :effect="effect"
content="重置页面" content="重置样式"
placement="bottom-start" placement="bottom-start"
> >
<i <i
@ -316,11 +316,10 @@ export default {
this.setCssEditorValue(DEFAULT_CSS_CONTENT); this.setCssEditorValue(DEFAULT_CSS_CONTENT);
} }
}, },
// //
confirmReset() { confirmReset() {
localStorage.clear(); localStorage.clear();
this.clearEditorToDefault(); this.cssEditor.setValue(DEFAULT_CSS_CONTENT);
this.editor.focus();
this.citeStatus = false; this.citeStatus = false;
this.statusChanged(false); this.statusChanged(false);
this.fontChanged(this.config.builtinFonts[0].value); this.fontChanged(this.config.builtinFonts[0].value);
@ -337,7 +336,6 @@ export default {
this.editor.focus(); this.editor.focus();
}, },
...mapMutations([ ...mapMutations([
"clearEditorToDefault",
"setCurrentColor", "setCurrentColor",
"setCiteStatus", "setCiteStatus",
"themeChanged", "themeChanged",

View File

@ -5,7 +5,7 @@
:visible="showResetConfirm" :visible="showResetConfirm"
@close="$emit('close')" @close="$emit('close')"
> >
<div class="text">此操作将丢失本地缓存的文本和自定义样式是否继续?</div> <div class="text">此操作将丢失本地自定义样式是否继续?</div>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button :type="btnType" plain @click="$emit('close')"> </el-button> <el-button :type="btnType" plain @click="$emit('close')"> </el-button>
<el-button :type="btnType" @click="$emit('confirm')" plain <el-button :type="btnType" @click="$emit('confirm')" plain

View File

@ -47,8 +47,8 @@ export default {
key: "insertTable", key: "insertTable",
}, },
{ {
text: "页面重置", text: "恢复默认样式",
key: "pageReset", key: "resetStyle",
}, },
], ],
[ [

View File

@ -392,7 +392,7 @@ export default {
}, },
onMenuEvent(type, info = {}) { onMenuEvent(type, info = {}) {
switch (type) { switch (type) {
case "pageReset": case "resetStyle":
this.$refs.header.showResetConfirm = true; this.$refs.header.showResetConfirm = true;
break; break;
case "insertPic": case "insertPic":

View File

@ -154,12 +154,6 @@ const mutations = {
} }
state.output = output; state.output = output;
}, },
clearEditorToDefault(state) {
const doc = formatDoc(DEFAULT_CONTENT);
state.editor.setValue(doc);
state.cssEditor.setValue(DEFAULT_CSS_CONTENT);
},
}; };
export default new Vuex.Store({ export default new Vuex.Store({