系统:修改Slice栈;保证里面保留默认SliceId
authorCaisking <3449750381@qq.com>
Wed, 2 Oct 2024 08:34:49 +0000 (16:34 +0800)
committerCaisking <3449750381@qq.com>
Wed, 2 Oct 2024 08:34:49 +0000 (16:34 +0800)
code/sdk/application/wearable/nativeabilityfwk/include/Ability.h

index 56cea10..5db5bcd 100755 (executable)
@@ -92,11 +92,7 @@ public:
     /// @param priority 切换优先级
     bool Back(const TransitionType transitionId = TransitionType::TRANSITION_INVALID,
         const uint16_t priority = gSliceDefaultPriority) { 
-        /*
-        if (backStack_.empty()) {
-        backStack_.push(defaultSliceId_); // 将默认主界面的 ID 推入栈中
-        }
-        */
+         
         if (!backStack_.empty()) {
             uint16_t preSlice = backStack_.top();
             backStack_.pop();
@@ -105,7 +101,8 @@ public:
         }
         else
         {
-            // 当backStack为空时,退回到defaultSliceId_
+            backStack_.push(defaultSliceId_); // 将默认主界面的 ID 推入栈中
+            // 退回到defaultSliceId_
             ChangeSlice(defaultSliceId_, transitionId, priority);
             return false; // 返回false表示无前一个slice,退回到默认slice
         }
@@ -182,6 +179,9 @@ public:
         {
             backStack_.pop();
         }
+        if (backStack_.empty()) {
+        backStack_.push(defaultSliceId_); // 将默认主界面的 ID 推入栈中
+        }
     }
 
     /*打印栈中元素*/