瀏覽代碼

更新日志改成bindSheet显示

onecold 1 年之前
父節點
當前提交
43c4a384fa
共有 2 個文件被更改,包括 31 次插入104 次删除
  1. 5 55
      entry/src/main/ets/dialog/OnlineUpdateLog.ets
  2. 26 49
      entry/src/main/ets/pages/NewIndex.ets

+ 5 - 55
entry/src/main/ets/dialog/OnlineUpdateLogDialog.ets → entry/src/main/ets/dialog/OnlineUpdateLog.ets

@@ -9,8 +9,8 @@ import { ConfigurationConstant } from '@kit.AbilityKit';
 import { AppUtil, PreferencesUtil } from '@pura/harmony-utils';
 import { CommonConstants } from '../common/constants/CommonConstants';
 
-@CustomDialog
-export default struct OnlineUpdateLogDialog {
+@Component
+export default struct OnlineUpdateLog {
   /** 弹窗控制器 */
   controller?: CustomDialogController;
   /** 关闭回调 */
@@ -129,67 +129,17 @@ export default struct OnlineUpdateLogDialog {
 
   build() {
     Column() {
-      // 标题栏
-      Row() {
-        Text('更新日志')
-          .fontSize(18)
-          .fontWeight(FontWeight.Bold)
-          .fontColor(Color.White)
-          .layoutWeight(1)
-        
-        Text('关闭')
-          .fontSize(14)
-          .fontColor(Color.White)
-          .padding({ left: 12, right: 12, top: 6, bottom: 6 })
-          .borderRadius(4)
-          .backgroundColor('rgba(255,255,255,0.2)')
-          .onClick(() => {
-            try {
-              this.markVersionShown();
-              if (this.onClose) {
-                this.onClose();
-              } else {
-                this.controller?.close();
-              }
-            } catch (error) {
-              console.error('OnlineUpdateLogDialog 关闭弹窗失败:', error);
-            }
-          })
-      }
-      .width('100%')
-      .height(48)
-      .padding({ left: 20, right: 20 })
-      .linearGradient(this.isDarkMode ? {
-        direction: GradientDirection.Right,
-        colors: [
-          ['#404040', 0.0],
-          ['#4A4A4A', 1.0]
-        ]
-      } : {
-        direction: GradientDirection.Right,
-        colors: [
-          [this.themeColor, 0.0],
-          [this.lightenColor(this.themeColor, 0.1), 1.0]
-        ]
-      })
-      .justifyContent(FlexAlign.SpaceBetween)
-      .alignItems(VerticalAlign.Center)
-      .borderRadius({
-        topLeft: 12,
-        topRight: 12,
-        bottomLeft: 0,
-        bottomRight: 0
-      })
+
 
       // 版本信息和进度条
       Column() {
         Row() {
           Text('当前版本:')
-            .fontSize(12)
+            .fontSize(15)
             .fontColor(this.isDarkMode ? '#E0E0E0' : Color.Gray)
           
           Text(`v${this.currentVersion}`)
-            .fontSize(12)
+            .fontSize(15)
             .fontColor(this.themeColor)
             .fontWeight(FontWeight.Medium)
         }

+ 26 - 49
entry/src/main/ets/pages/NewIndex.ets

@@ -36,7 +36,8 @@ import { ScanFilePage } from './ScanFilePage';
 import { AboutPage } from './AboutPage';
 import { smartMobilityCommon } from '@kit.CarKit';
 import { UpdateLogManager } from '../common/util/UpdateLogManager';
-import OnlineUpdateLogDialog from '../dialog/OnlineUpdateLogDialog';
+import OnlineUpdateLogDialog from '../dialog/OnlineUpdateLog';
+import OnlineUpdateLog from '../dialog/OnlineUpdateLog';
 
 const TAG = 'NewIndex'; // 日志标签
 
@@ -80,6 +81,7 @@ struct NewIndex {
   @StorageProp('windowWidth') windowWidth: number = 0;
   @StorageProp('windowHeight') windowHeight: number = 0;
   @StorageProp('isHiCarStatus') isHiCarStatus: boolean = false;
+  @State isShowUpdateDialog: boolean = false //是否显示更新日志开关
   /** 标题栏配置模型 */
   @State titleBarModel: TitleBar.Model = new TitleBar.Model()
     .setTitleTextStyle(FontStyle.Normal)
@@ -250,56 +252,15 @@ struct NewIndex {
     try {
       const shouldShow = await UpdateLogManager.checkAndShowUpdateLog();
       if (shouldShow) {
-        // 延迟显示,确保页面完全加载
-        setTimeout(() => {
-          this.showUpdateLogDialog();
-        }, 3000); // 3秒延迟,确保主页面完全加载
+          this.isShowUpdateDialog = !this.isShowUpdateDialog
       }
     } catch (error) {
       console.error('NewIndex checkAndShowUpdateLog error:', error);
     }
   }
 
-  /** 更新日志弹窗控制器 */
-  private updateLogDialogController?: CustomDialogController;
 
-  /**
-   * 显示更新日志弹窗
-   */
-  private showUpdateLogDialog() {
-    try {
-      // 如果已有弹窗,先关闭
-      if (this.updateLogDialogController) {
-        this.updateLogDialogController.close();
-        this.updateLogDialogController = undefined;
-      }
-
-      // 创建弹窗控制器
-      this.updateLogDialogController = new CustomDialogController({
-        builder: OnlineUpdateLogDialog({
-          onClose: () => {
-            // 弹窗关闭回调
-            if (this.updateLogDialogController) {
-              this.updateLogDialogController.close();
-              this.updateLogDialogController = undefined;
-            }
-          }
-        }),
-        autoCancel: false,
-        alignment: DialogAlignment.Center,
-        customStyle: true,
-        cancel: () => {
-          console.info('NewIndex 更新日志弹窗被取消');
-          this.updateLogDialogController = undefined;
-        }
-      });
 
-      this.updateLogDialogController.open();
-      console.info('NewIndex 更新日志弹窗已显示');
-    } catch (error) {
-      console.error('NewIndex 显示更新日志弹窗失败:', error);
-    }
-  }
 
   /**
    * 页面消失生命周期钩子
@@ -310,12 +271,7 @@ struct NewIndex {
     this.breakpointSystem.unregister();
     emitter.off(888);
     emitter.off(1001);
-    
-    // 清理更新日志弹窗
-    if (this.updateLogDialogController) {
-      this.updateLogDialogController.close();
-      this.updateLogDialogController = undefined;
-    }
+
   }
 
   build() {
@@ -353,6 +309,14 @@ struct NewIndex {
               })
           }
         }
+        .bindSheet($$this.isShowUpdateDialog, this.updateSheet(), {
+          height: '90%',
+          dragBar: true,
+          preferType: this.currentBreakpoint !== BreakpointTypeEnum.SM ? SheetType.CENTER : SheetType.BOTTOM,
+          showClose: true,
+          blurStyle: BlurStyle.Regular,
+          title: { title: '更新日志' }
+        })
       }
     }
     .showControlButton(false)
@@ -800,6 +764,19 @@ struct NewIndex {
     });
   }
 
+
+
+  @Builder
+  updateSheet() {
+    Scroll() {
+      Column() {
+        OnlineUpdateLog()
+      }
+    }
+    .width('100%')
+    .height('100%')
+  }
+
   // /**
   //  * ================== 穿山甲广告相关 ==================
   //  */