Skip to content

Instantly share code, notes, and snippets.

@hightemp
Last active May 17, 2020 11:01
Show Gist options
  • Select an option

  • Save hightemp/f5d5ae9ff386e040e943a42f4fac0e74 to your computer and use it in GitHub Desktop.

Select an option

Save hightemp/f5d5ae9ff386e040e943a42f4fac0e74 to your computer and use it in GitHub Desktop.
vue electron maximize
<q-btn v-if="$q.platform.is.desktop" dense @click="fnMinimizeWindow" icon="expand_more" />
<q-btn v-if="$q.platform.is.desktop" dense @click="fnMaximizeWindow" :icon="m_bWindowIsMaximized ? 'unfold_more' : 'expand_less'" />
<q-btn v-if="$q.platform.is.desktop" dense @click="fnCloseWindow" icon="close" />
/* ... */
computed: {
bWindowIsMaximized: {
set(bValue) {
if (process.env.MODE === 'electron') {
//this.m_bWindowIsMaximized = bValue
if (bValue) {
oBrowserWindow.maximize()
} else {
oBrowserWindow.unmaximize()
}
}
},
get() {
if (process.env.MODE === 'electron') {
console.log('bWindowIsMaximized - get', oBrowserWindow.isMaximized())
return oBrowserWindow.isMaximized()
}
},
cache: false
},
iUserIndex: {
set(iUserIndex) { this.$store.dispatch('configuration/SET_USER_INDEX', { iUserIndex }) },
get() { return this.$store.getters['configuration/USER_INDEX'] },
cache: false
},
iActiveTab: {
set(iActiveTab) { this.$store.dispatch('configuration/SET_ACTIVE_TAB', { iActiveTab }) },
get() { return this.$store.getters['configuration/ACTIVE_TAB'] },
cache: false
},
...mapGetters({
aRepositories: 'repositories/ALL'
})
},
/* ... */
fnMinimizeWindow() {
if (process.env.MODE === 'electron') {
this.$q.electron.remote.BrowserWindow.getFocusedWindow().minimize()
}
},
fnMaximizeWindow() {
this.bWindowIsMaximized = !this.bWindowIsMaximized
},
fnCloseWindow() {
if (process.env.MODE === 'electron') {
this.$q.electron.remote.BrowserWindow.getFocusedWindow().close()
}
},
window.oBrowserWindow = this.$q.electron.remote.BrowserWindow.getAllWindows()[0];
oBrowserWindow.on('maximize', function() { oIndexPage.m_bWindowIsMaximized = true; });
oBrowserWindow.on('unmaximize', function() { oIndexPage.m_bWindowIsMaximized = false; });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment