perf: 客户端标题优化

This commit is contained in:
kuaifan 2021-12-30 14:18:25 +08:00
parent b97a2e7cf3
commit bcf6cc1019
3 changed files with 24 additions and 5 deletions

21
electron/main.js vendored
View File

@ -66,7 +66,13 @@ function createMainWindow() {
}) })
} }
mainWindow.on('close', function (e) { mainWindow.on('page-title-updated', (event, title) => {
if (title == "index.html") {
event.preventDefault()
}
})
mainWindow.on('close', (e) => {
if (!willQuitApp) { if (!willQuitApp) {
e.preventDefault(); e.preventDefault();
if (inheritClose) { if (inheritClose) {
@ -103,6 +109,10 @@ function createSubWindow(args) {
return; return;
} }
} else { } else {
let config = args.config || {};
if (typeof args.title !== "undefined") {
config.title = args.title;
}
browser = new BrowserWindow(Object.assign({ browser = new BrowserWindow(Object.assign({
width: 1280, width: 1280,
height: 800, height: 800,
@ -115,8 +125,13 @@ function createSubWindow(args) {
nodeIntegration: true, nodeIntegration: true,
contextIsolation: false contextIsolation: false
} }
}, args.config || {})) }, config))
browser.on('close', function () { browser.on('page-title-updated', (event, title) => {
if (title == "index.html" || args.titleFixed === true) {
event.preventDefault()
}
})
browser.on('close', () => {
let index = subWindow.findIndex(item => item.name == name); let index = subWindow.findIndex(item => item.name == name);
if (index > -1) { if (index > -1) {
subWindow.splice(index, 1) subWindow.splice(index, 1)

View File

@ -1187,6 +1187,8 @@ export default {
config.minHeight = 600; config.minHeight = 600;
} }
this.$Electron.ipcRenderer.send('windowRouter', { this.$Electron.ipcRenderer.send('windowRouter', {
title: this.taskDetail.name,
titleFixed: true,
name: 'task-' + this.taskDetail.id, name: 'task-' + this.taskDetail.id,
path: "/single/task/" + this.taskDetail.id, path: "/single/task/" + this.taskDetail.id,
force: false, force: false,

View File

@ -762,13 +762,15 @@ export default {
openSingle(item) { openSingle(item) {
this.$Electron.ipcRenderer.send('windowRouter', { this.$Electron.ipcRenderer.send('windowRouter', {
title: item.name,
titleFixed: true,
name: 'file-' + item.id, name: 'file-' + item.id,
path: "/single/file/" + item.id, path: "/single/file/" + item.id,
force: false, // force: false, //
config: { config: {
parent: null, parent: null,
width: Math.min(window.screen.availWidth, 1280), width: Math.min(window.screen.availWidth, 1440),
height: Math.min(window.screen.availHeight, 800), height: Math.min(window.screen.availHeight, 900),
} }
}); });
}, },