Showing
2 changed files
with
12 additions
and
9 deletions
| @@ -25,6 +25,7 @@ export struct WdWebComponent { | @@ -25,6 +25,7 @@ export struct WdWebComponent { | ||
| 25 | @State subjectData : string = '' | 25 | @State subjectData : string = '' |
| 26 | 26 | ||
| 27 | @StorageProp('currentBreakpoint') @Watch("currentChanged")currentBreakpoint: string = 'sm'; | 27 | @StorageProp('currentBreakpoint') @Watch("currentChanged")currentBreakpoint: string = 'sm'; |
| 28 | + @State userAgent:string = 'Mozilla/5.0 (Phone; OpenHarmony 5.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 ArkWeb/4.1.6.1 Mobile automobile/792 Android' | ||
| 28 | 29 | ||
| 29 | currentChanged(){ | 30 | currentChanged(){ |
| 30 | ///折叠屏转换 | 31 | ///折叠屏转换 |
| @@ -54,6 +55,9 @@ export struct WdWebComponent { | @@ -54,6 +55,9 @@ export struct WdWebComponent { | ||
| 54 | let url: string = event.data.getRequestUrl().toString() | 55 | let url: string = event.data.getRequestUrl().toString() |
| 55 | return this.onLoadIntercept(url); | 56 | return this.onLoadIntercept(url); |
| 56 | }) | 57 | }) |
| 58 | + .onControllerAttached(() => { | ||
| 59 | + this.webviewControl.setCustomUserAgent(this.userAgent); | ||
| 60 | + }) | ||
| 57 | } | 61 | } |
| 58 | } | 62 | } |
| 59 | 63 |
| @@ -19,15 +19,6 @@ struct DefaultWebPage { | @@ -19,15 +19,6 @@ struct DefaultWebPage { | ||
| 19 | 19 | ||
| 20 | build() { | 20 | build() { |
| 21 | Column() { | 21 | Column() { |
| 22 | - Column() { | ||
| 23 | - WdWebComponent({ | ||
| 24 | - webviewControl: this.webviewControl, | ||
| 25 | - webUrl: this.webUrl, | ||
| 26 | - isPageEnd: $isPageEnd | ||
| 27 | - }) | ||
| 28 | - }.layoutWeight(1) | ||
| 29 | - | ||
| 30 | - | ||
| 31 | Row() { | 22 | Row() { |
| 32 | Button({ type: ButtonType.Normal }) { | 23 | Button({ type: ButtonType.Normal }) { |
| 33 | Image($r("app.media.back_icon_black")) | 24 | Image($r("app.media.back_icon_black")) |
| @@ -42,6 +33,14 @@ struct DefaultWebPage { | @@ -42,6 +33,14 @@ struct DefaultWebPage { | ||
| 42 | }.width("100%").height(44) | 33 | }.width("100%").height(44) |
| 43 | .alignItems(VerticalAlign.Center) | 34 | .alignItems(VerticalAlign.Center) |
| 44 | .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM]) | 35 | .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM]) |
| 36 | + | ||
| 37 | + Column() { | ||
| 38 | + WdWebComponent({ | ||
| 39 | + webviewControl: this.webviewControl, | ||
| 40 | + webUrl: this.webUrl, | ||
| 41 | + isPageEnd: $isPageEnd | ||
| 42 | + }) | ||
| 43 | + }.layoutWeight(1) | ||
| 45 | } | 44 | } |
| 46 | .width(CommonConstants.FULL_WIDTH) | 45 | .width(CommonConstants.FULL_WIDTH) |
| 47 | .height(CommonConstants.FULL_HEIGHT).padding({ | 46 | .height(CommonConstants.FULL_HEIGHT).padding({ |
-
Please register or login to post a comment