2024-04-26 07:54:02 +02:00
|
|
|
<template>
|
2025-03-28 01:16:24 +01:00
|
|
|
<SidebarProvider>
|
|
|
|
|
<AppSidebar>
|
2025-11-21 12:16:00 +01:00
|
|
|
<slot />
|
2025-03-28 01:16:24 +01:00
|
|
|
</AppSidebar>
|
|
|
|
|
</SidebarProvider>
|
2025-08-28 07:41:51 +02:00
|
|
|
<MobileNavbar v-if="authStore.isSignedIn" />
|
2025-04-30 01:44:16 +02:00
|
|
|
<Preferences />
|
2025-08-28 07:41:51 +02:00
|
|
|
<ComposerDialog v-if="authStore.isSignedIn" />
|
2024-04-26 07:54:02 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2024-11-30 19:15:23 +01:00
|
|
|
import ComposerDialog from "~/components/composer/dialog.vue";
|
2024-12-09 16:52:04 +01:00
|
|
|
import MobileNavbar from "~/components/navigation/mobile-navbar.vue";
|
2025-05-01 01:45:46 +02:00
|
|
|
import Preferences from "~/components/preferences/index.vue";
|
2025-03-28 01:16:24 +01:00
|
|
|
import AppSidebar from "~/components/sidebars/sidebar.vue";
|
|
|
|
|
import { SidebarProvider } from "~/components/ui/sidebar";
|
2024-04-26 07:54:02 +02:00
|
|
|
|
2024-12-25 17:39:22 +01:00
|
|
|
const colorMode = useColorMode();
|
|
|
|
|
const { n, d } = useMagicKeys();
|
2024-06-19 08:16:28 +02:00
|
|
|
const activeElement = useActiveElement();
|
2025-08-28 07:41:51 +02:00
|
|
|
const authStore = useAuthStore();
|
2024-06-19 08:16:28 +02:00
|
|
|
const notUsingInput = computed(
|
|
|
|
|
() =>
|
|
|
|
|
activeElement.value?.tagName !== "INPUT" &&
|
2024-12-25 18:51:52 +01:00
|
|
|
activeElement.value?.tagName !== "TEXTAREA" &&
|
|
|
|
|
activeElement.value?.contentEditable !== "true",
|
2024-06-19 08:16:28 +02:00
|
|
|
);
|
2024-12-07 18:26:52 +01:00
|
|
|
const route = useRoute();
|
|
|
|
|
|
2025-11-21 12:16:00 +01:00
|
|
|
watch(
|
|
|
|
|
() => route.path,
|
|
|
|
|
async () => {
|
|
|
|
|
console.log(route.meta.requiresAuth && !authStore.isSignedIn);
|
|
|
|
|
if (route.meta.requiresAuth && !authStore.isSignedIn) {
|
|
|
|
|
window.location.href = "/";
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{ immediate: true },
|
|
|
|
|
);
|
|
|
|
|
|
2024-12-25 18:51:52 +01:00
|
|
|
watch([n, notUsingInput, d], async () => {
|
2024-06-19 08:16:28 +02:00
|
|
|
if (n?.value && notUsingInput.value) {
|
2024-05-12 06:34:03 +02:00
|
|
|
// Wait 50ms
|
|
|
|
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
2024-04-28 07:02:27 +02:00
|
|
|
useEvent("composer:open");
|
|
|
|
|
}
|
2024-12-25 17:39:22 +01:00
|
|
|
|
2024-12-25 18:51:52 +01:00
|
|
|
if (d?.value && notUsingInput.value && !colorMode.forced) {
|
2024-12-25 17:39:22 +01:00
|
|
|
// Swap theme from dark to light or vice versa
|
|
|
|
|
if (colorMode.value === "dark") {
|
|
|
|
|
colorMode.preference = "light";
|
2025-04-30 18:03:14 +02:00
|
|
|
preferences.color_theme.value = "light";
|
2024-12-25 17:39:22 +01:00
|
|
|
} else {
|
|
|
|
|
colorMode.preference = "dark";
|
2025-04-30 18:03:14 +02:00
|
|
|
preferences.color_theme.value = "dark";
|
2024-12-25 17:39:22 +01:00
|
|
|
}
|
|
|
|
|
}
|
2024-04-28 07:02:27 +02:00
|
|
|
});
|
2024-12-25 17:39:22 +01:00
|
|
|
</script>
|