add navbar close & min functionality
This commit is contained in:
parent
ba2826484f
commit
4cf21a0c64
2 changed files with 45 additions and 2 deletions
33
src/App.vue
33
src/App.vue
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
<!-- Menu -->
|
||||
<span class="menu">
|
||||
<button class="menuButton exitButton"></button>
|
||||
<button class="menuButton minimizeButton"></button>
|
||||
<button class="menuButton exitButton" @click.prevent="callNavbar('close')"></button>
|
||||
<button class="menuButton minimizeButton" @click.prevent="callNavbar('min')"></button>
|
||||
</span>
|
||||
|
||||
<!-- Windows -->
|
||||
|
|
@ -17,6 +17,35 @@
|
|||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import {defineComponent} from 'vue';
|
||||
import { useIpc } from "@/modules/ipc";
|
||||
|
||||
export default defineComponent({
|
||||
|
||||
setup() {
|
||||
|
||||
const { invoke } = useIpc();
|
||||
|
||||
const callNavbar = (action: string) => {
|
||||
switch(action) {
|
||||
case 'close':
|
||||
invoke('nav-bar', 'close');
|
||||
break;
|
||||
case 'min':
|
||||
invoke('nav-bar', 'min');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
callNavbar
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
html, body {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,9 @@ let win: BrowserWindow | null;
|
|||
const windowMount = (): void => {
|
||||
backgroundMitt.emit('window-active', true);
|
||||
ipcMain.on('update-recorder', updateRecorder);
|
||||
// handle renderer auth-token event
|
||||
ipcMain.removeHandler('nav-bar'); // avoid setting duplicate handlers
|
||||
ipcMain.handle('nav-bar', navBarHandler);
|
||||
}
|
||||
|
||||
const windowDismount = (): void => {
|
||||
|
|
@ -87,3 +90,14 @@ export const createWindow = async (options: WindowSettings): Promise<void> => {
|
|||
});
|
||||
};
|
||||
|
||||
// call this function on nav bar click
|
||||
function navBarHandler(_event, action: string) {
|
||||
switch(action) {
|
||||
case 'close':
|
||||
if (win) win.close();
|
||||
break;
|
||||
case 'min':
|
||||
if (win) win.minimize();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue