diff --git a/resources/assets/js/functions/common.js b/resources/assets/js/functions/common.js index abe6c5524..abb322ea7 100755 --- a/resources/assets/js/functions/common.js +++ b/resources/assets/js/functions/common.js @@ -1045,6 +1045,21 @@ } }, + /** + * 按需滚动到View + * @param element + */ + scrollIntoViewIfNeeded(element) { + if (!element) { + return; + } + if (typeof element.scrollIntoViewIfNeeded === "function") { + element.scrollIntoViewIfNeeded() + } else { + $A.scrollToView(element, {block: "nearest", inline: "nearest"}) + } + }, + /** * 等比缩放尺寸 * @param width diff --git a/resources/assets/js/pages/manage.vue b/resources/assets/js/pages/manage.vue index e3edf3b11..59aeb297b 100644 --- a/resources/assets/js/pages/manage.vue +++ b/resources/assets/js/pages/manage.vue @@ -1030,10 +1030,7 @@ export default { this.$nextTick(() => { const active = this.$refs.menuProject.querySelector(".active") if (active) { - $A.scrollToView(active, { - behavior: 'instant', - scrollMode: 'if-needed', - }); + $A.scrollIntoViewIfNeeded(active); } }); }).catch(({msg}) => { diff --git a/resources/assets/js/pages/manage/components/ChatInput/index.vue b/resources/assets/js/pages/manage/components/ChatInput/index.vue index 8019a1aad..f11036b97 100755 --- a/resources/assets/js/pages/manage/components/ChatInput/index.vue +++ b/resources/assets/js/pages/manage/components/ChatInput/index.vue @@ -385,7 +385,7 @@ export default { } else if (!this.$isDesktop) { this.timerScroll = setInterval(() => { if (this.quill?.hasFocus()) { - this.$refs.editor.scrollIntoViewIfNeeded(); + $A.scrollIntoViewIfNeeded(this.$refs.editor); } else { clearInterval(this.timerScroll); } diff --git a/resources/assets/js/pages/manage/components/DialogView.vue b/resources/assets/js/pages/manage/components/DialogView.vue index 4683fba69..5d37045e0 100644 --- a/resources/assets/js/pages/manage/components/DialogView.vue +++ b/resources/assets/js/pages/manage/components/DialogView.vue @@ -10,7 +10,10 @@
+ v-longpress="{ + delay: 300, + callback: handleLongpress + }">

diff --git a/resources/assets/js/pages/manage/messenger.vue b/resources/assets/js/pages/manage/messenger.vue
index e7893f76d..7f88a3c2f 100644
--- a/resources/assets/js/pages/manage/messenger.vue
+++ b/resources/assets/js/pages/manage/messenger.vue
@@ -382,10 +382,7 @@ export default {
                 // 再次点击滚动到未读条目
                 const dialog = this.dialogList.find(dialog => $A.getDialogUnread(dialog) > 0)
                 if (dialog) {
-                    $A.scrollToView(this.$refs[`dialog_${dialog.id}`][0], {
-                        behavior: 'smooth',
-                        scrollMode: 'if-needed',
-                    })
+                    $A.scrollIntoViewIfNeeded(this.$refs[`dialog_${dialog.id}`][0])
                 }
             }
             this.dialogActive = type
@@ -517,10 +514,7 @@ export default {
                 if (this.$isDesktop && this.$refs.list) {
                     const active = this.$refs.list.querySelector(".active")
                     if (active) {
-                        $A.scrollToView(active, {
-                            behavior: 'instant',
-                            scrollMode: 'if-needed',
-                        });
+                        $A.scrollIntoViewIfNeeded(active);
                     } else {
                         const dialog = this.cacheDialogs.find(({id}) => id == this.dialogId)
                         if (dialog && this.dialogActive) {
@@ -528,10 +522,7 @@ export default {
                             this.$nextTick(() => {
                                 const active = this.$refs.list.querySelector(".active")
                                 if (active) {
-                                    $A.scrollToView(active, {
-                                        behavior: 'instant',
-                                        scrollMode: 'if-needed',
-                                    });
+                                    $A.scrollIntoViewIfNeeded(active);
                                 }
                             });
                         }