no message

This commit is contained in:
kuaifan 2022-03-08 08:15:34 +08:00
parent 629881d16b
commit 0e34cc49df
2 changed files with 34 additions and 0 deletions

33
electron/electron.js vendored
View File

@ -8,6 +8,7 @@ const fsProm = require('fs/promises');
const PDFDocument = require('pdf-lib').PDFDocument;
const crc = require('crc');
const zlib = require('zlib');
const azip = require("adm-zip");
const utils = require('./utils');
const config = require('./package.json');
@ -1122,6 +1123,26 @@ function unwatchFile(path) {
return null
}
function unzip(path, output) {
let zip = new azip(path, {});
try {
zip.extractAllTo(output, true, false, null);
return true;
} catch (e) {
return false;
}
}
function relaunch() {
app.relaunch();
return null
}
function exit() {
app.exit();
return null
}
ipcMain.on("rendererReq", async (event, args) => {
try {
let ret = null;
@ -1190,6 +1211,18 @@ ipcMain.on("rendererReq", async (event, args) => {
case 'unwatchFile':
ret = await unwatchFile(args.path);
break;
case 'getAppPath':
ret = app.getAppPath();
break;
case 'unzip':
ret = unzip(args.path, args.output);
break;
case 'relaunch':
ret = relaunch();
break;
case 'exit':
ret = exit();
break;
}
event.reply('mainResp', {success: true, data: ret, reqId: args.reqId});

View File

@ -39,6 +39,7 @@
"electron-builder": "^22.14.13"
},
"dependencies": {
"adm-zip": "^0.5.9",
"axios": "^0.26.0",
"crc": "^3.8.0",
"electron-squirrel-startup": "^1.0.0",