1
0
mirror of https://github.com/sendevia/website.git synced 2026-03-05 23:32:45 +08:00

feat: move build date fetch to onMounted lifecycle hook

This commit is contained in:
2025-10-09 20:34:22 +08:00
parent c18b53e22e
commit 132c009850

View File

@@ -1,23 +1,25 @@
<script setup lang="ts">
import { ref } from "vue";
import { ref, onMounted } from "vue";
import { useGlobalData } from "../composables/useGlobalData";
const { site, page, theme } = useGlobalData();
const siteVersion = theme.value.siteVersion;
const buildDate = ref("");
if (typeof window !== "undefined") {
fetch("/index.html", { method: "HEAD" })
.then((res) => {
const date = res.headers.get("last-modified");
buildDate.value = date ? new Date(date).toLocaleString() : new Date().toLocaleString();
})
.catch(() => {
buildDate.value = new Date().toLocaleString();
});
} else {
buildDate.value = new Date().toLocaleString();
}
onMounted(() => {
if (typeof window !== "undefined") {
fetch("/index.html", { method: "HEAD" })
.then((res) => {
const date = res.headers.get("last-modified");
buildDate.value = date ? new Date(date).toLocaleString() : new Date().toLocaleString();
})
.catch(() => {
buildDate.value = new Date().toLocaleString();
});
} else {
buildDate.value = new Date().toLocaleString();
}
});
</script>
<template>