chore: from value to visible (#186)

- 将 `value` 修改为 `visible`,并添加显式关闭方法
This commit is contained in:
YangQi 2022-08-17 14:00:46 +08:00 committed by GitHub
parent 99c0ce6a56
commit 5df723f88c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 26 deletions

View File

@ -2,8 +2,8 @@
<el-dialog <el-dialog
title="关于" title="关于"
class="about__dialog" class="about__dialog"
:visible="value" :visible="visible"
@close="$emit('input', false)" @close="$emit('close')"
width="30%" width="30%"
center center
> >
@ -37,7 +37,7 @@
<script> <script>
export default { export default {
props: { props: {
value: { visible: {
type: Boolean, type: Boolean,
default: false, default: false,
}, },

View File

@ -2,8 +2,8 @@
<el-dialog <el-dialog
title="插入表格" title="插入表格"
class="insert__dialog" class="insert__dialog"
:visible="value" :visible="visible"
@close="$emit('input', false)" @close="$emit('close')"
border border
> >
<el-row class="tb-options" type="flex" align="middle" :gutter="10"> <el-row class="tb-options" type="flex" align="middle" :gutter="10">
@ -44,7 +44,7 @@
</tr> </tr>
</table> </table>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button :type="btnType" @click="$emit('input', false)" plain> <el-button :type="btnType" @click="$emit('close')" plain>
</el-button> </el-button>
<el-button :type="btnType" @click="insertTable" plain> </el-button> <el-button :type="btnType" @click="insertTable" plain> </el-button>
@ -59,7 +59,7 @@ import { mapState, mapMutations } from 'vuex'
export default { export default {
props: { props: {
value: { visible: {
type: Boolean, type: Boolean,
default: false, default: false,
}, },
@ -95,7 +95,7 @@ export default {
this.rowNum = 3 this.rowNum = 3
this.colNum = 3 this.colNum = 3
this.editor.replaceSelection(`\n${table}\n`, `end`) this.editor.replaceSelection(`\n${table}\n`, `end`)
this.$emit(`input`, false) this.$emit(`close`)
this.editorRefresh() this.editorRefresh()
}, },
...mapMutations([`editorRefresh`]), ...mapMutations([`editorRefresh`]),

View File

@ -53,19 +53,19 @@ export default {
], ],
[ [
{ {
text: `导入 Markdown 文档`, text: `导入 .md 文档`,
key: `importMarkdown`, key: `importMarkdown`,
}, },
{ {
text: `导出 Markdown 文档`, text: `导出 .md 文档`,
key: `download`, key: `download`,
}, },
{ {
text: `导出 HTML 页面`, text: `导出 .html`,
key: `export`, key: `export`,
}, },
{ {
text: `格式化 Markdown 文档`, text: `格式化`,
key: `formatMarkdown`, key: `formatMarkdown`,
}, },
], ],
@ -75,7 +75,7 @@ export default {
methods: { methods: {
onMouseDown(key) { onMouseDown(key) {
this.$emit(`menuTick`, key) this.$emit(`menuTick`, key)
this.$emit(`closeMenu`, false) this.$emit(`closeMenu`)
}, },
}, },
} }

View File

@ -2,7 +2,7 @@
<el-dialog <el-dialog
title="本地上传" title="本地上传"
class="upload__dialog" class="upload__dialog"
:visible="value" :visible="visible"
@close="$emit('close')" @close="$emit('close')"
> >
<el-tabs type="activeName" v-model="activeName"> <el-tabs type="activeName" v-model="activeName">
@ -391,7 +391,7 @@ import CodeMirror from 'codemirror/lib/codemirror'
export default { export default {
props: { props: {
value: { visible: {
type: Boolean, type: Boolean,
default: false, default: false,
}, },

View File

@ -19,7 +19,7 @@
@export="exportEditorContent" @export="exportEditorContent"
@showCssEditor="showCssEditor = !showCssEditor" @showCssEditor="showCssEditor = !showCssEditor"
@show-about-dialog="aboutDialogVisible = true" @show-about-dialog="aboutDialogVisible = true"
@show-dialog-form="dialogFormVisible = true" @show-dialog-form="insertFormDialogVisible = true"
@show-dialog-upload-img="dialogUploadImgVisible = true" @show-dialog-upload-img="dialogUploadImgVisible = true"
@startCopy=";(isCoping = true), (backLight = true)" @startCopy=";(isCoping = true), (backLight = true)"
@endCopy="endCopy" @endCopy="endCopy"
@ -69,21 +69,27 @@
</el-container> </el-container>
<upload-img-dialog <upload-img-dialog
v-model="dialogUploadImgVisible" :visible="dialogUploadImgVisible"
@close="dialogUploadImgVisible = false" @close="dialogUploadImgVisible = false"
@beforeUpload="beforeUpload" @beforeUpload="beforeUpload"
@uploadImage="uploadImage" @uploadImage="uploadImage"
@uploaded="uploaded" @uploaded="uploaded"
></upload-img-dialog> ></upload-img-dialog>
<about-dialog v-model="aboutDialogVisible"></about-dialog> <about-dialog
<insert-form-dialog v-model="dialogFormVisible"></insert-form-dialog> :visible="aboutDialogVisible"
@close="aboutDialogVisible = false"
></about-dialog>
<insert-form-dialog
:visible="insertFormDialogVisible"
@close="insertFormDialogVisible = false"
></insert-form-dialog>
<right-click-menu <right-click-menu
:visible="rightClickMenuVisible" :visible="rightClickMenuVisible"
:left="mouseLeft" :left="mouseLeft"
:top="mouseTop" :top="mouseTop"
@menuTick="onMenuEvent" @menuTick="onMenuEvent"
@closeMenu="closeRightClickMenu" @closeMenu="rightClickMenuVisible = false"
></right-click-menu> ></right-click-menu>
<run-loading></run-loading> <run-loading></run-loading>
</div> </div>
@ -119,7 +125,7 @@ export default {
showCssEditor: false, showCssEditor: false,
aboutDialogVisible: false, aboutDialogVisible: false,
dialogUploadImgVisible: false, dialogUploadImgVisible: false,
dialogFormVisible: false, insertFormDialogVisible: false,
isCoping: false, isCoping: false,
isImgLoading: false, isImgLoading: false,
backLight: false, backLight: false,
@ -563,10 +569,7 @@ export default {
this.mouseTop = e.clientY + 10 this.mouseTop = e.clientY + 10
this.rightClickMenuVisible = true this.rightClickMenuVisible = true
}, },
closeRightClickMenu() { onMenuEvent(type) {
this.rightClickMenuVisible = false
},
onMenuEvent(type, info = {}) {
switch (type) { switch (type) {
case `resetStyle`: case `resetStyle`:
this.$refs.header.showResetConfirm = true this.$refs.header.showResetConfirm = true
@ -581,7 +584,7 @@ export default {
this.exportEditorContent() this.exportEditorContent()
break break
case `insertTable`: case `insertTable`:
this.dialogFormVisible = true this.insertFormDialogVisible = true
break break
case `importMarkdown`: case `importMarkdown`:
this.importMarkdownContent() this.importMarkdownContent()