Browse Source

SafeView.ets

徐勤民 2 months ago
parent
commit
72a5497762
1 changed files with 22 additions and 19 deletions
  1. 22 19
      src/main/ets/view/SafeView.ets

+ 22 - 19
src/main/ets/view/SafeView.ets

@@ -11,7 +11,7 @@ export interface TitleBarBtn {
 @Preview
 @Component
 export struct SafeView {
-  @Consume('pageInfos') pageInfos?: NavPathStack
+  pageInfos?: NavPathStack
   @Prop isLoading: boolean
   // 是不是沉浸式
   @Prop isImmersive: boolean
@@ -96,12 +96,12 @@ export struct SafeView {
           Row() {
             if (!this.onClickLeft?.img && this.onClickLeft) {
               Badge({
-                count:this.showBadgeLeft?1:0,
-                style:{
-                  badgeSize:6,
+                count: this.showBadgeLeft ? 1 : 0,
+                style: {
+                  badgeSize: 6,
                   badgeColor: Color.Red
                 }
-              }){
+              }) {
                 Text(`${this.onClickLeft?.text}` ?? '确定')
                   .fontColor(this.onClickLeft?.color ?? '#17171A')
                   .onClick(() => {
@@ -111,13 +111,13 @@ export struct SafeView {
             }
             if (this.onClickLeft?.img && this.onClickLeft) {
               Badge({
-                count:this.showBadgeLeft?1:0,
-                style:{
-                  badgeSize:6,
+                count: this.showBadgeLeft ? 1 : 0,
+                style: {
+                  badgeSize: 6,
                   badgeColor: '#FF6500',
                   color: '#FF6500'
                 }
-              }){
+              }) {
                 Image(this.onClickLeft.img)
                   .onClick(() => {
                     this.onClickLeft?.onClick && this.onClickLeft?.onClick()
@@ -129,13 +129,13 @@ export struct SafeView {
             }
             if (!this.onClickRight?.img && this.onClickRight) {
               Badge({
-                count:this.showBadgeRight?1:0,
-                style:{
-                  badgeSize:6,
+                count: this.showBadgeRight ? 1 : 0,
+                style: {
+                  badgeSize: 6,
                   badgeColor: '#FF6500',
                   color: '#FF6500'
                 }
-              }){
+              }) {
                 Text(this.onClickRight?.text ?? '确定')
                   .fontColor(this.onClickRight?.color ?? '#17171A')
                   .onClick(() => {
@@ -148,13 +148,13 @@ export struct SafeView {
             }
             if (this.onClickRight?.img && this.onClickRight) {
               Badge({
-                count:this.showBadgeRight?1:0,
-                style:{
-                  badgeSize:6,
+                count: this.showBadgeRight ? 1 : 0,
+                style: {
+                  badgeSize: 6,
                   badgeColor: '#FF6500',
                   color: '#FF6500'
                 }
-              }){
+              }) {
                 Image(this.onClickRight.img)
                   .onClick(() => {
                     this.onClickRight?.onClick && this.onClickRight?.onClick()
@@ -208,14 +208,17 @@ export struct SafeView {
     .hideTitleBar(true)
     .width('100%')
     .height('100%')
-    .backgroundColor(this.backgroundColorView??'#ffffff')
+    .backgroundColor(this.backgroundColorView ?? '#ffffff')
     .onBackPressed(() => {
       if (this.onBackEvent) {
         this.onBackEvent()
+        return true
       } else if (this.pageInfos) {
         this.pageInfos.pop()
+        return true
+      } else {
+        return false
       }
-      return true
     })
   }
 }