提交 62c7acc2 authored 作者: caicai's avatar caicai

修复鼠标右键位置获取

上级 474b268d
...@@ -141,8 +141,8 @@ class MainWindow { ...@@ -141,8 +141,8 @@ class MainWindow {
/* 获取分类窗口 */ /* 获取分类窗口 */
getWinCateOf(id) { getWinCateOf(id) {
let winId = ""; let winId = "";
console.log('窗口组',id) // console.log('窗口组',id)
console.log(this.group) // console.log(this.group)
let keys = Object.keys(this.group); let keys = Object.keys(this.group);
let targetIndex = keys.findIndex(v => this.group[v].route === '/category/'+id); let targetIndex = keys.findIndex(v => this.group[v].route === '/category/'+id);
if(targetIndex != -1) winId = keys[targetIndex]; if(targetIndex != -1) winId = keys[targetIndex];
...@@ -194,7 +194,7 @@ class MainWindow { ...@@ -194,7 +194,7 @@ class MainWindow {
typeof callback == 'function' && callback(win); typeof callback == 'function' && callback(win);
console.log('窗口id:' + win.id) // console.log('窗口id:' + win.id)
this.group[win.id] = { this.group[win.id] = {
route: args.route, route: args.route,
isMultiWindow: args.isMultiWindow, isMultiWindow: args.isMultiWindow,
......
...@@ -195,21 +195,23 @@ export default { ...@@ -195,21 +195,23 @@ export default {
this.closeMenu(); this.closeMenu();
return; return;
} }
let parentType = e.target.parentElement && let rightMenuElement = this.findParentEl({dataType:"right-menu", element:e.target});
e.target.parentElement.dataset.type || ''; // let parentType = e.target.parentElement &&
if ( // e.target.parentElement.dataset.type || '';
parentType !== 'right-menu' && // if (
e.target.dataset.type !== 'right-menu' // parentType !== 'right-menu' &&
) { // e.target.dataset.type !== 'right-menu'
return; // ) {
} // return;
// }
if(rightMenuElement == null) return;
let itemWrapElement = this.findParentEl({className:"item_wrap", element:e.target}); let itemWrapElement = this.findParentEl({className:"item_wrap", element:e.target});
// 需要显示右键菜单 // 需要显示右键菜单
this.menuPosition.left = (itemWrapElement && (itemWrapElement.offsetLeft+20)) || (e.layerX - 16); this.menuPosition.left = (itemWrapElement && (itemWrapElement.offsetLeft+20)) || (e.layerX - 16);
this.menuPosition.top = e.layerY; this.menuPosition.top = e.layerY;
this.menuPosition.id = parentType === 'right-menu' ? e.target.parentElement.dataset.id : e.target.dataset.id; this.menuPosition.id = rightMenuElement.dataset.id;
this.menuPosition.current = parentType === 'right-menu' ? e.target.parentElement.dataset.index : e.target.dataset.index; this.menuPosition.current = rightMenuElement.dataset.index;
this.showMenu = true; this.showMenu = true;
}, },
listener() { listener() {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div v-if="src && (src.indexOf('data:image/svg') == 0 || src.indexOf('data:image/png') == 0)" <div v-if="src && (src.indexOf('data:image/svg') == 0 || src.indexOf('data:image/png') == 0)"
class="item_wrap" @click="tapApp" data-type="right-menu" :data-id="detail.id" :data-index="index"> class="item_wrap" @click="tapApp" data-type="right-menu" :data-id="detail.id" :data-index="index">
<!-- <img :src="src" alt="" class="item_img" lazy> --> <!-- <img :src="src" alt="" class="item_img" lazy> -->
<el-image :src="src" alt="" class="item_img" :lazy="index>18"></el-image> <el-image :src="src" alt="" class="item_img" lazy></el-image>
<span class="item_name">{{name}}</span> <span class="item_name">{{name}}</span>
</div> </div>
</template> </template>
...@@ -70,6 +70,7 @@ export default { ...@@ -70,6 +70,7 @@ export default {
width: 42px; width: 42px;
height: 42px; height: 42px;
object-fit: contain; object-fit: contain;
overflow: visible; //确保鼠标右键位置获取正确
} }
.item_name { .item_name {
margin-top: 6px; margin-top: 6px;
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论