From c0c9d32b19fcd8e644b34253294c443479f3da3b Mon Sep 17 00:00:00 2001 From: wpp <58198665+879356503@users.noreply.github.com> Date: Fri, 28 Feb 2025 15:26:25 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=89=93=E5=BC=80=E6=89=80=E6=9C=89?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/module.json5 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 index 4c11abd..481560f 100644 --- a/entry/src/main/module.json5 +++ b/entry/src/main/module.json5 @@ -20,7 +20,9 @@ "description": "$string:module_desc", "mainElement": "EntryAbility", "deviceTypes": [ - "phone" + "phone", + "tablet", + "2in1" ], "deliveryWithInstall": true, "installationFree": false, -- Gitee From 527cecd1148a913a7b45e59a2fd164a03968d7b5 Mon Sep 17 00:00:00 2001 From: wpp <58198665+879356503@users.noreply.github.com> Date: Wed, 5 Mar 2025 21:27:51 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=85=AC=E7=BD=91=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ets/common/constants/CommonConstants.ets | 55 +++++++++++ .../main/ets/common/utils/ResourceUtil.ets | 91 +++++++++++++++++++ entry/src/main/ets/common/utils/Utils.ets | 38 ++++++++ .../main/ets/entryability/EntryAbility.ets | 86 ++++++++++++++---- entry/src/main/ets/pages/Index.ets | 46 ++++++++-- entry/src/main/resources/rawfile/config.json | 4 + 6 files changed, 291 insertions(+), 29 deletions(-) create mode 100644 entry/src/main/ets/common/constants/CommonConstants.ets create mode 100644 entry/src/main/ets/common/utils/ResourceUtil.ets create mode 100644 entry/src/main/ets/common/utils/Utils.ets create mode 100644 entry/src/main/resources/rawfile/config.json diff --git a/entry/src/main/ets/common/constants/CommonConstants.ets b/entry/src/main/ets/common/constants/CommonConstants.ets new file mode 100644 index 0000000..d92b62e --- /dev/null +++ b/entry/src/main/ets/common/constants/CommonConstants.ets @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Common constants for all features. + */ + +export class CommonConstants { + /** + * font weight is 500. + */ + static readonly FONT_WEIGHT_FIVE: number = 500; + + /** + * font weight is 500. + */ + static readonly FONT_WEIGHT_FOUR: number = 400; + + /** + * Width the percentage of the 100. + */ + static readonly FULL_WIDTH: string = '100%'; + + /** + * Height the percentage of the 100. + */ + static readonly FULL_HEIGHT: string = '100%'; + + /** + * Breakpoint sm. + */ + static readonly BREAK_POINT_SM: string = 'sm'; + + /** + * Breakpoint md. + */ + static readonly BREAK_POINT_MD: string = 'md'; + + /** + * Breakpoint lg. + */ + static readonly BREAK_POINT_LG: string = 'lg'; +} \ No newline at end of file diff --git a/entry/src/main/ets/common/utils/ResourceUtil.ets b/entry/src/main/ets/common/utils/ResourceUtil.ets new file mode 100644 index 0000000..584a74b --- /dev/null +++ b/entry/src/main/ets/common/utils/ResourceUtil.ets @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { JSON, util } from '@kit.ArkTS'; + +const TAG: string = '[ResourceUtil]'; + +export class ResourceUtil { + /** + * Obtains the character string corresponding to the specified resource ID. + * + * @param resource resource. + */ + public static getResourceString(context: Context, resource: Resource): string { + if (ResourceUtil.isEmptyObj(resource)) { + return ''; + } + let resourceString: string = ''; + try { + resourceString = context.resourceManager.getStringSync(resource.id); + } catch (error) { + } + return resourceString; + } + + /** + * Check whether the object is empty. + * + * @param obj Objects to be checked. + * @returns Return true if the object is empty or has no properties; Otherwise return false. + */ + private static isEmptyObj(obj: Object): boolean { + if (obj === null || typeof obj !== 'object') { + return true; + } + return Object.keys(obj).length === 0; + } + + /** + * Get content from the raw file resource "config.json" by key. + * @param context The base context of an ability or an application. + * @param key The Json key value. + * @returns Return the value of the key. + */ + public static getRawFileStringByKey(context: Context, key: ConfigMapKey): string { + try { + const result: Uint8Array = context.resourceManager.getRawFileContentSync('config.json'); + const textDecoder = util.TextDecoder.create('utf-8', { ignoreBOM: true }); + const content: string = textDecoder.decodeToString(result, { stream: false }); + const jsonContent: ConfigMapData = JSON.parse(content) as ConfigMapData; + if (JSON.has(jsonContent, key)) { + const linkUrl: string = ResourceUtil.getDataByKey(jsonContent, key); + return linkUrl; + } + return ''; + } catch (error) { + return ''; + } + } + + private static getDataByKey(content: ConfigMapData, key: ConfigMapKey): string { + if (key === ConfigMapKey.GALLERY_URL) { + return content.url; + } else if (key === ConfigMapKey.BGIMAGE_URL) { + return content.bgImage; + } + return ''; + } +} + +export class ConfigMapData { + public url: string = ''; + public bgImage: string = ''; +} + +export enum ConfigMapKey { + GALLERY_URL = 'url', + BGIMAGE_URL = 'bgImage' +} \ No newline at end of file diff --git a/entry/src/main/ets/common/utils/Utils.ets b/entry/src/main/ets/common/utils/Utils.ets new file mode 100644 index 0000000..820d7bb --- /dev/null +++ b/entry/src/main/ets/common/utils/Utils.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { CommonConstants } from "../constants/CommonConstants"; + +export class BreakpointType { + sm: T; + md: T; + lg: T; + + constructor(sm: T, md: T, lg: T) { + this.sm = sm; + this.md = md; + this.lg = lg; + } + + getValue(currentBreakpoint: string): T { + if (currentBreakpoint === CommonConstants.BREAK_POINT_MD) { + return this.md; + } + if (currentBreakpoint === CommonConstants.BREAK_POINT_LG) { + return this.lg; + } else { + return this.sm; + } + } +} \ No newline at end of file diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 18f9c16..579b04b 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,54 +13,100 @@ * limitations under the License. */ +import { AbilityConstant, Configuration, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { display, window } from '@kit.ArkUI'; import { hilog } from '@kit.PerformanceAnalysisKit'; -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { window } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { resourceManager } from '@kit.LocalizationKit'; export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + private windowObj?: window.Window; + private curBp: string = ''; + + private updateBreakpoint(windowWidth: number): void { + let windowWidthVp = windowWidth / display.getDefaultDisplaySync().densityPixels; + let newBp: string = ''; + if (windowWidthVp < 600) { + newBp = 'sm'; + } else if (windowWidthVp < 840) { + newBp = 'md'; + } else { + newBp = 'lg'; + } + if (this.curBp !== newBp) { + this.curBp = newBp; + AppStorage.setOrCreate('currentBreakpoint', this.curBp); + } + } + + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? ''); - hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? ''); + AppStorage.setOrCreate('systemColorMode', this.context.config.colorMode); + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); } - onDestroy() { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + onConfigurationUpdate(newConfig: Configuration): void { + let newColorMode: ConfigurationConstant.ColorMode = + newConfig.colorMode || ConfigurationConstant.ColorMode.COLOR_MODE_DARK; + let currentColorMode = AppStorage.get('systemColorMode'); + if (newColorMode !== currentColorMode) { + AppStorage.setOrCreate('systemColorMode', newColorMode); + } + } + + onDestroy(): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); } - onWindowStageCreate(windowStage: window.WindowStage) { + onWindowStageCreate(windowStage: window.WindowStage): void { + windowStage.getMainWindow().then((windowObj: window.Window) => { + let type = window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR; + let avoidArea = windowObj.getWindowAvoidArea(type); + let bottomRectHeight = avoidArea.bottomRect.height; + AppStorage.setOrCreate('bottomRectHeight', bottomRectHeight); + type = window.AvoidAreaType.TYPE_SYSTEM; + avoidArea = windowObj.getWindowAvoidArea(type); + let topRectHeight = avoidArea.topRect.height; + AppStorage.setOrCreate('topRectHeight', topRectHeight); + this.windowObj = windowObj; + this.updateBreakpoint(windowObj.getWindowProperties().windowRect.width); + windowObj.on('windowSizeChange', (windowSize) => { + this.updateBreakpoint(windowSize.width); + }) + }); // Main window is created, set main page for this ability - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - + let context = this.context; + let resourceManager: resourceManager.ResourceManager = context.resourceManager; + AppStorage.setOrCreate('resourceManager', resourceManager); windowStage.loadContent('pages/Index', (err, data) => { if (err.code) { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR); hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); return; } - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + let windowClass: window.Window = windowStage.getMainWindowSync(); + let isLayoutFullScreen = true; + windowClass.setWindowLayoutFullScreen(isLayoutFullScreen).then(() => { + console.info('Succeeded in setting the window layout to full-screen mode.'); + }).catch((err: BusinessError) => { + console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); + }); }); } - onWindowStageDestroy() { + onWindowStageDestroy(): void { // Main window is destroyed, release UI related resources - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); } - onForeground() { + onForeground(): void { // Ability has brought to foreground - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); } - onBackground() { + onBackground(): void { // Ability has back to background - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); } } diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 0c44462..b865d0c 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -13,7 +13,11 @@ * limitations under the License. */ import { webview } from '@kit.ArkWeb'; +import { CommonConstants } from '../common/constants/CommonConstants'; +import { ConfigMapKey, ResourceUtil } from '../common/utils/ResourceUtil'; +import { BreakpointType } from '../common/utils/Utils'; import Logger from '../model/Logger'; +import { common } from '@kit.AbilityKit'; const TAG: string = '[Index]'; @@ -28,14 +32,16 @@ struct Index { 'console.info(\'webgame gameReset\'); if (_main.game.state === _main.game.state_GAMEOVER) {_main.game.state = _main.game.state_START; _main.start()}'; @State removeDesc: string = 'console.info(\'webgame removeDesc\'); y=document.getElementsByTagName(\'div\')[0]; y.parentNode.removeChild(y)'; - private imgRequestUrl: string = 'https://yangyunhe369.github.io/h5-game-blockBreaker/images/background.jpg'; + private imgRequestUrl: string = + ResourceUtil.getRawFileStringByKey(getContext(this) as common.UIAbilityContext, ConfigMapKey.BGIMAGE_URL); controller: webview.WebviewController = new webview.WebviewController(); responseweb: WebResourceResponse = new WebResourceResponse(); + @StorageLink('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; build() { Row() { Column() { - Button('Start', { type: ButtonType.Capsule }) + Button('start', { type: ButtonType.Capsule }) .onClick(() => { try { this.controller.loadUrl('javascript:' + this.gameStart); @@ -43,6 +49,7 @@ struct Index { Logger.info(TAG, `loadUrl gameStart fail: ${JSON.stringify(error)}`); } }) + .margin({ bottom: $r('sys.float.padding_level4') }) Button('L', { type: ButtonType.Capsule }) .width(50) .height(100) @@ -60,10 +67,14 @@ struct Index { }) ) } - .width('8%') + .width(new BreakpointType(60, 60, 80).getValue(this.curBp)) - Column() { - Web({ src: 'https://yangyunhe369.github.io/h5-game-blockBreaker/', controller: this.controller }) + Stack({ alignContent: Alignment.TopStart }) { + Web({ + src: ResourceUtil.getRawFileStringByKey(getContext(this) as common.UIAbilityContext, + ConfigMapKey.GALLERY_URL), + controller: this.controller + }) .domStorageAccess(true) .onlineImageAccess(true) .imageAccess(true) @@ -87,11 +98,16 @@ struct Index { Logger.info(TAG, `loadUrl removeDesc fail: ${JSON.stringify(error)}`); } }) + Column() + .height(new BreakpointType(16, 12, 17.75).getValue(this.curBp)) + .width(new BreakpointType(700, 600, 900).getValue(this.curBp)) + .backgroundColor($r('sys.color.background_secondary')) } - .width('78%') + .height(new BreakpointType(300, 312.5, 469).getValue(this.curBp)) + .width(new BreakpointType(700, 600, 900).getValue(this.curBp)) Column() { - Button('Reset', { type: ButtonType.Capsule }) + Button('reset', { type: ButtonType.Capsule }) .onClick(() => { try { this.controller.loadUrl('javascript:' + this.gameReset); @@ -99,6 +115,7 @@ struct Index { Logger.info(TAG, `loadUrl gameReset fail: ${JSON.stringify(error)}`); } }) + .margin({ bottom: $r('sys.float.padding_level4') }) Button('R', { type: ButtonType.Capsule }) .width(50) .height(100) @@ -116,8 +133,19 @@ struct Index { }) ) } - .width('8%') + .width(new BreakpointType(60, 60, 80).getValue(this.curBp)) } - .margin({ left: 36 }) + .justifyContent(FlexAlign.SpaceBetween) + .padding({ + left: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'), + $r('sys.float.padding_level16')).getValue(this.curBp), + right: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'), + $r('sys.float.padding_level16')).getValue(this.curBp), + }) + .height('100%') + .backgroundColor($r('sys.color.background_secondary')) + .width('100%') + + //.margin({ left: 36 }) } } \ No newline at end of file diff --git a/entry/src/main/resources/rawfile/config.json b/entry/src/main/resources/rawfile/config.json new file mode 100644 index 0000000..07a56e5 --- /dev/null +++ b/entry/src/main/resources/rawfile/config.json @@ -0,0 +1,4 @@ +{ + "url": "https://yangyunhe369.github.io/h5-game-blockBreaker/", + "bgImage": "https://yangyunhe369.github.io/h5-game-blockBreaker/images/background.jpg" +} \ No newline at end of file -- Gitee From 84a66eca96efd7f30d2dc64ce89b7ea80a8be10c Mon Sep 17 00:00:00 2001 From: wpp <58198665+879356503@users.noreply.github.com> Date: Sat, 8 Mar 2025 17:50:40 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=B7=B7=E6=B7=86?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/build-profile.json5 | 17 ++++++++++++++++- entry/obfuscation-rules.txt | 22 ++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 entry/obfuscation-rules.txt diff --git a/entry/build-profile.json5 b/entry/build-profile.json5 index 648265b..af8ccbc 100644 --- a/entry/build-profile.json5 +++ b/entry/build-profile.json5 @@ -14,9 +14,24 @@ */ { - "apiType": 'stageMode', + "apiType": "stageMode", "buildOption": { }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], "targets": [ { "name": "default" diff --git a/entry/obfuscation-rules.txt b/entry/obfuscation-rules.txt new file mode 100644 index 0000000..a1dfa0b --- /dev/null +++ b/entry/obfuscation-rules.txt @@ -0,0 +1,22 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file -- Gitee From 4b6796a27ecf89e10d583255139ceb32d732c032 Mon Sep 17 00:00:00 2001 From: wpp <58198665+879356503@users.noreply.github.com> Date: Tue, 18 Mar 2025 17:25:12 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9PC=E4=B8=8BWeb=E9=A1=B5?= =?UTF-8?q?=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ets/common/constants/CommonConstants.ets | 5 +++++ entry/src/main/ets/common/utils/Utils.ets | 11 +++++++---- entry/src/main/ets/entryability/EntryAbility.ets | 4 +++- entry/src/main/ets/pages/Index.ets | 16 ++++++++-------- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/entry/src/main/ets/common/constants/CommonConstants.ets b/entry/src/main/ets/common/constants/CommonConstants.ets index d92b62e..99b0ff8 100644 --- a/entry/src/main/ets/common/constants/CommonConstants.ets +++ b/entry/src/main/ets/common/constants/CommonConstants.ets @@ -52,4 +52,9 @@ export class CommonConstants { * Breakpoint lg. */ static readonly BREAK_POINT_LG: string = 'lg'; + + /** + * Breakpoint lg. + */ + static readonly BREAK_POINT_XL: string = 'xl'; } \ No newline at end of file diff --git a/entry/src/main/ets/common/utils/Utils.ets b/entry/src/main/ets/common/utils/Utils.ets index 820d7bb..8999bf3 100644 --- a/entry/src/main/ets/common/utils/Utils.ets +++ b/entry/src/main/ets/common/utils/Utils.ets @@ -18,21 +18,24 @@ export class BreakpointType { sm: T; md: T; lg: T; + xl: T; - constructor(sm: T, md: T, lg: T) { + constructor(sm: T, md: T, lg: T, xl: T) { this.sm = sm; this.md = md; this.lg = lg; + this.xl = xl; } getValue(currentBreakpoint: string): T { if (currentBreakpoint === CommonConstants.BREAK_POINT_MD) { return this.md; - } - if (currentBreakpoint === CommonConstants.BREAK_POINT_LG) { + } else if (currentBreakpoint === CommonConstants.BREAK_POINT_LG) { return this.lg; - } else { + } else if (currentBreakpoint === CommonConstants.BREAK_POINT_SM) { return this.sm; + } else { + return this.xl; } } } \ No newline at end of file diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 579b04b..171e836 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -30,8 +30,10 @@ export default class EntryAbility extends UIAbility { newBp = 'sm'; } else if (windowWidthVp < 840) { newBp = 'md'; - } else { + } else if (windowWidthVp < 1440) { newBp = 'lg'; + } else { + newBp = 'xl'; } if (this.curBp !== newBp) { this.curBp = newBp; diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index b865d0c..45eac5a 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -67,7 +67,7 @@ struct Index { }) ) } - .width(new BreakpointType(60, 60, 80).getValue(this.curBp)) + .width(new BreakpointType(60, 60, 80, 80).getValue(this.curBp)) Stack({ alignContent: Alignment.TopStart }) { Web({ @@ -99,12 +99,12 @@ struct Index { } }) Column() - .height(new BreakpointType(16, 12, 17.75).getValue(this.curBp)) - .width(new BreakpointType(700, 600, 900).getValue(this.curBp)) + .height(new BreakpointType(16, 12, 17.75, 17.75).getValue(this.curBp)) + .width(new BreakpointType(700, 600, 900, 1000).getValue(this.curBp)) .backgroundColor($r('sys.color.background_secondary')) } - .height(new BreakpointType(300, 312.5, 469).getValue(this.curBp)) - .width(new BreakpointType(700, 600, 900).getValue(this.curBp)) + .height(new BreakpointType(300, 312.5, 500, 500).getValue(this.curBp)) + .width(new BreakpointType(700, 600, 900, 1000).getValue(this.curBp)) Column() { Button('reset', { type: ButtonType.Capsule }) @@ -133,14 +133,14 @@ struct Index { }) ) } - .width(new BreakpointType(60, 60, 80).getValue(this.curBp)) + .width(new BreakpointType(60, 60, 80, 80).getValue(this.curBp)) } .justifyContent(FlexAlign.SpaceBetween) .padding({ left: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'), - $r('sys.float.padding_level16')).getValue(this.curBp), + $r('sys.float.padding_level16'), $r('sys.float.padding_level16')).getValue(this.curBp), right: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'), - $r('sys.float.padding_level16')).getValue(this.curBp), + $r('sys.float.padding_level16'), $r('sys.float.padding_level16')).getValue(this.curBp), }) .height('100%') .backgroundColor($r('sys.color.background_secondary')) -- Gitee