refactor: convert menus to options (#190)

This commit is contained in:
YangQi 2022-08-23 22:22:01 +08:00 committed by GitHub
parent f89d85cc4e
commit b41f131f3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,38 +35,12 @@
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item <el-dropdown-item
class="format-item" class="format-item"
@click.native="$emit('addFormat', '**')" v-for="{ label, kbd, emitArgs } in formatItems"
:key="kbd"
@click.native="$emit(...emitArgs)"
> >
加粗 {{ label }}
<kbd> Ctrl + B </kbd> <kbd>{{ kbd }}</kbd>
</el-dropdown-item>
<el-dropdown-item
class="format-item"
@click.native="$emit('addFormat', '*')"
>
斜体
<kbd> Ctrl + I </kbd>
</el-dropdown-item>
<el-dropdown-item
class="format-item"
@click.native="$emit('addFormat', '~~')"
>
删除线
<kbd> Alt + Shift + U </kbd>
</el-dropdown-item>
<el-dropdown-item
class="format-item"
@click.native="$emit('addFormat', '[', ']()')"
>
超链接
<kbd> Alt + Shift + K </kbd>
</el-dropdown-item>
<el-dropdown-item
class="format-item"
@click.native="$emit('formatContent')"
>
格式化
<kbd> Ctrl + Alt + L </kbd>
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item divided @click.native="statusChanged"> <el-dropdown-item divided @click.native="statusChanged">
<i <i
@ -209,14 +183,7 @@ export default {
name: `editor-header`, name: `editor-header`,
data() { data() {
return { return {
form: { config,
dialogVisible: false,
title: ``,
desc: ``,
thumb: ``,
content: ``,
},
config: config,
citeStatus: false, citeStatus: false,
isMacCodeBlock: true, isMacCodeBlock: true,
showResetConfirm: false, showResetConfirm: false,
@ -224,6 +191,40 @@ export default {
selectSize: ``, selectSize: ``,
selectColor: ``, selectColor: ``,
selectCodeTheme: config.codeThemeOption[2].value, selectCodeTheme: config.codeThemeOption[2].value,
form: {
dialogVisible: false,
title: ``,
desc: ``,
thumb: ``,
content: ``,
},
formatItems: [
{
label: `加粗`,
kbd: `Ctrl + B`,
emitArgs: [`addFormat`, `**`],
},
{
label: `斜体`,
kbd: `Ctrl + I`,
emitArgs: [`addFormat`, `*`],
},
{
label: `删除线`,
kbd: `Alt + Shift + U`,
emitArgs: [`addFormat`, `~~`],
},
{
label: `超链接`,
kbd: `Alt + Shift + K`,
emitArgs: [`addFormat`, `[`, `]()`],
},
{
label: `格式化`,
kbd: `Alt + Shift + L`,
emitArgs: [`formatContent`],
},
],
} }
}, },
components: { components: {
@ -232,12 +233,6 @@ export default {
ResetDialog, ResetDialog,
}, },
computed: { computed: {
effect() {
return this.nightMode ? `dark` : `light`
},
btnContent() {
return this.nightMode ? `浅色模式` : `暗黑模式`
},
btnType() { btnType() {
return this.nightMode ? `default` : `primary` return this.nightMode ? `default` : `primary`
}, },