Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
7487ba4f
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
7487ba4f
编写于
5月 27, 2022
作者:
B
bayanxing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add webView code
Signed-off-by:
N
bayanxing
<
bayanxing@kaihongdigi.com
>
上级
e6da9f19
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
1120 addition
and
0 deletion
+1120
-0
arkui/ace_ets_webView/entry/src/main/ets/MainAbility/pages/index.ets
...ts_webView/entry/src/main/ets/MainAbility/pages/index.ets
+63
-0
arkui/ace_ets_webView/entry/src/main/ets/MainAbility/pages/webEvent.ets
...webView/entry/src/main/ets/MainAbility/pages/webEvent.ets
+215
-0
arkui/ace_ets_webView/entry/src/main/ets/MainAbility/pages/webProp.ets
..._webView/entry/src/main/ets/MainAbility/pages/webProp.ets
+418
-0
arkui/ace_ets_webView/entry/src/main/ets/MainAbility/pages/webStyle.ets
...webView/entry/src/main/ets/MainAbility/pages/webStyle.ets
+424
-0
未找到文件。
arkui/ace_ets_webView/entry/src/main/ets/MainAbility/pages/index.ets
0 → 100644
浏览文件 @
7487ba4f
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets";
import testsuite from "../test/List.test.ets";
import featureAbility from "@ohos.ability.featureAbility";
@Entry
@Component
struct MyComponent {
aboutToAppear() {
console.info("start run testcase!!!!")
featureAbility.getWant()
.then((Want) => {
const core = Core.getInstance();
const expectExtend = new ExpectExtend({
'id': 'extend'
});
core.addService('expect', expectExtend);
const reportExtend = new ReportExtend(file);
core.addService('report', reportExtend);
core.init();
core.subscribeEvent('task', reportExtend);
const configService = core.getDefaultService('config');
console.info('parameters---->' + JSON.stringify(Want.parameters));
configService.setConfig(Want.parameters);
testsuite();
core.execute();
console.info('Operation successful. Data: ' + JSON.stringify(Want));
})
.catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
}
build() {
Flex({
direction: FlexDirection.Column,
alignItems: ItemAlign.Center,
justifyContent: FlexAlign.Center
}) {
Text('ACE WEBVIEW ETS TEST')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
arkui/ace_ets_webView/entry/src/main/ets/MainAbility/pages/webEvent.ets
0 → 100644
浏览文件 @
7487ba4f
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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.
*/
@Entry
@Component
struct Index {
@State javaScriptAccess: boolean = true;
@State fileAccess: boolean = true;
build() {
Column() {
Row(){
Web({ src:'www.baidu.com', controller:null })
.width('20%')
.height('100%')
.key("webViewOnAlert")
.onAlert((event?: {
url: string,
message: string,
result: JsResult
}) => {
console.log("onAlert: url -- " + event.url)
console.log("onAlert: message -- " + event.message)
event.result.handleCancel(()=>{
console.log("onAlert: handleCancel -- ")
})
event.result.handleConfirm()(()=>{
console.log("onAlert: handleConfirm -- ")
})
})
Divider().width("3%")
Web({ src:'www.baidu.com', controller:null })
.width('20%')
.height('100%')
.key("webViewOnBeforeUnload")
.onBeforeUnload((event?: {
url: string,
message: string,
result: JsResult
}) => {
console.log("onBeforeUnload: url -- " + event.url)
console.log("onBeforeUnload: message -- " + event.message)
event.result.handleCancel(()=>{
console.log("onBeforeUnload: handleCancel -- ")
})
event.result.handleConfirm()(()=>{
console.log("onBeforeUnload: handleConfirm -- ")
})
})
Divider().width("3%")
Web({ src:'www.baidu.com', controller:null })
.width('20%')
.height('100%')
.key("webViewOnConfirm")
.onConfirm((event?: {
url: string,
message: string,
result: JsResult
}) => {
console.log("onConfirm: url -- " + event.url)
console.log("onConfirm: message -- " + event.message)
event.result.handleCancel(()=>{
console.log("onConfirm: handleCancel -- ")
})
event.result.handleConfirm()(()=>{
console.log("onConfirm: handleConfirm -- ")
})
})
Divider().width("3%")
Web({ src:'www.baidu.com', controller:null })
.width('20%')
.height('100%')
.key("webViewOnConfirm")
.onConsole((event?: {
message: ConsoleMessage
}) => {
console.log("onConsole: getLineNumber -- " + event.message.getLineNumber())
console.log("onConsole: getSourceId -- " + event.message.getSourceId())
console.log("onConsole: getMessageLevel -- " + event.message.getMessageLevel())
console.log("onConsole: getMessage -- " + event.message.getMessage())
})
}
.width("100%")
.height("20%")
Divider().height("5%")
Row(){
Web({ src:'www.baidu.com', controller:null })
.width('20%')
.height('100%')
.key("webViewOnDownloadStart")
.onDownloadStart((event?: {
url:string,
userAgent:string,
contentDisposition:string,
mimetype: string,
contentLength: number
}) => {
console.log("onDownloadStart: url -- " + event.url)
console.log("onDownloadStart: userAgent -- " + event.userAgent)
console.log("onDownloadStart: contentDisposition -- " + event.contentDisposition)
console.log("onDownloadStart: mimetype -- " + event.mimetype)
console.log("onDownloadStart: contentLength -- " + event.contentLength)
})
Divider().width("3%")
Web({ src:'www.baidu.com', controller:null })
.width('20%')
.height('100%')
.key("webViewOnErrorReceive")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
Divider().width("3%")
Web({ src:'www.baidu.com', controller:null })
.width('20%')
.height('100%')
.key("webViewOnHttpErrorReceive")
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
Divider().width("3%")
Web({ src:'www.baidu.com', controller:null })
.width('20%')
.height('100%')
.key("webViewOnPageBegin")
.onPageBegin((event?: {
url: string
}) => {
console.log("onPageBegin: url -- " + event.url)
})
}
.width("100%")
.height("20%")
Divider().height("5%")
Row(){
Web({ src:'www.baidu.com', controller:null })
.width('20%')
.height('100%')
.key("webViewOnPageEnd")
.onPageEnd((event?: {
url: string
}) => {
console.log("onPageEnd: url -- " + event.url)
})
Divider().width("3%")
Web({ src:'www.baidu.com', controller:null })
.width('20%')
.height('100%')
.key("webViewOnProgressChange")
.onProgressChange((event?: {
newProgress: number
}) => {
console.log("onProgressChange: newProgress -- " + event.newProgress)
})
Divider().width("3%")
Web({ src:'www.baidu.com', controller:null })
.width('20%')
.height('100%')
.zoomAccess(true)
.key("webViewOnTitleReceive")
.onTitleReceive((event?: {
title: string
}) => {
console.log("onTitleReceive: title -- " + event.title)
})
}
.width("100%")
.height("20%")
}.width('100%')
.height('100%').backgroundColor("#ff0000")
}
}
\ No newline at end of file
arkui/ace_ets_webView/entry/src/main/ets/MainAbility/pages/webProp.ets
0 → 100644
浏览文件 @
7487ba4f
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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.
*/
@Entry
@Component
struct Index {
@State javaScriptAccess: boolean = true;
@State fileAccess: boolean = true;
build() {
Column() {
Row(){
Web({ src:$rawfile('test.html'), controller:null })
.width('20%')
.height('100%')
.domStorageAccess(true)
.key("webViewDomStorageAccessTrue")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
Divider().width("3%")
Web({ src:$rawfile('test.html'), controller:null })
.width('20%')
.height('100%')
.domStorageAccess(false)
.key("webViewDomStorageAccessFalse")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
Divider().width("3%")
Web({ src:$rawfile('test.html'), controller:null })
.width('20%')
.height('100%')
.fileAccess(true)
.key("webViewFileAccessTrue")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
Divider().width("3%")
Web({ src:$rawfile('test.html'), controller:null })
.width('20%')
.height('100%')
.fileAccess(false)
.key("webViewFileAccessFalse")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
}
.width("100%")
.height("20%")
Divider().height("5%")
Row(){
Web({ src:$rawfile('test.html'), controller:null })
.width('20%')
.height('100%')
.imageAccess(true)
.key("webViewImageAccessTrue")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
Divider().width("3%")
Web({ src:$rawfile('test.html'), controller:null })
.width('20%')
.height('100%')
.imageAccess(false)
.key("webViewImageAccessFalse")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
Divider().width("3%")
Web({ src:$rawfile('test.html'), controller:null })
.width('20%')
.height('100%')
.javaScriptAccess(true)
.key("webViewJavaScriptAccessTrue")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
Divider().width("3%")
Web({ src:$rawfile('test.html'), controller:null })
.width('20%')
.height('100%')
.javaScriptAccess(false)
.key("webViewJavaScriptAccessFalse")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
}
.width("100%")
.height("20%")
Divider().height("5%")
Row(){
Web({ src:$rawfile('test.html'), controller:null })
.width('20%')
.height('100%')
.onlineImageAccess(true)
.key("webViewOnlineImageAccessTrue")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
Divider().width("3%")
Web({ src:$rawfile('test.html'), controller:null })
.width('20%')
.height('100%')
.onlineImageAccess(false)
.key("webViewOnlineImageAccessFalse")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
Divider().width("3%")
Web({ src:$rawfile('test.html'), controller:null })
.width('20%')
.height('100%')
.zoomAccess(true)
.key("webViewZoomAccessTrue")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
Divider().width("3%")
Web({ src:$rawfile('test.html'), controller:null })
.width('20%')
.height('100%')
.zoomAccess(false)
.key("webViewZoomAccessFalse")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
}
.width("100%")
.height("20%")
Divider().height("5%")
Row(){
Web({ src:$rawfile('test.html'), controller:null })
.width('20%')
.height('100%')
.mixedMode(MixedMode.None)
.key("webViewMixedModeNone")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
Divider().width("3%")
Web({ src:$rawfile('test.html'), controller:null })
.width('20%')
.height('100%')
.mixedMode(MixedMode.All)
.key("webViewMixedModeAll")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
Divider().width("3%")
Web({ src:$rawfile('test.html'), controller:null })
.width('20%')
.height('100%')
.mixedMode(MixedMode.Compatible)
.key("webViewMixedModeCompatible")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
Divider().width("3%")
}
.width("100%")
.height("20%")
}.width('100%')
.height('100%').backgroundColor("#ff0000")
}
}
\ No newline at end of file
arkui/ace_ets_webView/entry/src/main/ets/MainAbility/pages/webStyle.ets
0 → 100644
浏览文件 @
7487ba4f
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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.
*/
@Entry
@Component
struct Index {
@State javaScriptAccess: boolean = true;
@State fileAccess: boolean = true;
build() {
Column() {
Row(){
Web({ src: $rawfile('index.html'), controller:null })
.width('30%')
.height('100%')
.fileAccess(this.fileAccess)
.key("webViewWidthPer")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
Divider().width("3%")
Web({ src: $rawfile('index.html'), controller:null })
.width(100)
.height('100%')
.fileAccess(this.fileAccess)
.key("webViewWidthPx")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
Divider().width("3%")
Web({ src: $rawfile('index.html'), controller:null })
.width('20%')
.height('80%')
.fileAccess(this.fileAccess)
.key("webViewHeightPer")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
Divider().width("3%")
Web({ src: $rawfile('index.html'), controller:null })
.width("20%")
.height(50)
.fileAccess(this.fileAccess)
.key("webViewHeightPx")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
}
.width("100%")
.height("30%")
Divider().height("5%")
Row(){
Web({ src: $rawfile('index.html'), controller:null })
.width('20%')
.height('100%')
.padding(10)
.fileAccess(this.fileAccess)
.key("webViewPaddingAll")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
Divider().width("3%")
Web({ src: $rawfile('index.html'), controller:null })
.width('20%')
.height('100%')
.padding({left:10,right:5,top:5,bottom:5})
.fileAccess(this.fileAccess)
.key("webViewPadding")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
Divider().width("3%")
Web({ src: $rawfile('index.html'), controller:null })
.width('20%')
.height('100%')
.margin(10)
.fileAccess(this.fileAccess)
.key("webViewMarginAll")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
Divider().width("3%")
Web({ src: $rawfile('index.html'), controller:null })
.width('20%')
.height('100%')
.margin({left:10,right:5,top:5,bottom:5})
.fileAccess(this.fileAccess)
.key("webViewMargin")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
}
.width("100%")
.height("30%")
Divider().height("5%")
Row(){
Web({ src: $rawfile('index.html'), controller:null })
.width('14%')
.height('100%')
.border({width:2,color:0x317AF7,radius:5,style:BorderStyle.Dashed})
.fileAccess(this.fileAccess)
.key("webViewBorderAll")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
Divider().width("3%")
Web({ src: $rawfile('index.html'), controller:null })
.width('14%')
.height('100%')
.borderWidth(3)
.fileAccess(this.fileAccess)
.key("webViewBorderWidth")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
Divider().width("3%")
Web({ src: $rawfile('index.html'), controller:null })
.width('14%')
.height('100%')
.borderColor(0x317AF7)
.fileAccess(this.fileAccess)
.key("webViewBorderColor")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
Divider().width("3%")
Web({ src: $rawfile('index.html'), controller:null })
.width('14%')
.height('100%')
.borderRadius(6)
.fileAccess(this.fileAccess)
.key("webViewBorderRadius")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
Divider().width("3%")
Web({ src: $rawfile('index.html'), controller:null })
.width('14%')
.height('100%')
.borderStyle(BorderStyle.Dashed)
.fileAccess(this.fileAccess)
.key("webViewBorderStyleDashed")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
Divider().width("3%")
Web({ src: $rawfile('index.html'), controller:null })
.width('14%')
.height('100%')
.borderStyle(BorderStyle.Solid)
.fileAccess(this.fileAccess)
.key("webViewBorderStyleSolid")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
Divider().width("3%")
Web({ src: $rawfile('index.html'), controller:null })
.width('14%')
.height('100%')
.borderStyle(BorderStyle.Dotted)
.fileAccess(this.fileAccess)
.key("webViewBorderStyleDotted")
.onErrorReceive((event?: {
request: WebResourceRequest,
error: WebResourceError
}) => {
console.log("onErrorReceive: errCode -- " + event.error.getErrorCode() +";errInfo -- " + event.error.getErrorInfo())
})
.onHttpErrorReceive((event?: {
request: WebResourceRequest,
response: WebResourceResponse
}) => {
console.log("onHttpErrorReceive: message -- " + event.response.getReasonMessage()
+";code -- " + event.response.getResponseCode()
+";data -- " + event.response.getResponseData()
+";enCoding -- " + event.response.getResponseEncoding()
+";header -- " + JSON.stringify(event.response.getResponseHeader())
+";mimeType -- " +event.response.getResponseMimeType())
})
}
.width("100%")
.height("30%")
}.width('100%')
.height('100%').backgroundColor("#ff0000")
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录