From aba671722860077afe4ff4fcbb2cec59d7da28ec Mon Sep 17 00:00:00 2001 From: DevWiki Date: Tue, 9 Apr 2024 17:54:16 +0800 Subject: [PATCH] webpage test --- app/src/main/ets/appability/AppAbility.ets | 1 - app/src/main/ets/pages/Index.ets | 4 ++++ app/src/main/ets/pages/WebPage.ets | 5 +++-- app/src/main/ets/pages/layout/LinearLayoutPage.ets | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/ets/appability/AppAbility.ets b/app/src/main/ets/appability/AppAbility.ets index ac4467d..17c91fc 100644 --- a/app/src/main/ets/appability/AppAbility.ets +++ b/app/src/main/ets/appability/AppAbility.ets @@ -11,7 +11,6 @@ export default class AppAbility extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - ScreenUtil.getInstance().initScreenSize(); } onDestroy(): void { diff --git a/app/src/main/ets/pages/Index.ets b/app/src/main/ets/pages/Index.ets index c6c24ef..0645238 100644 --- a/app/src/main/ets/pages/Index.ets +++ b/app/src/main/ets/pages/Index.ets @@ -16,6 +16,10 @@ struct Index { customStyle: true }) + aboutToAppear(): void { + ScreenUtil.getInstance().initScreenSize(); + } + onPageShow(): void { ScreenUtil.getInstance().setPreferredOrientation(window.Orientation.AUTO_ROTATION); } diff --git a/app/src/main/ets/pages/WebPage.ets b/app/src/main/ets/pages/WebPage.ets index b4713f0..96149c6 100644 --- a/app/src/main/ets/pages/WebPage.ets +++ b/app/src/main/ets/pages/WebPage.ets @@ -1,10 +1,11 @@ -import { WebView, ComponentConst, CommonRes, TitleBar, WebViewController } from '@devwiki/common_ui'; +import { WebView, ComponentConst, CommonRes, TitleBar, WebViewController, ScreenUtil } from '@devwiki/common_ui'; @Entry @Component export struct WebPage { @State viewModel: WebPageViewModel = new WebPageViewModel(); + @StorageLink(ScreenUtil.isPortraitKey)isPortrait: boolean = true; private webViewController?: WebPageController; aboutToAppear(): void { @@ -39,7 +40,7 @@ export struct WebPage { left: { anchor: ComponentConst.ContainerId, align: HorizontalAlign.Start } }).width('100%').id("divider") - WebView({ webUrl: this.viewModel?.webUrl, controller: this.webViewController }).width('100%') + WebView({ webUrl: this.isPortrait? this.viewModel?.webUrl : "https://blog.devwiki.net", controller: this.webViewController }).width('100%') .alignRules({ top: { anchor: "divider", align: VerticalAlign.Bottom }, left: { anchor: ComponentConst.ContainerId, align: HorizontalAlign.Start }, diff --git a/app/src/main/ets/pages/layout/LinearLayoutPage.ets b/app/src/main/ets/pages/layout/LinearLayoutPage.ets index afc20e3..1b4d4e5 100644 --- a/app/src/main/ets/pages/layout/LinearLayoutPage.ets +++ b/app/src/main/ets/pages/layout/LinearLayoutPage.ets @@ -18,6 +18,6 @@ struct LinearLayoutPage { Row().width('90%').height('10%').backgroundColor("#ff4455") Row().width('90%').height('10%').backgroundColor("#ff4455") Row().width('90%').height('10%').backgroundColor("#ff4455") - }.height('100%').width('100%') + }.width('100%') } } \ No newline at end of file