Browse Source

fix: 处理页面隐藏时定时器的清除(处理鸿蒙手机闪退问题)

wenxingxing 16 giờ trước cách đây
mục cha
commit
1240c88943
1 tập tin đã thay đổi với 14 bổ sung0 xóa
  1. 14 0
      pages/course/info.vue

+ 14 - 0
pages/course/info.vue

@@ -726,6 +726,10 @@ export default {
 				}, 5000);
 			}
 		}
+		// 重新启动章节奖励计时器(如果符合条件)
+		if (this.pickCatalog.videoId && (this.hasGotPageEntryReward == 1 || this.hasGotPageEntryReward == 2)) {
+			this.startPageEntryTimer();
+		}
 		this.playFun()
 		if (this.showPayTips) {
 			this.$refs.popTip.open();
@@ -743,6 +747,16 @@ export default {
 	onHide() {
 		const type = this.showAudio ? 'audio' : 'video'
 		this.pauseFun(type);
+		// 清理所有定时器,避免后台运行时资源泄漏
+		this.endCountsTime();
+		this.stopPageEntryTimer();
+		// 关闭WebSocket连接和心跳
+		if (this.socket != null) {
+			this.socket.close()
+			clearInterval(this.pingpangTimes)
+			this.pingpangTimes = null
+			this.socket = null
+		}
 	},
 	onUnload() {
 		if (this.socket != null) {