]> Repos - mime-chat/commitdiff
add navbar close & min functionality
authorEnrique Hernandez <hernandeze2@xavier.edu>
Sat, 27 Feb 2021 22:35:39 +0000 (16:35 -0600)
committerEnrique Hernandez <hernandeze2@xavier.edu>
Sat, 27 Feb 2021 22:35:39 +0000 (16:35 -0600)
src/App.vue
src/background/window.ts

index 222f4dbd8212377e45ec11aec0f963abcbf6f0c0..583ff1b889aa5c149622c765d9f28a2fa3795eef 100644 (file)
@@ -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 -->
   </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 {
index 036999a4ad2c478ce1b758678345860aa583557e..334ae679646701beffa5287e076a23ca1419da18 100644 (file)
@@ -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;
+    }
+}