Browse Source

refactor(app): 优化错误处理和请求频率

- 在多个组件中添加对 'cancel' 错误码的处理,提高用户体验- 在某些场景下增加请求频率限制,减少不必要的网络请求
- 优化部分页面的刷新逻辑,提高性能
徐勤民 1 month ago
parent
commit
788e449b25
1 changed files with 8 additions and 1 deletions
  1. 8 1
      src/main/ets/view/RefreshView.ets

+ 8 - 1
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('没有更多数据了')
                 }