mirror of
https://github.com/doocs/md.git
synced 2024-11-24 19:10:34 +08:00
fix: menu close bug
This commit is contained in:
parent
3151c4fe99
commit
33252765a4
@ -1,12 +1,12 @@
|
||||
<template>
|
||||
<ul v-show="value" id="menu" class="menu" :style="`left: ${left}px;top: ${top}px;`">
|
||||
<li v-for="item of list" :key="item.key" class="menu_item">
|
||||
<li v-for="item of list" :key="item.key" class="menu_item" @mousedown="onMouseDown(item.key)">
|
||||
<el-upload v-if="item.key === 'insertPic'" action="" class="li__upload"
|
||||
:show-file-list="false" :multiple="true" accept=".jpg,.jpeg,.png,.gif" name="file"
|
||||
:before-upload="beforeUpload">
|
||||
<span>{{item.text}}</span>
|
||||
<button class="btn-upload">{{item.text}}</button>
|
||||
</el-upload>
|
||||
<span v-else @click="$emit('menuTick', item.key)">{{item.text}}</span>
|
||||
<span v-else>{{item.text}}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
@ -70,6 +70,14 @@ export default {
|
||||
});
|
||||
return false;
|
||||
},
|
||||
onMouseDown(key){
|
||||
if (key == 'insertPic') {
|
||||
document.querySelector('.li__upload button').click()
|
||||
} else {
|
||||
this.$emit('menuTick', key)
|
||||
}
|
||||
this.$emit('closeMenu',false)
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@ -98,12 +106,22 @@ export default {
|
||||
color: white;
|
||||
background: rgb(139, 146, 148);
|
||||
}
|
||||
span {
|
||||
span,.btn-upload {
|
||||
text-align: center;
|
||||
display: inline-block;
|
||||
padding: 4px 0;
|
||||
width: 100%;
|
||||
}
|
||||
.btn-upload {
|
||||
margin: 0;
|
||||
border:none;
|
||||
outline: none;
|
||||
background: transparent;
|
||||
}
|
||||
.btn-upload:hover {
|
||||
color: white;
|
||||
background: rgb(139, 146, 148);
|
||||
}
|
||||
/deep/ .el-upload {
|
||||
width: 100%;
|
||||
}
|
||||
|
@ -98,16 +98,6 @@ const mutations = {
|
||||
state.editor.setValue(doc)
|
||||
}
|
||||
|
||||
state.editor.on('mousedown', function() {
|
||||
state.rightClickMenuVisible = false
|
||||
});
|
||||
state.editor.on('blur', function() {
|
||||
state.rightClickMenuVisible = false
|
||||
});
|
||||
state.editor.on('scroll', function() {
|
||||
state.rightClickMenuVisible = false
|
||||
});
|
||||
|
||||
},
|
||||
initCssEditorEntity(state) {
|
||||
state.cssEditor = CodeMirror.fromTextArea(
|
||||
|
@ -57,6 +57,7 @@
|
||||
:left="mouseLeft"
|
||||
:top="mouseTop"
|
||||
@menuTick="onMenuEvent"
|
||||
@closeMenu="closeRightClickMenu"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@ -158,6 +159,18 @@ export default {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.editor.on('mousedown', () => {
|
||||
this.$store.commit('setRightClickMenuVisible', false);
|
||||
});
|
||||
this.editor.on('blur', () => {
|
||||
//!影响到右键菜单的点击事件,右键菜单的点击事件在组件内通过mousedown触发
|
||||
this.$store.commit('setRightClickMenuVisible', false);
|
||||
});
|
||||
this.editor.on('scroll', () => {
|
||||
this.$store.commit('setRightClickMenuVisible', false);
|
||||
});
|
||||
|
||||
},
|
||||
initCssEditor() {
|
||||
this.initCssEditorEntity();
|
||||
@ -269,6 +282,9 @@ export default {
|
||||
this.mouseTop = e.clientY + 10;
|
||||
this.$store.commit('setRightClickMenuVisible', true);
|
||||
},
|
||||
closeRightClickMenu(){
|
||||
this.$store.commit('setRightClickMenuVisible', false);
|
||||
},
|
||||
onMenuEvent(type, info = {}) {
|
||||
switch (type) {
|
||||
case 'pageReset':
|
||||
|
Loading…
Reference in New Issue
Block a user