| Name | Date | Size | #Lines | LOC | ||
|---|---|---|---|---|---|---|
| .. | - | - | ||||
| AppScope/ | 06-May-2025 | - | 36 | 33 | ||
| entry/ | 06-May-2025 | - | 803 | 696 | ||
| hvigor/ | 06-May-2025 | - | 24 | 22 | ||
| screenshots/device/ | 06-May-2025 | - | ||||
| .gitignore | D | 06-May-2025 | 121 | 10 | 10 | |
| README_zh.md | D | 06-May-2025 | 2.1 KiB | 65 | 43 | |
| build-profile.json5 | D | 06-May-2025 | 1 KiB | 42 | 41 | |
| hvigorfile.ts | D | 06-May-2025 | 772 | 17 | 1 | |
| hvigorw | D | 06-May-2025 | 2.1 KiB | 62 | 28 | |
| hvigorw.bat | D | 06-May-2025 | 2 KiB | 73 | 56 | |
| oh-package.json5 | D | 06-May-2025 | 816 | 27 | 25 | |
| ohosTest.md | D | 06-May-2025 | 593 | 11 | 7 |
README_zh.md
1# JS注入与执行 2 3### 介绍 4 5本示例基于H5游戏,通过arkui的button实现对游戏实现基本控制,展示webview的JS注入与执行能力,及native应用与H5的通信能力。 6 7本例的H5游戏页面,由https://yangyunhe369.github.io/h5-game-blockBreaker/ 提供 8 9### 效果预览 10 11|主页| 12|--------------------------------| 13|| 14 15使用说明 16 171.设备连接热点,可访问互联网。 18 192.打开应用,通过界面中按钮进行游戏控制。 20 21### 工程目录 22``` 23entry/src/main/ets/ 24|---entryability 25| |---EntryAbility.ts // 弹窗组件 26|---model 27| |---Logger.ts // 日志工具 28|---pages 29| |---Index.ets // 首页 30``` 31 32### 具体实现 33 34* 本示例分成一个模块 35 * 通过button实现对游戏的基本控制,WebviewController方法控制Web组件各种行为,使用webview注入JS与执行能力。 36 * 源码链接:[EntryAbility.ts](entry/src/main/ets/entryability/EntryAbility.ts),[Index.ets](entry/src/main/ets/pages/Index.ets) 37 * 接口参考:[@ohos.window](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/apis/js-apis-window.md),[@ohos.web.webview](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/apis/js-apis-webview.md) 38 39### 相关权限 40 41网络访问权限: [ohos.permission.INTERNET](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet) 42 43### 依赖 44 45不涉及。 46 47### 约束与限制 48 491.本示例仅支持标准系统上运行。 50 512.本示例已适配API version 9版本SDK,版本号:3.2.11.9。 52 533.本示例需要使用DevEco Studio 3.1 Beta2 (Build Version: 3.1.0.400, built on April 7, 2023)才可编译运行。 54 55### 下载 56 57如需单独下载本工程,执行如下命令: 58``` 59git init 60git config core.sparsecheckout true 61echo code/BasicFeature/Telephony/RunJsInWeb/ > .git/info/sparse-checkout 62git remote add origin https://gitee.com/openharmony/applications_app_samples.git 63git pull origin master 64 65```