首页 » 网站建设 » php代码被vue编译技巧_vue反编译dist包到源码

php代码被vue编译技巧_vue反编译dist包到源码

访客 2024-10-26 0

扫一扫用手机浏览

文章目录 [+]

2.找到须要编译的dist/static/js的目录下 实行完成后在该目录会看到目录下存不才面的文件名:0.7ab7d1434ffcc747c1ca.js.map,这里以0.7ab7d1434ffcc747c1ca.js.map为例,如下图:

3.全局安装reverse-sourcemap资源

php代码被vue编译技巧_vue反编译dist包到源码

npm install --global reverse-sourcemap

php代码被vue编译技巧_vue反编译dist包到源码
(图片来自网络侵删)

4.反编译 实行:reverse-sourcemap --output-dir source 0.7ab7d1434ffcc747c1ca.js.map

2.脚本反编译

上面的办法实行完毕,确实在source中会涌现源码,那么有没有可能用脚本去实行呢,通过node的child_process模块中的exec办法便可以实行reverse-sourcemap --output-dir source这个命令,那么只须要拿到当前文件夹中包含.map文件即可,那么可以借助node中fs模块,递归读取文件名,并利用正则将所有.map的文件提取出来放在一个凑集或数组中,在对数组进行递归循环实行reverse-sourcemap --output-dir source这个命令

2.1根据child_process模块编写实行函数

function executeReverseSourceMap(outputDir) { // 构建 reverse-sourcemap 命令 const command = `reverse-sourcemap --output-dir source ${outputDir}`; // 实行命令 exec(command, (error, stdout, stderr) => { if (error) { console.error(`实行命令时出错:${error.message}`); return; } if (stderr) { console.error(`命令输出错误:${stderr}`); return; } console.log(`命令输出结果:${stdout}`); }); }

2.2读取文件并匹配文件

// // 读取文件夹中的文件fs.readdir(folderPath, (err, files) => { if (err) { console.error('读取文件夹时出错:', err); return; } // 遍历文件 files.forEach(file => { // 利用正则表达式匹配特定格式的文件名 const match = /^(\d+)\..+\.js\.map$/.exec(file); if (match) { // 如果匹配成功,将文件名存入数组 targetFiles.push(match[0]); } }); // 输出目标文件名数组 targetFiles.forEach(file=>{ executeReverseSourceMap(file) })});

2.3完全的实行代码

const fs = require('fs');const path = require('path');const { exec } = require('child_process');// 文件夹路径const folderPath = '../js';// 存放目标文件名的数组const targetFiles = [];function executeReverseSourceMap(outputDir) { // 构建 reverse-sourcemap 命令 const command = `reverse-sourcemap --output-dir source ${outputDir}`; // 实行命令 exec(command, (error, stdout, stderr) => { if (error) { console.error(`实行命令时出错:${error.message}`); return; } if (stderr) { console.error(`命令输出错误:${stderr}`); return; } console.log(`命令输出结果:${stdout}`); }); }// // 读取文件夹中的文件fs.readdir(folderPath, (err, files) => { if (err) { console.error('读取文件夹时出错:', err); return; } // 遍历文件 files.forEach(file => { // 利用正则表达式匹配特定格式的文件名 const match = /^(\d+)\..+\.js\.map$/.exec(file); if (match) { // 如果匹配成功,将文件名存入数组 targetFiles.push(match[0]); } }); // 输出目标文件名数组 targetFiles.forEach(file=>{ executeReverseSourceMap(file) })});

3终极结果展示图

作者:ws_qy链接:https://juejin.cn/post/7359893196439207972

标签:

相关文章

微信第三方登录便捷与安全的完美融合

社交平台已成为人们日常生活中不可或缺的一部分。微信作为我国最受欢迎的社交软件之一,拥有庞大的用户群体。为了方便用户在不同平台间切换...

网站建设 2025-02-18 阅读0 评论0

广东高速代码表解码高速公路管理智慧

高速公路作为国家交通动脉,连接着城市与城市,承载着巨大的物流和人流。广东作为我国经济大省,高速公路网络密布,交通流量巨大。为了更好...

网站建设 2025-02-18 阅读0 评论0