Przeglądaj źródła

fix: 修复在离开训练view 下的功能页面时, 相关资源没有清除的BUG

YuJing 2 tygodni temu
rodzic
commit
aa65d18b4c

+ 3 - 0
features/feature/src/main/ets/components/reagencyComp.ets

@@ -40,6 +40,9 @@ export struct reagencyComp {
       this.timeC = setInterval(() => {
         let location = this.generateBubbleLocation()
         this.getUIContext().animateTo({ duration: 300 }, () => {
+          if(this.bubbles.length == 10) {
+            this.deleteBubble(this.bubbles[0].id!, false)
+          }
           this.bubbles.push(location)
         })
       }, this.bubbleConnect.bubbleFrequency * 1000)

+ 4 - 0
features/feature/src/main/ets/pages/reagencyPage.ets

@@ -10,6 +10,10 @@ import { reagencyComp } from '../components/reagencyComp';
 struct reagencyPage {
   @Local vm: reagencyViewModel = new reagencyViewModel();
 
+  aboutToDisappear(): void {
+    this.vm.dispose();
+  }
+
   build() {
     NavDestination() {
       Column() {

+ 6 - 0
features/feature/src/main/ets/viewModel/PageVm/reagencyViewModel.ets

@@ -96,6 +96,12 @@ export class reagencyViewModel{
     this.avgTime =  Math.floor(sum)
   }
 
+  dispose() {
+    if(this.trainStarted == 1) {
+      this.toggleTrain()
+    }
+  }
+
   constructor() {
     this.safeTop = AppStorage.get(YTAvoid.SAFE_TOP_KEY) as number
     this.safeBottom = AppStorage.get(YTAvoid.SAFE_BOTTOM_KEY) as number

+ 3 - 0
features/feature/src/main/ets/viewModel/PageVm/stabilityViewModel.ets

@@ -114,6 +114,9 @@ export class stabilityViewModel{
 
   dispose(){
     sensor.off(sensor.SensorId.ORIENTATION);
+    if(this.trainStarted == 1) {
+      this.resetTrain()
+    }
   }