diff --git a/iyuu b/iyuu
index f7eed46..e62cfef 160000
--- a/iyuu
+++ b/iyuu
@@ -1 +1 @@
-Subproject commit f7eed461a0d812a3b5c1adb96047a09021d87857
+Subproject commit e62cfefe353c075642a4ab5294fc86a396390b55
diff --git a/logs.html b/logs.html
new file mode 100644
index 0000000..008fb21
--- /dev/null
+++ b/logs.html
@@ -0,0 +1,18 @@
+
+
+
+
+
+ 运行日志
+
+
+ IYUU 日志信息
+
+
+
+
+
diff --git a/main.js b/main.js
index 85c7d81..e68af35 100644
--- a/main.js
+++ b/main.js
@@ -1,14 +1,19 @@
const { app } = require('electron')
const path = require('node:path')
-const server = require('./server/server');
const log = require('electron-log')
+log.initialize();
+console.log = log.log;
+log.transports.file.resolvePathFn = () => path.join(app.getPath('appData'), 'iyuu-plus/logs/iyuu.log');
+log.transports.file.format = '[{y}-{m}-{d} {h}:{i}:{s}.{ms}] [{level}]{scope} {text}';
+log.transports.file.encoding = 'utf8';
+log.info('App is starting...');
+
+const server = require('./server/server');
const mainWin = require('./windows/app');
+
app.whenReady().then(() => {
- log.transports.file.encoding = 'utf8';
- log.transports.file.file = path.join(app.getPath('userData'), 'logs/iyuu.log');
- log.transports.file.format = '{y}-{m}-{d} {h}:{i}:{s} {text}';
log.info('App is starting...');
server.startServer()
diff --git a/menu/menu.js b/menu/menu.js
index 2c943f3..25e2b10 100644
--- a/menu/menu.js
+++ b/menu/menu.js
@@ -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: () => {
diff --git a/preload.js b/preload.js
index 9cb22e4..32a3037 100644
--- a/preload.js
+++ b/preload.js
@@ -4,4 +4,11 @@ window.addEventListener('DOMContentLoaded', () => {
script.src = 'https://analytics.lifebus.top/script.js';
script.setAttribute('data-website-id', '5ca63d47-0739-4059-a480-40e7edf80ff9');
document.head.appendChild(script);
+});
+
+
+const { contextBridge, ipcRenderer } = require('electron');
+
+contextBridge.exposeInMainWorld('electron', {
+ onDisplayLog: (callback) => ipcRenderer.on('display-log', (event, data) => callback(data))
});
\ No newline at end of file
diff --git a/windows/app.js b/windows/app.js
index 475f7dc..9416d6a 100644
--- a/windows/app.js
+++ b/windows/app.js
@@ -108,4 +108,11 @@ const visibleWindows = () => {
}
-module.exports = { hideWindows, showWindows, createWindow, closeWindows, refreshWindows, rebootWindows, visibleWindows, refreshUrl };
\ No newline at end of file
+const downloadLocalFile = (filePath) => {
+ log.info('[Download local file]: ', filePath)
+ if (mainWindow) {
+ mainWindow.webContents.downloadURL('file://' + filePath)
+ }
+}
+
+module.exports = { hideWindows, showWindows, createWindow, closeWindows, refreshWindows, rebootWindows, visibleWindows, refreshUrl, downloadLocalFile };
\ No newline at end of file