perf: 客户端关闭

This commit is contained in:
kuaifan 2021-12-23 23:26:33 +08:00
parent ba32df2fb8
commit 89b8342ca0
2 changed files with 25 additions and 15 deletions

39
electron/main.js vendored
View File

@ -3,8 +3,9 @@ const path = require('path')
const XLSX = require('xlsx');
const {app, BrowserWindow, ipcMain, dialog} = require('electron')
let mainWindow = null;
let willQuitApp = false,
let mainWindow = null,
willQuitApp = false,
inheritClose = false,
devloadCachePath = path.resolve(__dirname, ".devload"),
devloadUrl = "";
if (fs.existsSync(devloadCachePath)) {
@ -53,7 +54,11 @@ function createWindow() {
mainWindow.on('close', function (e) {
if (!willQuitApp) {
e.preventDefault();
mainWindow.webContents.send("windowClose", {})
if (inheritClose) {
mainWindow.webContents.send("windowClose", {})
} else {
app.hide();
}
}
})
}
@ -74,12 +79,16 @@ app.on('before-quit', () => {
willQuitApp = true
})
ipcMain.on('setDockBadge', (event, arg) => {
if (runNum(arg) > 0) {
app.dock.setBadge(String(arg))
} else {
app.dock.setBadge("")
}
ipcMain.on('inheritClose', () => {
inheritClose = true
})
ipcMain.on('windowHidden', () => {
app.hide();
})
ipcMain.on('windowClose', () => {
mainWindow.close()
})
ipcMain.on('windowMax', function () {
@ -90,14 +99,14 @@ ipcMain.on('windowMax', function () {
}
})
ipcMain.on('windowHidden', () => {
app.hide();
ipcMain.on('setDockBadge', (event, arg) => {
if (runNum(arg) > 0) {
app.dock.setBadge(String(arg))
} else {
app.dock.setBadge("")
}
})
ipcMain.on('windowClose', () => {
mainWindow.close()
});
ipcMain.on('saveSheet', (event, data, filename, opts) => {
const EXTENSIONS = "xls|xlsx|xlsm|xlsb|xml|csv|txt|dif|sylk|slk|prn|ods|fods|htm|html".split("|");
dialog.showSaveDialog({

View File

@ -177,6 +177,7 @@ export default {
return;
}
const {ipcRenderer} = this.$electron;
ipcRenderer.send('inheritClose');
ipcRenderer.on('windowClose', () => {
if (this.$Modal.removeLast()) {
return;