fix: 优化网络状况不佳时,下次不能继续的问题

This commit is contained in:
msojocs 2022-01-26 17:00:59 +08:00
parent 0c18dc853e
commit 42f9ecabeb
5 changed files with 33 additions and 19 deletions

View File

@ -24,4 +24,4 @@ USERDATADIR="$( echo ~ )/.config/wechat_devtools"
# "$@"参数 # "$@"参数
LANG=zh_CN.UTF-8 LANG=zh_CN.UTF-8
exec "$DIR"/../nwjs/nw $DIR/../package.nw $EXTENSION1 $INSPECTOR1 --user-data-dir=$USERDATADIR "$@" exec "$DIR"/../nwjs/nw $DIR/../package.nw $EXTENSION2 $INSPECTOR1 "$@"

View File

@ -42,7 +42,7 @@ Docker容器启动方法
如需要映射外部目录请自行修改Docker启动命令 如需要映射外部目录请自行修改Docker启动命令
# 构筑方法1推荐 # 构筑方法1推荐,支持断点续传
1. 请先在Linux环境中自行安装`wine``wine-binfmt` 1. 请先在Linux环境中自行安装`wine``wine-binfmt`
2. 请安装nodejs并配置到PATH环境变量中; 2. 请安装nodejs并配置到PATH环境变量中;

View File

@ -18,7 +18,7 @@
this.next(); return; this.next(); return;
} }
@.task.execute(@path(__dirname, "update-nwjs-node"), [], false, this.test); @.task.execute(@path(__dirname, "update-nwjs"), [], false, this.test);
}).then(function () { }).then(function () {

View File

@ -4,7 +4,7 @@ const fs = require("fs");
const { spawn } = require("child_process"); const { spawn } = require("child_process");
const init_node = function () { const init_node = function () {
console.info("Initializing node"); console.info("===============Initializing node=======================");
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (fs.existsSync(path.resolve(__dirname, "../node"))) { if (fs.existsSync(path.resolve(__dirname, "../node"))) {
resolve(); resolve();
@ -20,13 +20,14 @@ const init_node = function () {
); );
updateNode.on("close", (code) => { updateNode.on("close", (code) => {
console.log(`Update Node code: ${code}`); console.log(`Update Node code: ${code}`);
resolve(); if (code === 0) resolve();
else reject();
}); });
}); });
}; };
const init_nwjs = function () { const init_nwjs = function () {
console.info("Initializing nwjs"); console.info("==================Initializing nwjs==================");
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (fs.existsSync(path.resolve(__dirname, "../nwjs"))) { if (fs.existsSync(path.resolve(__dirname, "../nwjs"))) {
@ -43,12 +44,15 @@ const init_nwjs = function () {
); );
updateNwjs.on("close", (code) => { updateNwjs.on("close", (code) => {
console.log(`Update Nwjs result code: ${code}`); console.log(`Update Nwjs result code: ${code}`);
resolve(); if (code === 0) resolve();
else reject();
}); });
}); });
}; };
const init_wechat = function () { const init_wechat = function () {
console.info("Initializing wechat-devtools package"); console.info(
"==========Initializing wechat-devtools package=============="
);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (fs.existsSync(path.resolve(__dirname, "../package.nw"))) { if (fs.existsSync(path.resolve(__dirname, "../package.nw"))) {
@ -67,7 +71,8 @@ const init_wechat = function () {
console.log( console.log(
`Initializing wechat-devtools package result code:${code}` `Initializing wechat-devtools package result code:${code}`
); );
resolve(); if (code === 0) resolve();
else reject();
}); });
}); });
}; };

View File

@ -122,8 +122,13 @@ const download = function (url) {
}); });
ls.on("close", (code) => { ls.on("close", (code) => {
fs.renameSync(`${localPath}.tmp`, localPath); console.info(`Download Wechat DevTools Result Code: ${code}`);
resolve(localPath); if (code === 0){
fs.renameSync(`${localPath}.tmp`, localPath);
resolve(localPath);
}else{
reject()
}
}); });
}); });
}; };
@ -203,7 +208,7 @@ const patch_wechat_devtools_editor_selection_autocopy = function () {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
spawn(path.resolve(__dirname, "fix-selection-copy-node"), [], { spawn(path.resolve(__dirname, "fix-selection-copy-node"), [], {
stdio: 'inherit', stdio: "inherit",
}).on("close", (code) => { }).on("close", (code) => {
resolve(); resolve();
}); });
@ -213,12 +218,11 @@ const patch_wechat_devtools_CLI = function () {
info("Patching wechat-devtools CLI supports"); info("Patching wechat-devtools CLI supports");
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
spawn(path.resolve(__dirname, "fix-cli-node"), [], { stdio: "inherit" }).on( spawn(path.resolve(__dirname, "fix-cli-node"), [], {
"close", stdio: "inherit",
(code) => { }).on("close", (code) => {
resolve(); resolve();
} });
);
}); });
}; };
const rebuild_wechat_devtools_node_modules = function () { const rebuild_wechat_devtools_node_modules = function () {
@ -228,7 +232,12 @@ const rebuild_wechat_devtools_node_modules = function () {
spawn(path.resolve(__dirname, "rebuild-node-modules"), [], { spawn(path.resolve(__dirname, "rebuild-node-modules"), [], {
stdio: "inherit", stdio: "inherit",
}).on("close", (code) => { }).on("close", (code) => {
console.info(`Rebuilding wechat-devtools node modules Result Code: ${code}`)
if(0 === code)
resolve(); resolve();
else{
reject()
}
}); });
}); });
}; };
@ -282,7 +291,7 @@ const start = async () => {
); );
} catch (error) { } catch (error) {
console.error("异常", error); console.error("异常", error);
throw error throw error;
} }
}; };
start(); start();