Browse Source

release包

徐勤民 6 tháng trước cách đây
mục cha
commit
abcaf8d019

+ 7 - 0
src/main/ets/bean/DeviceInfo.ets

@@ -0,0 +1,7 @@
+export class DeviceInfo{
+  ODID?:string
+  manufacture?:string
+  brand?:string
+  osFullName?:string
+
+}

+ 1 - 1
src/main/ets/utils/PreferencesHelper.ets

@@ -1,7 +1,7 @@
 import preferences from '@ohos.data.preferences';
 
 export class PreferencesHelper {
-  public static async put(key: string, value: preferences.ValueType | undefined) {
+  public static async put(key: string, value: preferences.ValueType | undefined | null) {
 
     const pref = await preferences.getPreferences(getContext(), 'PreferencesHelper')
     // 写入数据

+ 29 - 4
src/main/ets/utils/ToolsHelper.ets

@@ -1,6 +1,7 @@
 import promptAction from '@ohos.promptAction';
-import { BusinessError } from '@kit.BasicServicesKit';
-import { HashMap } from '@kit.ArkTS';
+import { BusinessError, deviceInfo } from '@kit.BasicServicesKit';
+import { HashMap, util } from '@kit.ArkTS';
+import { DeviceInfo } from '../bean/DeviceInfo';
 
 export interface Btn {
   text?: string | Resource;
@@ -67,12 +68,23 @@ function customDialogBuilder<T>(option: ListOptions<T>, dialogId: number) {
     .listDirection(Axis.Vertical) // 排列方向
     .scrollBar(BarState.Off)
     .friction(0.6)
-    .divider({ strokeWidth: 1, color: 0xEEEEEE, startMargin: 20, endMargin: 20 }) // 每行之间的分界线
+    .divider({
+      strokeWidth: 1,
+      color: 0xEEEEEE,
+      startMargin: 20,
+      endMargin: 20
+    }) // 每行之间的分界线
     .edgeEffect(EdgeEffect.Spring) // 边缘效果设置为Spring
     .width('100%')
     .height(option.values.length < 8 ? `${option.values.length / 16 * 100}%` : '50%')
     .margin({ top: 20 })
-  }.padding({ top: 20, bottom: 20, left: 20, right: 20 })
+  }
+  .padding({
+    top: 20,
+    bottom: 20,
+    left: 20,
+    right: 20
+  })
 }
 
 /**
@@ -209,4 +221,17 @@ export class ToolsHelper {
     }
     return undefined
   }
+
+  private static deviceInfo: DeviceInfo
+
+  static getDeviceInfo() {
+    if (!ToolsHelper.deviceInfo) {
+      ToolsHelper.deviceInfo = new DeviceInfo()
+      ToolsHelper.deviceInfo.ODID = deviceInfo.ODID
+      ToolsHelper.deviceInfo.manufacture = deviceInfo.manufacture
+      ToolsHelper.deviceInfo.brand = deviceInfo.brand
+      ToolsHelper.deviceInfo.osFullName = deviceInfo.osFullName
+    }
+    return ToolsHelper.deviceInfo
+  }
 }