feat: 日志的查询与下载

This commit is contained in:
2024-07-03 18:35:02 +08:00
parent dce28ba729
commit 357fb2ecda
6 changed files with 80 additions and 6 deletions
+37
View File
@@ -1,5 +1,6 @@
const { app, Menu, BrowserWindow } = require("electron")
const path = require('node:path')
const fs = require('fs')
const server = require('../server/server');
const mainWin = require('../windows/app');
@@ -72,6 +73,42 @@ let template = [
});
}
},
{
label: "查看日志",
click: () => {
let win = new BrowserWindow({
width: 800,
height: 600,
icon: iconPath,
webPreferences: {
preload: path.join(__dirname, '..', 'preload.js'),
contextIsolation: true,
enableRemoteModule: false,
nodeIntegration: false
}
});
win.loadFile(path.join(__dirname, '..', 'logs.html'));
win.on("closed", () => {
win = null;
});
const logsFile = path.join(app.getPath('appData'), 'iyuu-plus/logs/iyuu.log');
fs.readFile(logsFile, 'utf8', (err, data) => {
if (err) {
console.error('Error reading log file:', err);
return;
}
win.webContents.send('display-log', data);
});
}
},
{
label: "下载日志",
click: () => {
const logsFile = path.join(app.getPath('appData'), 'iyuu-plus/logs/iyuu.log');
mainWin.downloadLocalFile(logsFile);
}
},
{
label: "新疆萌森软件开发工作室提供技术支持",
click: () => {