perf: 优化长按菜单位置

This commit is contained in:
kuaifan 2025-04-10 07:46:32 +08:00
parent 54a42a14b6
commit 77940c9430
3 changed files with 10 additions and 7 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="page-manage" :class="pageClass"> <div class="page-manage" :class="pageClass">
<div class="manage-box-menu"> <div ref="boxMenu" class="manage-box-menu">
<Dropdown <Dropdown
class="page-manage-menu-dropdown main-menu" class="page-manage-menu-dropdown main-menu"
trigger="click" trigger="click"
@ -1143,9 +1143,10 @@ export default {
this.operateItem = $A.isJson(projectItem) ? projectItem : {}; this.operateItem = $A.isJson(projectItem) ? projectItem : {};
this.$nextTick(() => { this.$nextTick(() => {
const rect = el.getBoundingClientRect(); const rect = el.getBoundingClientRect();
const parentRect = this.$refs.boxMenu?.getBoundingClientRect() || {top: 0, left: 0}
this.operateStyles = { this.operateStyles = {
left: `${event.clientX}px`, left: `${event.clientX - parentRect.left}px`,
top: `${rect.top + this.windowScrollY}px`, top: `${rect.top + this.windowScrollY - parentRect.top}px`,
height: rect.height + 'px', height: rect.height + 'px',
} }
this.operateVisible = true; this.operateVisible = true;

View File

@ -183,9 +183,10 @@ export default {
this.operateItem = $A.isJson(projectItem) ? projectItem : {}; this.operateItem = $A.isJson(projectItem) ? projectItem : {};
this.$nextTick(() => { this.$nextTick(() => {
const rect = el.getBoundingClientRect(); const rect = el.getBoundingClientRect();
const parentRect = this.$el.getBoundingClientRect() || {top: 0, left: 0}
this.operateStyles = { this.operateStyles = {
left: `${event.clientX}px`, left: `${event.clientX - parentRect.left}px`,
top: `${rect.top + this.windowScrollY}px`, top: `${rect.top + this.windowScrollY - parentRect.top}px`,
height: rect.height + 'px', height: rect.height + 'px',
} }
this.operateVisible = true; this.operateVisible = true;

View File

@ -1060,9 +1060,10 @@ export default {
this.operateVisible = false; this.operateVisible = false;
this.operateItem = $A.isJson(item) ? item : {}; this.operateItem = $A.isJson(item) ? item : {};
this.$nextTick(() => { this.$nextTick(() => {
const parentRect = this.$refs.list?.$el?.getBoundingClientRect() || {top: 0, left: 0}
this.operateStyles = { this.operateStyles = {
left: `${clientX}px`, left: `${clientX - parentRect.left}px`,
top: `${rect.top + this.windowScrollY}px`, top: `${rect.top + this.windowScrollY - parentRect.top}px`,
height: rect.height + 'px', height: rect.height + 'px',
} }
this.operateVisible = true; this.operateVisible = true;