first commit
This commit is contained in:
commit
db5762abd4
687 files changed
+171307
No files matched your search
+35
@@ -0,0 +1,35 @@
|
||||
<script setup>
|
||||
import { computed, onMounted, onBeforeUnmount } from "vue";
|
||||
import { useRoute } from "#app";
|
||||
import { NuxtLayout, NuxtPage, NuxtRouteAnnouncer } from "#components";
|
||||
import BuildUpdateNotice from "~/components/BuildUpdateNotice.vue";
|
||||
import OperationToasts from "~/components/OperationToasts.vue";
|
||||
import { useAuth } from "~/lib/auth.js";
|
||||
import { t as useTheme } from "~/lib/useTheme.js";
|
||||
import { isPublicShop, isAuthPage, isPublicRoute } from "~/utils/access.js";
|
||||
|
||||
const auth = useAuth();
|
||||
const route = useRoute();
|
||||
const theme = useTheme();
|
||||
const layout = computed(() =>
|
||||
!auth.isLoggedIn && isPublicShop(route) ? "public-order" : route.meta.layout,
|
||||
);
|
||||
// An authenticated route's component tree belongs to that session, not to a pending redirect.
|
||||
const canRenderRoute = computed(() => auth.isLoggedIn || isPublicRoute(route));
|
||||
const routeSessionKey = computed(() =>
|
||||
isAuthPage(route.path) || route.path === "/home.htm"
|
||||
? route.path
|
||||
: auth.token || "anonymous",
|
||||
);
|
||||
onMounted(theme.init);
|
||||
onBeforeUnmount(theme.dispose);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NuxtRouteAnnouncer />
|
||||
<BuildUpdateNotice />
|
||||
<OperationToasts />
|
||||
<NuxtLayout v-if="canRenderRoute" :key="routeSessionKey" :name="layout"
|
||||
><NuxtPage
|
||||
/></NuxtLayout>
|
||||
</template>
|
||||
Reference in new issue
Block a user