mirror of
https://github.com/Cronocide/WebMessage.git
synced 2025-01-22 19:28:37 +00:00
Fixed a bug where window would be null
This commit is contained in:
parent
2009090e23
commit
9ee1545652
64
src/App.vue
64
src/App.vue
@ -71,7 +71,8 @@ export default {
|
|||||||
search: '',
|
search: '',
|
||||||
process: window.process,
|
process: window.process,
|
||||||
maximized: false,
|
maximized: false,
|
||||||
maximizing: false
|
maximizing: false,
|
||||||
|
win: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -82,9 +83,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getWindow () {
|
|
||||||
return window.remote.BrowserWindow.getAllWindows()[0]
|
|
||||||
},
|
|
||||||
closeWindow () {
|
closeWindow () {
|
||||||
if (this.$store.state.minimize) {
|
if (this.$store.state.minimize) {
|
||||||
ipcRenderer.send('minimizeToTray')
|
ipcRenderer.send('minimizeToTray')
|
||||||
@ -93,18 +91,17 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
minimizeWindow () {
|
minimizeWindow () {
|
||||||
this.getWindow().minimize()
|
this.win.minimize()
|
||||||
},
|
},
|
||||||
maximizeWindow () {
|
maximizeWindow () {
|
||||||
this.maximizing = true
|
this.maximizing = true
|
||||||
const win = this.getWindow()
|
|
||||||
if (this.maximized) {
|
if (this.maximized) {
|
||||||
win.restore()
|
this.win.restore()
|
||||||
win.setSize(700,600)
|
this.win.setSize(700,600)
|
||||||
win.center()
|
this.win.center()
|
||||||
if (process.platform !== 'darwin') document.body.style.borderRadius = null
|
if (process.platform !== 'darwin') document.body.style.borderRadius = null
|
||||||
} else {
|
} else {
|
||||||
win.maximize()
|
this.win.maximize()
|
||||||
if (process.platform !== 'darwin') document.body.style.borderRadius = '0'
|
if (process.platform !== 'darwin') document.body.style.borderRadius = '0'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,6 +163,29 @@ export default {
|
|||||||
this.updateAvailable = true
|
this.updateAvailable = true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ipcRenderer.on('win_id', (e, id) => {
|
||||||
|
this.win = window.remote.BrowserWindow.fromId(id)
|
||||||
|
|
||||||
|
window.addEventListener('resize', (e) => {
|
||||||
|
if (this.maximizing) return
|
||||||
|
if (this.maximized) {
|
||||||
|
this.win.restore()
|
||||||
|
if (process.platform !== 'darwin') document.body.style.borderRadius = null
|
||||||
|
this.maximized = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
this.win.on('move', (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
if (this.maximizing) return
|
||||||
|
if (this.maximized) {
|
||||||
|
this.win.restore()
|
||||||
|
if (process.platform !== 'darwin') document.body.style.borderRadius = null
|
||||||
|
this.maximized = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
this.notifSound = new Audio('wm-audio://receivedText.mp3')
|
this.notifSound = new Audio('wm-audio://receivedText.mp3')
|
||||||
|
|
||||||
if (!(this.$store.state.macstyle || process.platform === 'darwin')) {
|
if (!(this.$store.state.macstyle || process.platform === 'darwin')) {
|
||||||
@ -176,27 +196,6 @@ export default {
|
|||||||
if (!this.$store.state.acceleration) {
|
if (!this.$store.state.acceleration) {
|
||||||
document.documentElement.style.backgroundColor = "black"
|
document.documentElement.style.backgroundColor = "black"
|
||||||
}
|
}
|
||||||
|
|
||||||
const win = this.getWindow()
|
|
||||||
|
|
||||||
window.addEventListener('resize', (e) => {
|
|
||||||
if (this.maximizing) return
|
|
||||||
if (this.maximized) {
|
|
||||||
win.restore()
|
|
||||||
if (process.platform !== 'darwin') document.body.style.borderRadius = null
|
|
||||||
this.maximized = false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
win.on('move', (e) => {
|
|
||||||
e.preventDefault()
|
|
||||||
if (this.maximizing) return
|
|
||||||
if (this.maximized) {
|
|
||||||
win.restore()
|
|
||||||
if (process.platform !== 'darwin') document.body.style.borderRadius = null
|
|
||||||
this.maximized = false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
socket: {
|
socket: {
|
||||||
fetchChats (data) {
|
fetchChats (data) {
|
||||||
@ -224,7 +223,8 @@ export default {
|
|||||||
const notification = {
|
const notification = {
|
||||||
title: messageData.name,
|
title: messageData.name,
|
||||||
body: messageData.text,
|
body: messageData.text,
|
||||||
silent: this.$store.state.playsound
|
silent: this.$store.state.playsound,
|
||||||
|
icon: __static + '/icon.png'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.$store.state.playsound) this.notifSound.play()
|
if (this.$store.state.playsound) this.notifSound.play()
|
||||||
|
Loading…
Reference in New Issue
Block a user