app.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <UApp>
  3. <AdminLoadingOverlay />
  4. <component :is="DynamicHeader" v-if="!isAdminPage && isIndexPage" />
  5. <NuxtLayout>
  6. <NuxtPage />
  7. </NuxtLayout>
  8. <component :is="DynamicFooter" v-if="!isAdminPage && isIndexPage" />
  9. </UApp>
  10. </template>
  11. <script setup>
  12. import { computed, defineAsyncComponent, watch } from "vue";
  13. import { useRoute } from "vue-router";
  14. import { useHead } from "#app";
  15. const route = useRoute();
  16. const config = useRuntimeConfig();
  17. // admin 페이지 체크
  18. const isAdminPage = computed(() => {
  19. return route.path.startsWith("/site-manager");
  20. });
  21. // index 페이지 체크 (홈)
  22. const isIndexPage = computed(() => {
  23. return route.path === "/";
  24. });
  25. // 파비콘 동적 설정
  26. const favicon = computed(() => {
  27. if (route.path.includes("/lincoln")) {
  28. return "/favicon-lincoln.ico";
  29. }
  30. return "/favicon-ford.ico";
  31. });
  32. // 타이틀 동적 설정
  33. const pageTitle = computed(() => {
  34. return "파이럿존";
  35. });
  36. useHead(() => ({
  37. title: pageTitle.value,
  38. link: [
  39. {
  40. rel: "icon",
  41. type: "image/x-icon",
  42. href: favicon.value,
  43. },
  44. ],
  45. }));
  46. // 파비콘 강제 업데이트 (브라우저 캐시 우회)
  47. watch(favicon, (newFavicon) => {
  48. const link = document.querySelector("link[rel='icon']");
  49. if (link) {
  50. link.href = newFavicon + "?v=" + Date.now();
  51. }
  52. });
  53. // 동적 Header 컴포넌트
  54. const DynamicHeader = defineAsyncComponent(() => import(`~/components/header.vue`));
  55. // 동적 Footer 컴포넌트
  56. const DynamicFooter = defineAsyncComponent(() => import(`~/components/footer.vue`));
  57. </script>
  58. <style setup>
  59. @import "tailwindcss";
  60. @import "@nuxt/ui";
  61. </style>