当前位置: 首页 > ds >正文

使用DevTools工具调试前端页面,便捷脚本,鸿蒙调试webView

参考官方文章

便捷脚本 创建文本,复制修改后缀为bat

建立bat文件

@echo off
setlocal enabledelayedexpansion:: Initialize port number and PID list
set PORT=9222
set PID_LIST=:: Get the list of all forwarded ports and PIDs
for /f "tokens=2,5 delims=:_" %%a in ('hdc fport ls') do (if %%a gtr !PORT! (set PORT=%%a)for /f "tokens=1 delims= " %%c in ("%%b") do (set PID_LIST=!PID_LIST! %%c)
):: Increment port number for next application
set temp_PORT=!PORT!
set /a temp_PORT+=1
set PORT=!temp_PORT!:: Get the domain socket name of devtools
for /f "tokens=*" %%a in ('hdc shell "cat /proc/net/unix | grep devtools"') do (set SOCKET_NAME=%%a:: Extract process IDfor /f "delims=_ tokens=4" %%b in ("!SOCKET_NAME!") do set PID=%%b:: Check if PID already has a mappingecho !PID_LIST! | findstr /C:" !PID! " >nulif errorlevel 1 (:: Add mappinghdc fport tcp:!PORT! localabstract:webview_devtools_remote_!PID!if errorlevel 1 (echo Error: Failed to add mapping.pauseexit /b):: Add PID to list and increment port number for next applicationset PID_LIST=!PID_LIST! !PID!set temp_PORT=!PORT!set /a temp_PORT+=1set PORT=!temp_PORT!)
):: If no process ID was found, prompt the user to open debugging in their application code and provide the documentation link
if "!SOCKET_NAME!"=="" (echo No process ID was found. Please open debugging in your application code using the corresponding interface. You can find the relevant documentation at this link: [https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/web/web-debugging-with-devtools.md]pauseexit /b
):: Check mapping
hdc fport lsecho.
echo Script executed successfully. Press any key to exit...
pause >nul:: Try to open the page in Edge
start msedge chrome://inspect/#devices.com:: If Edge is not available, then open the page in Chrome
if errorlevel 1 (start chrome chrome://inspect/#devices.com
)endlocal

调试页面

chrome://inspect/#devices

调试web页面再双击执行脚本
在这里插入图片描述
在这里插入图片描述

http://www.xdnf.cn/news/4327.html

相关文章:

  • 使用 ANSYS SIwave 求解器在 ANSYS AEDT 中预测串行通道性能并生成眼图
  • mysql-视图特性,用户管理和使用c连接
  • C++笔记
  • Web3 应用中常见的数据安全风险及防护措施
  • 使用AI应用开发平台搭建夸奖机器人,玩转AI【COZE入门案例-第1课】
  • 精益数据分析(43/126):媒体网站商业模式的盈利与指标解析
  • RAG框架搭建(基于Langchain+Ollama生成级RAG 聊天机器人)
  • Windows远程连接MySQL报错,本地navicat能连接MySQL
  • Docker安装使用
  • Android SDK 开发中的 AAR 与 JAR 区别详解
  • BUUCTF Pwn [ZJCTF 2019]Login WP
  • uv简单使用
  • Linux环境基础与开发工具使用
  • Linux——特殊权限管理
  • 用html+js+css实现的战略小游戏
  • C++内联函数
  • vue引入物理引擎matter.js
  • Transformer-LSTM混合模型在时序回归中的完整流程研究
  • 使用Unsloth微调DeepSeek-R1蒸馏模型:低显存高效训练实践
  • String 字符串基础和常用API
  • 钢厂首选,profinet转profibus在煤电项目中的协议转换解决方案
  • CAN报文中UDS部分的帧类型
  • ONLYOFFICE 文档 API :新的文档格式支持及配置方法
  • VNP46A3灯光遥感数据全球拼接并重采样
  • ArcGIS Pro图斑属性自动联动更新-在线卫星底图图斑采集
  • Kotlin密封类优化Android状态管理
  • 技术对暴力的削弱
  • 前端知识-forwardRef
  • 数字孪生储能充电站,实现智慧能源设施全景管控
  • 63.微服务保姆教程 (六) SkyWalking--分布式链路追踪系统/分布式的应用性能管理工具