perf: 客户端关闭
This commit is contained in:
parent
ba32df2fb8
commit
89b8342ca0
39
electron/main.js
vendored
39
electron/main.js
vendored
@ -3,8 +3,9 @@ const path = require('path')
|
|||||||
const XLSX = require('xlsx');
|
const XLSX = require('xlsx');
|
||||||
const {app, BrowserWindow, ipcMain, dialog} = require('electron')
|
const {app, BrowserWindow, ipcMain, dialog} = require('electron')
|
||||||
|
|
||||||
let mainWindow = null;
|
let mainWindow = null,
|
||||||
let willQuitApp = false,
|
willQuitApp = false,
|
||||||
|
inheritClose = false,
|
||||||
devloadCachePath = path.resolve(__dirname, ".devload"),
|
devloadCachePath = path.resolve(__dirname, ".devload"),
|
||||||
devloadUrl = "";
|
devloadUrl = "";
|
||||||
if (fs.existsSync(devloadCachePath)) {
|
if (fs.existsSync(devloadCachePath)) {
|
||||||
@ -53,7 +54,11 @@ function createWindow() {
|
|||||||
mainWindow.on('close', function (e) {
|
mainWindow.on('close', function (e) {
|
||||||
if (!willQuitApp) {
|
if (!willQuitApp) {
|
||||||
e.preventDefault();
|
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
|
willQuitApp = true
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('setDockBadge', (event, arg) => {
|
ipcMain.on('inheritClose', () => {
|
||||||
if (runNum(arg) > 0) {
|
inheritClose = true
|
||||||
app.dock.setBadge(String(arg))
|
})
|
||||||
} else {
|
|
||||||
app.dock.setBadge("")
|
ipcMain.on('windowHidden', () => {
|
||||||
}
|
app.hide();
|
||||||
|
})
|
||||||
|
|
||||||
|
ipcMain.on('windowClose', () => {
|
||||||
|
mainWindow.close()
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('windowMax', function () {
|
ipcMain.on('windowMax', function () {
|
||||||
@ -90,14 +99,14 @@ ipcMain.on('windowMax', function () {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('windowHidden', () => {
|
ipcMain.on('setDockBadge', (event, arg) => {
|
||||||
app.hide();
|
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) => {
|
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("|");
|
const EXTENSIONS = "xls|xlsx|xlsm|xlsb|xml|csv|txt|dif|sylk|slk|prn|ods|fods|htm|html".split("|");
|
||||||
dialog.showSaveDialog({
|
dialog.showSaveDialog({
|
||||||
|
@ -177,6 +177,7 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const {ipcRenderer} = this.$electron;
|
const {ipcRenderer} = this.$electron;
|
||||||
|
ipcRenderer.send('inheritClose');
|
||||||
ipcRenderer.on('windowClose', () => {
|
ipcRenderer.on('windowClose', () => {
|
||||||
if (this.$Modal.removeLast()) {
|
if (this.$Modal.removeLast()) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user