bug修复
这个提交包含在:
父节点
b6a5b3f98a
当前提交
bba0b2ed77
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* Use these variables when you tailor your ArkTS code. They must be of the const type.
|
* Use these variables when you tailor your ArkTS code. They must be of the const type.
|
||||||
*/
|
*/
|
||||||
export const HAR_VERSION = '1.0.2';
|
export const HAR_VERSION = '1.0.3';
|
||||||
export const BUILD_MODE_NAME = 'debug';
|
export const BUILD_MODE_NAME = 'debug';
|
||||||
export const DEBUG = true;
|
export const DEBUG = true;
|
||||||
export const TARGET_NAME = 'default';
|
export const TARGET_NAME = 'default';
|
||||||
|
|||||||
@ -270,7 +270,13 @@ WindowHelper.setWindowLayoutFullScreen(true)
|
|||||||
WindowHelper.hideStatusBar()
|
WindowHelper.hideStatusBar()
|
||||||
|
|
||||||
// 显示状态栏
|
// 显示状态栏
|
||||||
WindowHelper.showStatusBar
|
WindowHelper.showStatusBar()
|
||||||
|
|
||||||
|
// 顶部安全区高度
|
||||||
|
WindowHelper.topRectHeight()
|
||||||
|
|
||||||
|
// 底部安全区高度
|
||||||
|
WindowHelper.bottomRectHeight()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@szyx/sdk_base",
|
"name": "@szyx/sdk_base",
|
||||||
"version": "1.0.2",
|
"version": "1.0.3",
|
||||||
"description": "数字医信公司,鸿蒙app开发基础工具。",
|
"description": "数字医信公司,鸿蒙app开发基础工具。",
|
||||||
"main": "Index.ets",
|
"main": "Index.ets",
|
||||||
"author": "szyx",
|
"author": "szyx",
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import { picker } from '@kit.CoreFileKit';
|
|||||||
import { BusinessError } from '@kit.BasicServicesKit';
|
import { BusinessError } from '@kit.BasicServicesKit';
|
||||||
import { ToolsHelper } from '../utils/ToolsHelper';
|
import { ToolsHelper } from '../utils/ToolsHelper';
|
||||||
import { XWebParams } from '../utils/XWebHelper';
|
import { XWebParams } from '../utils/XWebHelper';
|
||||||
|
import { WindowHelper } from '../utils/WindowHelper';
|
||||||
|
|
||||||
@Entry({ routeName: 'XWebview' })
|
@Entry({ routeName: 'XWebview' })
|
||||||
@Preview
|
@Preview
|
||||||
@ -14,6 +15,7 @@ export struct XWebview {
|
|||||||
// 手机号
|
// 手机号
|
||||||
@State url: string = (router.getParams() as XWebParams).url
|
@State url: string = (router.getParams() as XWebParams).url
|
||||||
@State title?: string = (router.getParams() as XWebParams).title
|
@State title?: string = (router.getParams() as XWebParams).title
|
||||||
|
@State showMenu: boolean = (router.getParams() as XWebParams).showMenu ?? false
|
||||||
@State errorInfo: string | null = null
|
@State errorInfo: string | null = null
|
||||||
@State progress: number = 0
|
@State progress: number = 0
|
||||||
controller: web_webview.WebviewController = new web_webview.WebviewController();
|
controller: web_webview.WebviewController = new web_webview.WebviewController();
|
||||||
@ -72,7 +74,7 @@ export struct XWebview {
|
|||||||
if (this.dialogController != null) {
|
if (this.dialogController != null) {
|
||||||
this.dialogController.open()
|
this.dialogController.open()
|
||||||
}
|
}
|
||||||
})
|
}).visibility(this.showMenu ? Visibility.Visible : Visibility.Hidden)
|
||||||
}
|
}
|
||||||
.width('100%')
|
.width('100%')
|
||||||
.height(45)
|
.height(45)
|
||||||
@ -145,7 +147,9 @@ export struct XWebview {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.onErrorReceive((event) => { // 加载失败
|
.onErrorReceive((event) => { // 加载失败
|
||||||
if (this.progress > 65) return
|
if (this.progress > 65) {
|
||||||
|
return
|
||||||
|
}
|
||||||
if (event) {
|
if (event) {
|
||||||
this.errorInfo = `错误码:${event.error.getErrorCode()}\n${event.error.getErrorInfo()}`
|
this.errorInfo = `错误码:${event.error.getErrorCode()}\n${event.error.getErrorInfo()}`
|
||||||
} else {
|
} else {
|
||||||
@ -153,7 +157,9 @@ export struct XWebview {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.onHttpErrorReceive((event) => { // 加载失败
|
.onHttpErrorReceive((event) => { // 加载失败
|
||||||
if (this.progress > 65) return
|
if (this.progress > 65) {
|
||||||
|
return
|
||||||
|
}
|
||||||
if (event) {
|
if (event) {
|
||||||
this.errorInfo = `错误码:${event.response.getResponseCode()}\n${event.response.getReasonMessage()}`
|
this.errorInfo = `错误码:${event.response.getResponseCode()}\n${event.response.getReasonMessage()}`
|
||||||
} else {
|
} else {
|
||||||
@ -228,6 +234,10 @@ export struct XWebview {
|
|||||||
})
|
})
|
||||||
|
|
||||||
}.width('100%').height('100%')
|
}.width('100%').height('100%')
|
||||||
|
.padding({
|
||||||
|
top: WindowHelper.topRectHeight,
|
||||||
|
bottom: WindowHelper.bottomRectHeight
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -66,6 +66,9 @@ export class WindowHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static _windowClass: window.Window | undefined = undefined;
|
private static _windowClass: window.Window | undefined = undefined;
|
||||||
|
private static _isFullScreen: boolean = false;
|
||||||
|
private static _topRectHeight: number = 0;
|
||||||
|
private static _bottomRectHeight: number = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置窗口管理器
|
* 设置窗口管理器
|
||||||
@ -73,12 +76,39 @@ export class WindowHelper {
|
|||||||
*/
|
*/
|
||||||
public static set windowClass(value: window.Window | undefined) {
|
public static set windowClass(value: window.Window | undefined) {
|
||||||
WindowHelper._windowClass = value;
|
WindowHelper._windowClass = value;
|
||||||
|
if (WindowHelper._windowClass) {
|
||||||
|
let avoidArea = WindowHelper._windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR);
|
||||||
|
WindowHelper._bottomRectHeight = avoidArea.bottomRect.height
|
||||||
|
let avoidArea2 = WindowHelper._windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_CUTOUT);
|
||||||
|
WindowHelper._topRectHeight = avoidArea2.topRect.height
|
||||||
|
console.log('=====>', WindowHelper._topRectHeight)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前窗口管理器
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
public static get windowClass(): window.Window | undefined {
|
public static get windowClass(): window.Window | undefined {
|
||||||
return WindowHelper._windowClass;
|
return WindowHelper._windowClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取底部安全区高度
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
public static get bottomRectHeight(): number {
|
||||||
|
return WindowHelper._bottomRectHeight
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取顶部安全区高度
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
public static get topRectHeight(): number {
|
||||||
|
return WindowHelper._isFullScreen?WindowHelper._topRectHeight:0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置是否全屏
|
* 设置是否全屏
|
||||||
@ -86,6 +116,7 @@ export class WindowHelper {
|
|||||||
*/
|
*/
|
||||||
static setWindowLayoutFullScreen(isLayoutFullScreen: boolean) {
|
static setWindowLayoutFullScreen(isLayoutFullScreen: boolean) {
|
||||||
if (WindowHelper._windowClass) {
|
if (WindowHelper._windowClass) {
|
||||||
|
WindowHelper._isFullScreen = isLayoutFullScreen
|
||||||
WindowHelper._windowClass.setWindowLayoutFullScreen(isLayoutFullScreen);
|
WindowHelper._windowClass.setWindowLayoutFullScreen(isLayoutFullScreen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,7 @@ const XWebview = import('../pages/XWebview');
|
|||||||
export interface XWebParams {
|
export interface XWebParams {
|
||||||
url: string
|
url: string
|
||||||
title?: string
|
title?: string
|
||||||
|
showMenu?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export class XWebHelper {
|
export class XWebHelper {
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户