From ab616c5d329cce44a85c7f147544fb5b3ad56408 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Thu, 17 Apr 2025 09:46:57 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E9=95=BF=E6=8C=89?= =?UTF-8?q?=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/assets/js/pages/manage.vue | 19 +++++--- .../pages/manage/components/DialogWrapper.vue | 48 +++++++++++-------- .../pages/manage/components/ProjectList.vue | 19 +++++--- .../assets/js/pages/manage/messenger.vue | 19 +++++--- resources/assets/sass/pages/common.scss | 13 +++++ .../sass/pages/components/dialog-wrapper.scss | 10 ---- .../sass/pages/components/project-list.scss | 10 ---- resources/assets/sass/pages/page-manage.scss | 9 ---- .../assets/sass/pages/page-messenger.scss | 9 ---- 9 files changed, 77 insertions(+), 79 deletions(-) diff --git a/resources/assets/js/pages/manage.vue b/resources/assets/js/pages/manage.vue index 952591a17..f59835ea0 100644 --- a/resources/assets/js/pages/manage.vue +++ b/resources/assets/js/pages/manage.vue @@ -155,7 +155,12 @@ -
+
{ + requestAnimationFrame(() => { const rect = element.getBoundingClientRect(); - const parentRect = this.$refs.boxMenu?.getBoundingClientRect() || {top: 0, left: 0} this.operateStyles = { - left: `${event.clientX - parentRect.left}px`, - top: `${rect.top + this.windowScrollY - parentRect.top}px`, - height: rect.height + 'px', + left: `${event.clientX}px`, + top: `${rect.top}px`, + height: `${rect.height}px`, } this.operateVisible = true; }) diff --git a/resources/assets/js/pages/manage/components/DialogWrapper.vue b/resources/assets/js/pages/manage/components/DialogWrapper.vue index 4f6b380f9..8731227e2 100644 --- a/resources/assets/js/pages/manage/components/DialogWrapper.vue +++ b/resources/assets/js/pages/manage/components/DialogWrapper.vue @@ -292,7 +292,12 @@
-
+
{ + requestAnimationFrame(() => { this.operateItem.clientX = event.clientX this.operateItem.clientY = event.clientY this.onSelectionchange() @@ -3146,34 +3152,36 @@ export default { return } // - const rect = el.getBoundingClientRect(); - const scrollerRect = this.$refs.scroller.$el.getBoundingClientRect(); - let top = rect.top + this.windowScrollY, - height = rect.height; + const rect = el.getBoundingClientRect(), + scrollerRect = this.$refs.scroller.$el.getBoundingClientRect(); + const operatePosition = { + left: this.operateItem.clientX, + top: rect.top, + height: rect.height + } if (rect.top < scrollerRect.top) { - top = scrollerRect.top - height -= scrollerRect.top - rect.top + operatePosition.top = scrollerRect.top + operatePosition.height -= scrollerRect.top - rect.top } if (rect.bottom > scrollerRect.bottom) { - height -= rect.bottom - scrollerRect.bottom + operatePosition.height -= rect.bottom - scrollerRect.bottom } - let left = this.operateItem.clientX if (this.windowWidth < 500) { if (this.operateItem.created_at) { - left = this.windowWidth / 2 + operatePosition.left = this.windowWidth / 2 } else { - left = rect.left + (rect.width / 2) + operatePosition.left = rect.left + (rect.width / 2) } } this.operateStyles = { - left: `${left}px`, - top: `${top}px`, - height: `${height}px`, + left: `${operatePosition.left}px`, + top: `${operatePosition.top}px`, + height: `${operatePosition.height}px`, } - if (this.location === 'messenger') { - this.operateStyles.marginTop = "calc(var(--status-bar-height) * -1)" - } - this.operateClient = {x: left, y: this.operateItem.clientY}; + this.operateClient = { + x: operatePosition.left, + y: this.operateItem.clientY + }; if (this.operateVisible) { try { this.$refs.operate.$refs.drop.popper.update() diff --git a/resources/assets/js/pages/manage/components/ProjectList.vue b/resources/assets/js/pages/manage/components/ProjectList.vue index f46d4da76..9879a62b0 100644 --- a/resources/assets/js/pages/manage/components/ProjectList.vue +++ b/resources/assets/js/pages/manage/components/ProjectList.vue @@ -56,7 +56,12 @@
-
+
import {mapState} from "vuex"; import longpress from "../../../directives/longpress"; +import TransferDom from "../../../directives/transfer-dom"; export default { name: "ProjectList", - directives: {longpress}, + directives: {longpress, TransferDom}, data() { return { projectKeyValue: '', @@ -189,13 +195,12 @@ export default { } this.operateVisible = false; this.operateItem = $A.isJson(projectItem) ? projectItem : {}; - this.$nextTick(() => { + requestAnimationFrame(() => { const rect = element.getBoundingClientRect(); - const parentRect = this.$el.getBoundingClientRect() || {top: 0, left: 0} this.operateStyles = { - left: `${event.clientX - parentRect.left}px`, - top: `${rect.top + this.windowScrollY - parentRect.top}px`, - height: rect.height + 'px', + left: `${event.clientX}px`, + top: `${rect.top}px`, + height: `${rect.height}px`, } this.operateVisible = true; }) diff --git a/resources/assets/js/pages/manage/messenger.vue b/resources/assets/js/pages/manage/messenger.vue index fde97605f..692ed7720 100644 --- a/resources/assets/js/pages/manage/messenger.vue +++ b/resources/assets/js/pages/manage/messenger.vue @@ -177,7 +177,12 @@
-
+
{ - const parentRect = this.$refs.select?.getBoundingClientRect() || {top: 0, left: 0} + requestAnimationFrame(() => { + const rect = element.getBoundingClientRect(); this.operateStyles = { left: `${event.clientX}px`, - top: `${rect.top + this.windowScrollY - parentRect.top}px`, - height: rect.height + 'px', + top: `${rect.top}px`, + height: `${rect.height}px`, } this.operateVisible = true; }) diff --git a/resources/assets/sass/pages/common.scss b/resources/assets/sass/pages/common.scss index 24ec956b7..bd1d72db1 100755 --- a/resources/assets/sass/pages/common.scss +++ b/resources/assets/sass/pages/common.scss @@ -999,3 +999,16 @@ body.window-portrait { margin-left: 54px; } } + +/*操作位置*/ +.operate-position { + position: absolute; + top: 0; + left: 0; + width: 1px; + height: auto; + margin-top: var(--window-scroll-y); + opacity: 0; + visibility: hidden; + pointer-events: none; +} diff --git a/resources/assets/sass/pages/components/dialog-wrapper.scss b/resources/assets/sass/pages/components/dialog-wrapper.scss index d218619b1..6fb233179 100644 --- a/resources/assets/sass/pages/components/dialog-wrapper.scss +++ b/resources/assets/sass/pages/components/dialog-wrapper.scss @@ -2073,16 +2073,6 @@ } } - .operate-position { - position: fixed; - top: 0; - left: 0; - width: 1px; - opacity: 0; - visibility: hidden; - pointer-events: none; - } - .apply-reasoning { margin: 0 0 12px 0; padding: 0 0 0 13px; diff --git a/resources/assets/sass/pages/components/project-list.scss b/resources/assets/sass/pages/components/project-list.scss index b46fad51f..fdc1d1c03 100644 --- a/resources/assets/sass/pages/components/project-list.scss +++ b/resources/assets/sass/pages/components/project-list.scss @@ -191,14 +191,4 @@ } } } - - .operate-position { - position: fixed; - top: 0; - left: 0; - width: 1px; - opacity: 0; - visibility: hidden; - pointer-events: none; - } } diff --git a/resources/assets/sass/pages/page-manage.scss b/resources/assets/sass/pages/page-manage.scss index 7ae0db187..f5e48f7c8 100644 --- a/resources/assets/sass/pages/page-manage.scss +++ b/resources/assets/sass/pages/page-manage.scss @@ -200,15 +200,6 @@ } } } - .operate-position { - position: fixed; - top: 0; - left: 0; - width: 1px; - opacity: 0; - visibility: hidden; - pointer-events: none; - } .manage-project-search { width: 80%; padding: 0 6px; diff --git a/resources/assets/sass/pages/page-messenger.scss b/resources/assets/sass/pages/page-messenger.scss index a153cb805..74059cb1a 100644 --- a/resources/assets/sass/pages/page-messenger.scss +++ b/resources/assets/sass/pages/page-messenger.scss @@ -555,15 +555,6 @@ } } } - .operate-position { - position: fixed; - top: 0; - left: 0; - width: 1px; - opacity: 0; - visibility: hidden; - pointer-events: none; - } } .messenger-msg { flex: 1;