当前位置: 首页 > 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页面再双击执行脚本
在这里插入图片描述
在这里插入图片描述

http://www.dtcms.com/a/175053.html

相关文章:

  • 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
  • 【MongoDB篇】MongoDB的事务操作!
  • LeetCode 1128. 等价多米诺骨牌对的数量 题解
  • C++ STL 基础与多线程安全性说明文档
  • Visual Studio 快捷键更改和设置
  • 使用ip池后,爬虫还被封,是什么原因呢?
  • Zoho在2025:三个支点和一个新故事
  • 数据管理平台是什么?企业应如何做好数据化管理?
  • MySQL数据库中篇
  • 【STM32项目实战】一文了解单片机的SPI驱动外设功能
  • Vue3 中用 canvas 封装抽奖转盘组件:设定中奖概率及奖项图标和名称