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

使用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页面再双击执行脚本
在这里插入图片描述
在这里插入图片描述

相关文章:

  • PyTorch常用命令详解:助力深度学习开发
  • day18-API(常见API,对象克隆)
  • yolov8 输出数据解释
  • 游戏的TypeScript(6)TypeScript的元编程
  • Spring 中四种常见初始化方法,对比 static {} 和 @PostConstruct 在并发,Spring 加载顺序大致为: JVM 加载类
  • 4.29 tag的完整实现和登录页面的初步搭建
  • Python 数据智能实战 (13):AI的安全可靠 - 电商数据智能的红线与指南
  • qt国际化翻译功能用法
  • 哈尔滨服务器租用
  • 亿级流量系统架构设计与实战(四)
  • 第九节:图像处理基础-图像几何变换 (缩放、旋转、平移、翻转)
  • 数据结构(一)——线性表的顺序表示和实现
  • Xcode16提交App Store审核时提示bitcode报错
  • 【coze】工作流(B站视频总结改写)
  • 什么是原子变量
  • 今日行情明日机会——20250506
  • The 2023 ICPC Asia Taoyuan Regional Programming Contest
  • C++自动重连机制设计与实现指南
  • 2025ACTF Web部分题解
  • Linux/AndroidOS中进程间的通信线程间的同步 - POSIX IPC
  • 杭温高铁、沪苏湖高铁明起推出定期票和计次票,不限车次执行优惠折扣
  • 国际上首次,地月空间卫星激光测距试验在白天成功实施
  • 山东滕州市醉驾交通事故肇事人员已被刑拘
  • 丁薛祥在学习《习近平经济文选》第一卷专题研讨班上强调:深入学习贯彻习近平经济思想,加强党中央对经济工作的集中统一领导
  • 被炒热的“高潮针”:超适应症使用,安全性和有效性存疑
  • 贵州召开全省安全生产电视电话会议:以最严要求最实举措守牢安全底线