fix: Webview

This commit is contained in:
msojocs 2022-02-05 15:34:47 +08:00
parent 5321bffed0
commit 1990a54a2d
5 changed files with 45 additions and 24 deletions

View File

@ -9,7 +9,7 @@
本项目修改自https://github.com/dragonation/wechat-devtools/
# 项目地址
* https://github.com/msojocs/wechat-devtools
* https://github.com/msojocs/wechat-devtools-linux
# 进度
@ -18,20 +18,18 @@
# 使用方法
可以在本项目的[发布](https://github.com/msojocs/wechat-devtools/releases)中,寻找已经构筑好了的`.tar.gz`包(发布里也有度盘链接),下载解压后,运行其中的`bin/wechat-devtools`即可运行。
可以在本项目的[发布](https://github.com/msojocs/wechat-devtools-linux/releases)中,寻找已经构筑好了的`.tar.xz`包(发布里也有度盘链接),下载解压后,运行其中的`bin/wechat-devtools`即可运行。
gitee上原来我也想放发布包的但是文件太大了附件最大只允许100M而且总体积不能超过1G。所以目前暂时先只放github如果大家发现下载速度慢的话可以考虑科学上网或者度盘链接速度快也稳定上传和下载。
# 系统要求
* 基于Linux的桌面系统首选GNOME其他的桌面环境可能会有问题未测试
* 安装有wine和wine-binfmt支持建议版本在5.0以上,低版本可能会存在有问题
* 安装有wine支持建议版本在5.0以上,低版本可能会存在有问题
* 非兼容版对glibc和libstdc++有一定的版本要求glibc的版本要求2.3libstdc++的版本要求3.4.26发布包里已经预编译了的Linux原生Node模块有这个依赖。兼容版本对这两个系统库的要求则较低如果发现非兼容版本运行有问题可以考虑尝试切换到兼容版本
* 如果运行的是Docker镜像版本请自行安装和编译Docker镜像仅用于测试
# CLI支持
在项目的`bin`目录中有`wechat-devtools-cli`命令是微信开发者工具的命令行支持Linux版本。相关料可以在[微信CLI命令行V2](https://developers.weixin.qq.com/miniprogram/dev/devtools/cli.html)上找到。
在项目的`bin`目录中有`wechat-devtools-cli`命令是微信开发者工具的命令行支持Linux版本。相关料可以在[微信CLI命令行V2](https://developers.weixin.qq.com/miniprogram/dev/devtools/cli.html)上找到。
# Docker支持
@ -46,15 +44,15 @@ Docker容器启动方法
如需要映射外部目录请自行修改Docker启动命令
# 构筑方法0推荐,支持断点续传
# 构筑方法0推荐
理论上此方法99%成功;在网络不稳定时容易失败(原因懂得都懂)
1. 请先在Linux环境中自行安装`wine``wine-binfmt`
1. 请先在Linux环境中自行安装`wine`
2. 请安装`docker` `docker-compose`
3. 克隆本项目:
```
git clone https://github.com/msojocs/wechat-devtools.git
git clone https://github.com/msojocs/wechat-devtools-linux.git
```
4. 在本地项目目录中执行如下的语句,构筑开发者工具:
```
@ -67,15 +65,15 @@ docker-compose up
之后即可通过点击应用图标启动微信开发者工具,也可以运行`bin/wechat-devtools`通过命令行启动
# 构筑方法1(支持断点续传)
# 构筑方法1
由于使用到`node-gyp`,此方法会受`python``node`版本影响出现一些难以预料的异常(比如使用`node15.0.1`时,大部分模块构建会被忽略,但没有任何报错信息)。但是,`Docker`构建方式会帮你处理好这些问题。
由于使用到`node-gyp` `nw-gyp`,此方法会受`python``node`版本影响出现一些难以预料的异常(比如使用`node15.0.1`时,大部分模块构建会被忽略,但没有任何报错信息)。但是,`Docker`构建方式会帮你处理好这些问题。
1. 请先在Linux环境中自行安装`wine``wine-binfmt`
2. 请安装nodejs并配置到PATH环境变量中;
1. 请先在Linux环境中自行安装`wine`
2. 请安装nodejs并配置到PATH环境变量中,版本不限;
3. 克隆本项目:
```
git clone https://github.com/msojocs/wechat-devtools.git
git clone https://github.com/msojocs/wechat-devtools-linux.git
```
4. 在本地项目目录中执行如下的语句,构筑开发者工具:
```
@ -90,20 +88,19 @@ git clone https://github.com/msojocs/wechat-devtools.git
# 与其他Linux下的微信开发者工具版本区别
1. 支持最新版本,并个人会持续更新,确保运行和测试OK才会上传Release
1. 支持最新版本,并个人会持续更新,在添加新的tag时actions会自动构建并上传Release
2. 自己制作了一个看得过去的图标,官方的太丑了;
3. 核心构筑过程完全开源,可以自行修改;
4. 修复了nwjs上关于Menu的段错误确保最新版本可以正常启动
5. 在构筑过程中会重新编译node_modules确保原生模块可以在Linux上正确运行
6. 可以随时更新开发者工具中的node和nwjs版本
7. 下载更新可以支持断点再续并使用了taobao国内的npm源加速下载
8. 使用了更为严谨的JS代码来控制整个构筑过程避免Shell中出现的各类异常
9. 手工做了一些VSCode编辑器界面的文字汉化有些菜单很奇怪的腾讯没有汉化掉
8. 使用了更为严谨的JS代码来控制整个构筑过程避免Shell中出现的各类异常。
# 后续计划
1. 增加Docker镜像的稳定性对Host要求比较高
2. [处理计划](https://github.com/msojocs/wechat-devtools/projects?type=beta)
2. [处理计划](https://github.com/msojocs/wechat-devtools-linux/projects?type=beta)
# FAQ
[GO](docs/FAQ.MD)

View File

@ -14,8 +14,8 @@ const parseFile = function (path) {
content.name = "wechat_devtools";
// 开启调试,更新参数
content['chromium-args'] = content['chromium-args'].replace('--disable-devtools', '').replace('--ignore-gpu-blacklist', '--ignore-gpu-blocklist') + ' --mixed-context'
content.window.height = content.window.width = 500
content['chromium-args'] = content['chromium-args'].replace('--disable-devtools', '').replace('--ignore-gpu-blacklist', '--ignore-gpu-blocklist') + ' --mixed-context'
content.window.height = content.window.width = 1000
fs.writeFileSync(path, JSON.stringify(content));
};

11
tools/fix-webview-manager Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
# 修复 webview manager
# 此bug导致一下功能异常:
# 1. 代码依赖分析不可用
# 2. 拓展中的“SERVICE MARKET RECOMMENDS”功能不可用
root_dir=$(cd `dirname $0`/.. && pwd -P)
package_dir="$root_dir/package.nw"
sed -i 's#module.exports = createWebviewManager;#module.exports = createWebviewManager,( /** @type {any} */ (window)).createWebviewManager = createWebviewManager;#g' "$package_dir/js/libs/vseditor/webview-resource/main.js"

View File

@ -102,12 +102,13 @@ cp -fr "${package_dir}/node_modules_tmp/node_modules/vscode-ripgrep/bin/rg" "${p
# wcc wcsc
# 预览编译
# cd "${package_dir}/js/vendor/" && rm -rf "wcc.exe" "wcsc.exe"
# cd "${package_dir}/js/vendor/" && rm -rf "wcc.exe"
# cp "${package_dir}/node_modules_tmp/node_modules/miniprogram-compiler/bin/linux/wcc" "${package_dir}/js/vendor/wcc.exe"
# wcc_md5=$( md5sum wcc.exe|cut -d ' ' -f1 ) && \
# sed -i 's/wcc.exe": ".*"/wcc.exe": "'"${wcc_md5}"'"/g' "config.json"
# cd "${package_dir}/js/vendor/" && rm -rf "wcsc.exe"
# cp "${package_dir}/node_modules_tmp/node_modules/miniprogram-compiler/bin/linux/wcsc" "${package_dir}/js/vendor/wcsc.exe"
# cd "${package_dir}/js/vendor" && \
# wcc_md5=$( md5sum wcc.exe|cut -d ' ' -f1 ) && \
# sed -i 's/wcc.exe": ".*"/wcc.exe": "'"${wcc_md5}"'"/g' "config.json" && \
# wcsc_md5=$( md5sum wcsc.exe|cut -d ' ' -f1 ) && \
# sed -i 's/wcsc.exe": ".*"/wcsc.exe": "'"${wcsc_md5}"'"/g' "config.json"

View File

@ -232,7 +232,7 @@ const patch_wechat_devtools_CLI = function () {
});
};
const patch_wechat_devtools_core = function () {
info("Patching wechat-devtools CLI supports");
info("Patching wechat-devtools cloud console supports");
return new Promise((resolve, reject) => {
spawn(path.resolve(__dirname, "fix-cloudconsole"), [], {
@ -242,6 +242,17 @@ const patch_wechat_devtools_core = function () {
});
});
};
const patch_wechat_devtools_webview = function () {
info("Patching wechat-devtools webview supports");
return new Promise((resolve, reject) => {
spawn(path.resolve(__dirname, "fix-webview-manager"), [], {
stdio: "inherit",
}).on("close", (code) => {
resolve();
});
});
};
const rebuild_wechat_devtools_node_modules = function () {
info("Rebuilding wechat-devtools node modules");
@ -306,6 +317,7 @@ const start = async () => {
await patch_wechat_devtools_editor_selection_autocopy();
await patch_wechat_devtools_CLI();
await patch_wechat_devtools_core();
await patch_wechat_devtools_webview();
await rebuild_wechat_devtools_node_modules();
await patch_wechat_devtools();
await patch_wcc_wcsc();