diff --git a/app/src/main/ets/pages/Index.ets b/app/src/main/ets/pages/Index.ets index 7f4364c..3657b24 100644 --- a/app/src/main/ets/pages/Index.ets +++ b/app/src/main/ets/pages/Index.ets @@ -8,22 +8,6 @@ import { Log } from '@devwiki/base'; import { BaseLocalStorage, ScreenUtil } from '@devwiki/base'; import { HomeItem, HomeItemGroup } from '../model/Home'; -@CustomDialog -struct WebViewDialog { - webUrl: string = "https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/password" - private webviewController: web_webview.WebviewController = new web_webview.WebviewController(); - dialogController: CustomDialogController; - @StorageLink(ScreenUtil.isPortraitKey) isPortrait: boolean = true; - - build() { - Row() { - Web({ src: this.webUrl, controller: this.webviewController }) - .javaScriptAccess(true)// 允许使用 js - .width('100%') - .height('100%'); - }.height(this.isPortrait ? '95%' : '90%').width(this.isPortrait ? '100%' : '50%') - } -} @Entry @Component @@ -62,13 +46,6 @@ struct Index { } ]; - - dialogController: CustomDialogController = new CustomDialogController({ - builder: WebViewDialog(), - alignment: DialogAlignment.BottomEnd, - customStyle: true - }) - aboutToAppear(): void { ScreenUtil.getInstance().initScreenSize(); BaseLocalStorage.getInstance().init(getContext(this)); diff --git a/app/src/main/ets/pages/media/AVPlayerPage.ets b/app/src/main/ets/pages/media/AVPlayerPage.ets index 117012a..517ea5b 100644 --- a/app/src/main/ets/pages/media/AVPlayerPage.ets +++ b/app/src/main/ets/pages/media/AVPlayerPage.ets @@ -1,3 +1,4 @@ +import { TitleBar } from '@devwiki/common_ui/Index'; import media from '@ohos.multimedia.media'; import Prompt from '@system.prompt'; @@ -58,11 +59,18 @@ struct AVPlayerPage{ build() { Column(){ - Button('播放').height(48).width(96) + TitleBar({ + title: "AVPlayer", + onLeftClicked: () => { + this.getUIContext().getRouter().back(); + } + }); + + Button('播放').height(48).width(96).margin({top: 100}) .onClick(()=>{ this.playMusic(); }) - }.justifyContent(FlexAlign.Center).align(Alignment.Center).width('100%').height('100%') + }.align(Alignment.Center).width('100%').height('100%') } async playMusic() { diff --git a/app/src/main/ets/pages/web/WebDialogPage.ets b/app/src/main/ets/pages/web/WebDialogPage.ets index 6dede72..673300c 100644 --- a/app/src/main/ets/pages/web/WebDialogPage.ets +++ b/app/src/main/ets/pages/web/WebDialogPage.ets @@ -1,16 +1,18 @@ import { ScreenUtil } from '@devwiki/base'; import { WebPage } from './WebPage'; +import { TitleBar } from '@devwiki/common_ui/src/main/ets/component/TitleBar'; @CustomDialog export struct WebPageDialog { - - @StorageLink(ScreenUtil.isPortraitKey)isPortrait: boolean = true; + @StorageLink(ScreenUtil.isPortraitKey) isPortrait: boolean = true; dialogController: CustomDialogController; build() { - WebPage({onTitleBarLeftClick: ()=> { - this.dialogController.close(); - }}).height(this.isPortrait ? '95%' : '90%').width(this.isPortrait ? '100%' : '50%') + WebPage({ + onTitleBarLeftClick: () => { + this.dialogController.close(); + } + }).height(this.isPortrait ? '95%' : '90%').width(this.isPortrait ? '100%' : '50%') } } @@ -18,6 +20,25 @@ export struct WebPageDialog { @Component export struct WebDialogPage { + dialogController: CustomDialogController = new CustomDialogController({ + builder: WebPageDialog(), + alignment: DialogAlignment.BottomEnd, + customStyle: true + }) + build() { + Column() { + TitleBar({ + title: 'WebDialogPage', + onLeftClicked: () => { + this.getUIContext().getRouter().back() + } + }) + Row(){ + Button("Click").width(100).height(32).onClick(() => { + this.dialogController.open(); + }) + }.height('100%').width('100%').justifyContent(FlexAlign.Center) + } } } \ No newline at end of file diff --git a/app/src/main/ets/pages/web/WebPage.ets b/app/src/main/ets/pages/web/WebPage.ets index d1a2f38..220d7c4 100644 --- a/app/src/main/ets/pages/web/WebPage.ets +++ b/app/src/main/ets/pages/web/WebPage.ets @@ -24,7 +24,13 @@ export struct WebPage { RelativeContainer() { TitleBar({ title: this.viewModel.pageTitle, - onLeftClicked: this.onTitleBarLeftClick, + onLeftClicked: () => { + if (this.onTitleBarLeftClick) { + this.onTitleBarLeftClick(); + } else { + this.getUIContext().getRouter().back() + } + }, rightIcon: CommonRes.getIconRefresh(), // 必须这么写 onTitleBarRightClick内部的代码才执行, // 直接 onRightClicked: this.onTitleBarRightClick 这么写, 代码不执行 @@ -76,7 +82,7 @@ class WebPageViewModel { webUrl: "https://devwiki.net" }; - pageTitle: ResourceStr = ""; + pageTitle: ResourceStr = "WebPage"; constructor() { } diff --git a/common_ui/src/main/ets/component/TitleBar.ets b/common_ui/src/main/ets/component/TitleBar.ets index 0c2756a..a8cf109 100644 --- a/common_ui/src/main/ets/component/TitleBar.ets +++ b/common_ui/src/main/ets/component/TitleBar.ets @@ -30,7 +30,7 @@ export struct TitleBar { @Prop rightText: ResourceStr = ""; @Prop rightIcon: Resource = $r("app.media.ic_close"); - @Prop rightMenuType: TitleBarMenuType = TitleBarMenuType.Icon; + @Prop rightMenuType: TitleBarMenuType = TitleBarMenuType.None; @Prop titleTextAlign: TextAlign = TextAlign.Start; @Prop titleVisible: Visibility = Visibility.Visible;