From 788e449b25736d4c4bfa82d7c0670cea584d9be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=8B=A4=E6=B0=91?= Date: Thu, 21 Nov 2024 15:22:13 +0800 Subject: [PATCH] =?UTF-8?q?refactor(app):=20=E4=BC=98=E5=8C=96=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E5=A4=84=E7=90=86=E5=92=8C=E8=AF=B7=E6=B1=82=E9=A2=91?= =?UTF-8?q?=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在多个组件中添加对 'cancel' 错误码的处理,提高用户体验- 在某些场景下增加请求频率限制,减少不必要的网络请求 - 优化部分页面的刷新逻辑,提高性能 --- src/main/ets/view/RefreshView.ets | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/ets/view/RefreshView.ets b/src/main/ets/view/RefreshView.ets index 88cb913..ffb6fd8 100644 --- a/src/main/ets/view/RefreshView.ets +++ b/src/main/ets/view/RefreshView.ets @@ -12,6 +12,7 @@ export struct RefreshView { private endY: number = 0 private lastNum: number = 0 private _openMore: boolean = false + private _oTime: number = 0 aboutToAppear(): void { this.onRefresh && this.onRefresh() @@ -43,7 +44,13 @@ export struct RefreshView { if (this.endY - this.startY < -100 && this._openMore) { const v = this.data && (this.data.length % this.pageSize) === 0 if (v) { - this.onLoadMore && this.onLoadMore(Math.floor(this.data.length / this.pageSize)) + + const cTime = new Date().getTime() + // 2024.11.21 测试觉得刷新太多了,暂时改为1秒5间隔 + if (cTime - this._oTime > 1500) { + this.onLoadMore && this.onLoadMore(Math.floor(this.data.length / this.pageSize)) + this._oTime = cTime + } } else { ToolsHelper.showMessage('没有更多数据了') }