frontend/app.vue

122 lines
3.3 KiB
Vue
Raw Normal View History

<template>
<TooltipProvider>
<Component is="style">
{{ customCss.value }}
</Component>
<NuxtPwaAssets />
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
<ConfirmationModal />
<!-- pointer-events-auto fixes https://github.com/unovue/shadcn-vue/issues/462 -->
<Toaster class="pointer-events-auto" />
</TooltipProvider>
</template>
<script setup lang="ts">
import "~/styles/index.css";
2024-05-12 08:13:35 +02:00
import { convert } from "html-to-text";
import ConfirmationModal from "./components/modals/confirm.vue";
import { Toaster } from "./components/ui/sonner";
import { TooltipProvider } from "./components/ui/tooltip";
2025-03-27 22:20:04 +01:00
import { overwriteGetLocale } from "./paraglide/runtime";
2024-12-07 13:46:19 +01:00
import { type EnumSetting, SettingIds } from "./settings";
2024-12-04 15:43:31 +01:00
// Sin
//import "~/styles/mcdonalds.css";
const lang = useLanguage();
2025-03-27 22:20:04 +01:00
overwriteGetLocale(() => lang.value);
const code = useRequestURL().searchParams.get("code");
const origin = useRequestURL().searchParams.get("origin");
const appData = useAppData();
const instance = useInstance();
2024-05-12 08:13:35 +02:00
const description = useExtendedDescription(client);
const customCss = useSetting(SettingIds.CustomCSS);
const route = useRoute();
2024-12-07 13:46:19 +01:00
// Theme switcher
const theme = useSetting(SettingIds.Theme) as Ref<EnumSetting>;
const colorMode = useColorMode();
watch(theme.value, () => {
// Add theme-changing class to html to trigger transition
document.documentElement.classList.add("theme-changing");
2024-12-07 13:46:19 +01:00
colorMode.preference = theme.value.value;
setTimeout(() => {
// Remove theme-changing class after transition
document.documentElement.classList.remove("theme-changing");
}, 1000);
2024-12-07 13:46:19 +01:00
});
2024-05-12 08:13:35 +02:00
useSeoMeta({
titleTemplate: (titleChunk) => {
return titleChunk ? `${titleChunk} · Versia` : "Versia";
2024-05-12 08:13:35 +02:00
},
title: computed(() => instance.value?.title ?? ""),
2025-01-29 02:36:58 +01:00
ogImage: computed(() => instance.value?.banner?.url),
2024-05-12 08:13:35 +02:00
twitterTitle: computed(() => instance.value?.title ?? ""),
twitterDescription: computed(() =>
convert(description.value?.content ?? ""),
2024-05-12 08:13:35 +02:00
),
2025-01-29 02:36:58 +01:00
twitterImage: computed(() => instance.value?.banner?.url),
2024-05-12 08:13:35 +02:00
description: computed(() => convert(description.value?.content ?? "")),
ogDescription: computed(() => convert(description.value?.content ?? "")),
ogSiteName: "Versia",
2024-05-12 08:13:35 +02:00
colorScheme: "dark",
2024-05-12 09:30:02 +02:00
themeColor: "#f9a8d4",
2024-05-12 08:13:35 +02:00
});
useHead({
htmlAttrs: {
lang: "en",
},
});
if (code && origin && appData.value && route.path !== "/oauth/code") {
const newOrigin = new URL(
URL.canParse(origin) ? origin : `https://${origin}`,
);
signInWithCode(code, appData.value, newOrigin);
}
if (origin && !code) {
const newOrigin = new URL(
URL.canParse(origin) ? origin : `https://${origin}`,
);
signIn(appData, newOrigin);
}
useListen("identity:change", (newIdentity) => {
identity.value = newIdentity;
window.location.pathname = "/";
});
useCacheRefresh(client);
</script>
<style>
body {
font-family: Inter, sans-serif;
}
html.theme-changing * {
/* Stroke and fill aren't animatable */
2025-03-27 22:20:04 +01:00
transition: background-color 1s ease, border 1s ease, color 1s ease,
box-shadow 1s ease !important;
}
.slide-down-enter-active,
.slide-down-leave-active {
transition: transform 0.3s ease;
}
.slide-down-enter-from,
.slide-down-leave-to {
transform: translateY(-100%);
}
</style>