feat: 添加设置页面 可配置代理开关

This commit is contained in:
alger
2023-12-28 10:45:11 +08:00
parent c7c1143cb4
commit a2c49d354e
12 changed files with 173 additions and 16 deletions
+27
View File
@@ -1,5 +1,7 @@
const { app, BrowserWindow, ipcMain, Tray, Menu, globalShortcut, nativeImage } = require('electron')
const path = require('path')
const Store = require('electron-store');
const setJson = require('./electron/set.json')
let mainWin = null
function createWindow() {
@@ -50,6 +52,13 @@ function createWindow() {
win.show()
}
})
const set = store.get('set')
// store.set('set', setJson)
if (!set) {
store.set('set', setJson)
}
}
app.whenReady().then(createWindow)
@@ -104,3 +113,21 @@ ipcMain.on('mini-tray', (event) => {
const win = BrowserWindow.fromWebContents(event.sender)
win.hide()
})
// 重启
ipcMain.on('restart', () => {
app.relaunch()
app.exit(0)
})
const store = new Store();
// 定义ipcRenderer监听事件
ipcMain.on('setStore', (_, key, value) => {
store.set(key, value)
})
ipcMain.on('getStore', (_, key) => {
let value = store.get(key)
_.returnValue = value || ""
})