diff --git a/b2f.js b/b2f.js new file mode 100644 index 0000000..b5beb80 --- /dev/null +++ b/b2f.js @@ -0,0 +1,16 @@ +import fs from "node:fs"; + +const args = process.argv.slice(2); + +if (args.length !== 1) { + process.exit(1); +} + +switch (args[0]) { + case "b2f": //backend to frontend + fs.renameSync("./backend/dist/core.exe", "./front/src-tauri/binaries/core-x86_64-pc-windows-msvc.exe") //后端文件复制 + break; + case "b2r": //build to root + fs.renameSync("./front/src-tauri/target/release/bundle/nsis/DeEarthX-V3_0.1.0_x64-setup.exe","./DeEarthX-V3_x64-setup.exe") + break; +} diff --git a/backend/package.json b/backend/package.json index 085ccfb..2114244 100644 --- a/backend/package.json +++ b/backend/package.json @@ -9,7 +9,7 @@ "scripts": { "test": "tsc&&node dist/main.js", "rollup": "rollup -c rollup.config.js", - "nexe": "nexe -i ./dist/bundle.js --build -t x86-22.13.0 --output ./dist/core-x86_64-pc-windows-msvc.exe", + "nexe": "nexe -i ./dist/bundle.js --build -t x86-22.13.0 --output ./dist/core.exe", "build": "npm run rollup && npm run nexe" }, "devDependencies": { diff --git a/backend/src/Dex.ts b/backend/src/Dex.ts index b39f200..596e6e5 100644 --- a/backend/src/Dex.ts +++ b/backend/src/Dex.ts @@ -22,39 +22,52 @@ export class Dex { } public async Main(buffer: Buffer, dser: boolean) { + try{ const first = Date.now(); - const info = await this._getinfo(buffer); + const info = await this._getinfo(buffer).catch((e)=>{ + throw new Error(e) + }); const plat = what_platform(info); const mpname = this.in.name; const unpath = `./instance/${mpname}`; await Promise.all([ this._unzip(buffer, mpname), await platform(plat).downloadfile(this.in, unpath, this.ws), - ]); // 解压和下载 + ]).catch((e) => { + throw new Error(e) + }); // 解压和下载 this.ws.send( JSON.stringify({ status: "changed", result: undefined, }) ); //改变状态 - await new DeEarth(`${unpath}/mods`, `./.rubbish/${mpname}`).Main(); + await new DeEarth(`${unpath}/mods`, `./.rubbish/${mpname}`).Main().catch((e) => { + throw new Error(e) + }); this.ws.send( JSON.stringify({ status: "changed", result: undefined, }) ); //改变状态(DeEarth筛选模组完毕) - const mlinfo = await platform(plat).getinfo(this.in); + const mlinfo = await platform(plat).getinfo(this.in).catch((e)=>{ + throw new Error(e) + }); if (dser) { await mlsetup( mlinfo.loader, mlinfo.minecraft, mlinfo.loader_version, unpath - ); //安装服务端 + ).catch((e) => { + throw new Error(e) + }); //安装服务端 } if (!dser) { - dinstall(mlinfo.loader, mlinfo.minecraft, mlinfo.loader_version, unpath); + dinstall(mlinfo.loader, mlinfo.minecraft, mlinfo.loader_version, unpath).catch((e) => { + throw new Error(e) + }); } const latest = Date.now(); this.ws.send( @@ -64,9 +77,20 @@ export class Dex { }) ); if (config.oaf) { - await execPromise(`start ${p.join("./instance")}`); + await execPromise(`start ${p.join("./instance")}`).catch((e) => { + throw new Error(e) + }); } //await this._unzip(buffer); + }catch(e){ + const err = e as Error + this.ws.send( + JSON.stringify({ + status: "error", + result: err.message, + }) + ); + } } private async _getinfo(buffer: Buffer) { diff --git a/front/src/component/Main.vue b/front/src/component/Main.vue index e9749ef..383a3b6 100644 --- a/front/src/component/Main.vue +++ b/front/src/component/Main.vue @@ -1,7 +1,7 @@