perf: 客户端子窗口

This commit is contained in:
kuaifan 2021-12-28 14:12:24 +08:00
parent be7c6e700b
commit 739d1f2455
2 changed files with 22 additions and 6 deletions

26
electron/main.js vendored
View File

@ -1,7 +1,7 @@
const fs = require('fs')
const path = require('path')
const XLSX = require('xlsx');
const {app, BrowserWindow, ipcMain, dialog} = require('electron')
const {app, BrowserWindow, ipcMain, dialog, screen} = require('electron')
let mainWindow = null,
subWindow = [],
@ -176,7 +176,26 @@ ipcMain.on('windowSize', (event, args) => {
const win = BrowserWindow.fromWebContents(event.sender);
if (win) {
if (args.width || args.height) {
win.setSize(args.width || win.getSize()[0], args.height || win.getSize()[1], args.animate === true)
let [w, h] = win.getSize()
const width = args.width || w
const height = args.height || h
win.setSize(width, height, args.animate === true)
//
if (args.autoZoom === true) {
let move = false
let [x, y] = win.getPosition()
if (Math.abs(width - w) > 10) {
move = true
x -= (width - w) / 2
}
if (Math.abs(height - h) > 10) {
move = true
y -= (height - h) / 2
}
if (move) {
win.setPosition(Math.max(0, Math.floor(x)), Math.max(0, Math.floor(y)))
}
}
}
if (args.minWidth || args.minHeight) {
win.setMinimumSize(args.minWidth || win.getMinimumSize()[0], args.minHeight || win.getMinimumSize()[1])
@ -184,9 +203,6 @@ ipcMain.on('windowSize', (event, args) => {
if (args.maxWidth || args.maxHeight) {
win.setMaximumSize(args.maxWidth || win.getMaximumSize()[0], args.maxHeight || win.getMaximumSize()[1])
}
if (args.center === true) {
win.center();
}
}
event.returnValue = "ok"
})

View File

@ -1201,7 +1201,7 @@ export default {
height: Math.max(720, window.innerHeight),
minWidth: 800,
minHeight: 600,
center: true,
autoZoom: true,
});
if (this.msgText) {
let num = 0;