From cb35aaca2bc09528dbb0d909b1c4bcb6d00f77d9 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Wed, 28 Oct 2026 16:00:18 +0000 Subject: [PATCH] =?UTF-8?q?perf(dialog):=20=E6=B6=88=E6=81=AF=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=BB=9A=E5=8A=A8=E4=B8=8D=E5=86=8D=E8=A7=A6=E5=8F=91?= =?UTF-8?q?=E5=85=A8=E9=83=A8=E6=B6=88=E6=81=AF=E9=87=8D=E6=B8=B2=E6=9F=93?= =?UTF-8?q?=EF=BC=8CMarkdown=20=E8=BD=AC=E6=8D=A2=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 滚动与渲染区间变化时 Wrapper 及所有可见消息被反复重渲染: - 已读判断收拢到 DialogWrapper.onVisibleRead,scrollIng、readEnabled 不再经 extraProps 下发 - 模板改读 scrollTailFar / scrollOffsetNear 布尔值,仅越过阈值时才触发渲染 - positionMsg 改依赖 unreadOneAbove,startMsgId 随区间变化不再带动 Wrapper 重渲染 Markdown: - MarkdownConver 结果按原文做 LRU 缓存(200 条) - 未标注语言的代码块只在常用语言子集中自动识别 移动端 4 倍降速滚动 8 秒实测:消息组件更新 1700 → 25 次,Wrapper 重渲染约 90 → 10 次,平均帧率 12 → 22。 --- resources/app | 2 +- .../js/pages/manage/components/DialogItem.vue | 41 ------------- .../pages/manage/components/DialogWrapper.vue | 61 ++++++++++++++++--- resources/assets/js/utils/markdown.js | 26 +++++++- 4 files changed, 77 insertions(+), 53 deletions(-) diff --git a/resources/app b/resources/app index 8380cb731..c71239985 160000 --- a/resources/app +++ b/resources/app @@ -1 +1 @@ -Subproject commit 8380cb7310f69303c984706a72c1759c72b94f24 +Subproject commit c7123998555f0aab6d3f56a289bdf4d6cef49f01 diff --git a/resources/assets/js/pages/manage/components/DialogItem.vue b/resources/assets/js/pages/manage/components/DialogItem.vue index 911075fee..be34cc3bd 100644 --- a/resources/assets/js/pages/manage/components/DialogItem.vue +++ b/resources/assets/js/pages/manage/components/DialogItem.vue @@ -120,14 +120,6 @@ export default { type: Number, default: 0 }, - scrollIng: { - type: Number, - default: 0 - }, - readEnabled: { - type: Boolean, - default: false - }, multiSelectMode: { type: Boolean, default: false @@ -149,10 +141,6 @@ export default { return this.simpleView || this.msgId === this.source.id }, - isNoRead() { - return this.isRightMsg || this.source.read_at - }, - isUnreadStart() { return this.unreadOne === this.source.id && this.source.id > 0 }, @@ -189,36 +177,7 @@ export default { }, }, - watch: { - readEnabled() { - this.msgRead(); - }, - windowActive() { - this.msgRead(); - }, - scrollIng() { - this.msgRead(); - }, - }, - methods: { - msgRead() { - if (this.isNoRead) { - return; - } - if (!this.readEnabled) { - return; - } - if (!this.windowActive) { - return; - } - if (!this.$el?.parentNode.classList.contains('item-enter')) { - return; - } - // 标记已读 - this.$store.dispatch("dialogMsgRead", this.source); - }, - formatTodoUser(data) { if ($A.isJson(data)) { const {userids} = data diff --git a/resources/assets/js/pages/manage/components/DialogWrapper.vue b/resources/assets/js/pages/manage/components/DialogWrapper.vue index 04a1b7b95..c9202ce0e 100644 --- a/resources/assets/js/pages/manage/components/DialogWrapper.vue +++ b/resources/assets/js/pages/manage/components/DialogWrapper.vue @@ -225,7 +225,7 @@