Skip to content

Commit

Permalink
fix: proper window controls for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
unxsist committed Mar 21, 2024
1 parent b61b538 commit 2912ff7
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src-tauri/tauri.windows.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
"libcrypto-3-x64.dll",
"libssl-3-x64.dll"
]
}
},
"windows": [
{
"title": "JET Pilot",
"decorations": false
}
]
}
}
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DialogHandler from "./components/DialogHandler.vue";
</script>

<template>
<AppLayout class="dark bg-zinc-900 text-sm rounded-lg">
<AppLayout class="dark bg-zinc-900 text-sm rounded-lg overflow-hidden">
<Suspense>
<SettingsContextProvider>
<KubeContextProvider>
Expand Down
1 change: 1 addition & 0 deletions src/assets/icons/full_screen.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/icons/minimize.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 46 additions & 2 deletions src/components/Navigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@ import ContextSwitcher from "./ContextSwitcher.vue";
import NavigationGroup from "./NavigationGroup.vue";
import NavigationItem from "./NavigationItem.vue";
import { ScrollArea } from "@/components/ui/scroll-area";
import { Button } from "@/components/ui/button";
import { Kubernetes } from "@/services/Kubernetes";
import { KubeContextStateKey } from "@/providers/KubeContextProvider";
import { injectStrict } from "@/lib/utils";
import { V1APIResource } from "@kubernetes/client-node";
import pluralize from "pluralize";
import { platform as getPlatform } from "@tauri-apps/api/os";
import { getCurrent as getWindow } from "@tauri-apps/api/window"
import { exit } from '@tauri-apps/api/process';
import CloseIcon from "@/assets/icons/close.svg";
import FullScreenIcon from "@/assets/icons/full_screen.svg";
import MinimizeIcon from "@/assets/icons/minimize.svg";
const targetPlatform = ref<string>("");
const { context, namespace} = injectStrict(KubeContextStateKey);
interface NavigationGroup {
Expand Down Expand Up @@ -158,8 +166,33 @@ const fetchResources = () => {
});
};
const maxOrUnmaximize = () => {
const window = getWindow();
window.isMaximized().then((maximized) => {
if (maximized) {
window.unmaximize();
} else {
window.maximize();
}
});
};
const minimize = () => {
const window = getWindow();
window.minimize();
};
const quit = () => {
exit(0);
};
onMounted(() => {
fetchResources();
getPlatform().then((platform) => {
targetPlatform.value = platform;
});
});
watch([context, namespace], () => {
Expand All @@ -169,9 +202,20 @@ watch([context, namespace], () => {

<template>
<div class="flex flex-col flex-shrink-0 relative min-w-[200px] max-w-[200px]">
<div class="absolute w-full h-[40px]" data-tauri-drag-region></div>
<div v-if="targetPlatform == 'win32'" class="p-2 pb-0 -mb-1 space-x-2" data-tauri-drag-region>
<Button size="xs" @click="quit">
<CloseIcon class="h-3 text-white" />
</Button>
<Button size="xs" @click="maxOrUnmaximize">
<FullScreenIcon class="h-3 text-white" />
</Button>
<Button size="xs" @click="minimize">
<MinimizeIcon class="h-3 text-white" />
</Button>
</div>
<div class="absolute w-full h-[40px]" v-else data-tauri-drag-region></div>
<div class="flex flex-col flex-grow min-h-screen max-h-screen p-2 pr-0">
<ContextSwitcher class="mt-[30px]" />
<ContextSwitcher :class="{ 'mt-[30px]': targetPlatform !== 'win32'}" />
<div class="flex w-full flex-grow flex-shrink overflow-hidden">
<ScrollArea class="w-full mt-0 mb-0">
<NavigationGroup
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/scroll-area/ScrollArea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const props = withDefaults(

<template>
<ScrollAreaRoot :type="type" :class="cn('relative overflow-hidden', props.class)">
<ScrollAreaViewport class="h-full w-full rounded-[inherit]">
<ScrollAreaViewport class="h-full w-full rounded-[inherit]">
<slot />
</ScrollAreaViewport>
<ScrollBar />
Expand Down

0 comments on commit 2912ff7

Please sign in to comment.