Skip to content

Commit

Permalink
Update main.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ivysrono authored Mar 21, 2020
1 parent b73ffcf commit 5127b59
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ const i18n = require('./i18n')
const setting = require('./setting')
const updater = require('./updater')

const Store = require('electron-store')
const store = new Store()

// get the previous size
let preWidth = store.get('preWidth')
let preHeight = store.get('preHeight')
let maxWindow = store.get('maxWindow')

let windows = []
let openfile = null

Expand All @@ -13,8 +21,8 @@ function newWindow(path) {
process.platform === 'linux' ? resolve(__dirname, '../logo.png') : null,
title: app.name,
useContentSize: true,
width: setting.get('window.width'),
height: setting.get('window.height'),
width: preWidth ? preWidth : setting.get('window.width'),
height: preHeight ? preHeight : setting.get('window.height'),
minWidth: setting.get('window.minwidth'),
minHeight: setting.get('window.minheight'),
autoHideMenuBar: !setting.get('view.show_menubar'),
Expand All @@ -33,6 +41,24 @@ function newWindow(path) {
window.show()
})

if (maxWindow === 'true') {
window.maximize()
}

// store the window size
window.on('maximize', () => {
store.set('maxWindow', 'true')
})
window.on('unmaximize', () => {
store.set('maxWindow', 'false')
})
window.on('resize', () => {
const [nowWidth, nowHeight] = window.getSize()
store.set('preWidth', nowWidth)
store.set('preHeight', nowHeight)
//console.log(`Width: ${preWidth}, Height: ${preHeight}`);
})

window.on('closed', () => {
window = null
})
Expand Down

0 comments on commit 5127b59

Please sign in to comment.