From 531d6621369f523bf4ee4322fd657932c1582574 Mon Sep 17 00:00:00 2001
From: XiYang6666 <1782356858@qq.com>
Date: Sun, 12 May 2024 15:35:40 +0800
Subject: [PATCH] :bug: fix undefined value
---
.env.example | 4 ++--
app.vue | 23 ++++++++++++++---------
nuxt.config.ts | 9 +++------
3 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/.env.example b/.env.example
index cb7a4c8..9dedfb5 100644
--- a/.env.example
+++ b/.env.example
@@ -11,5 +11,5 @@ NUXT_GRAVATAR_URL = "https://gravatar.com"
NUXT_AVATAR_CACHE_TIME = 3600000
-NUXT_PUBLIC_LINKS = {"blog":"https://blog.example.com","forum":"https://forum.example.com"}
-NUXT_PUBLIC_SOCIALS = {"github":{"link":"https://github.com/","icon":"fa-brands fa-github"},"bilibili":{"link":"https://www.bilibili.com/","icon":"fa-brands fa-bilibili"},"email":{"link":"mailto:example@example.com","icon":"fa-solid fa-envelope"}}
+NUXT_LINKS = {"blog":"https://blog.example.com","forum":"https://forum.example.com"}
+NUXT_SOCIALS = {"github":{"link":"https://github.com/","icon":"fa-brands fa-github"},"bilibili":{"link":"https://www.bilibili.com/","icon":"fa-brands fa-bilibili"},"email":{"link":"mailto:example@example.com","icon":"fa-solid fa-envelope"}}
diff --git a/app.vue b/app.vue
index bb3fff7..4ccc6a4 100644
--- a/app.vue
+++ b/app.vue
@@ -10,7 +10,9 @@
- {{ hitokoto }}
+ {{
+ hitokoto
+ }}
@@ -56,15 +58,18 @@ useHead({
],
});
-const ownerName = ref(config.ownerName);
-const description = ref(config.description);
+const ownerName = useState(() => config.ownerName);
+const description = useState(() => config.description);
-const hitokotoData: Record = await $fetch(config.hitokotoUrl);
-const hitokoto = hitokotoData.hitokoto;
+const hitokoto: Ref = useState();
-const footer = ref(config.footer);
+if (process.server) {
+ const hitokotoData: Record = await $fetch(config.hitokotoUrl);
+ hitokoto.value = hitokotoData.hitokoto;
+}
-const links = ref(config.public.links as Record);
-const socials = ref(config.public.socials as Record);
-
+const footer = useState(() => config.footer);
+const links = useState(() => config.links as Record);
+const socials = useState(() => config.socials as Record);
+
diff --git a/nuxt.config.ts b/nuxt.config.ts
index fef9f94..b787a71 100644
--- a/nuxt.config.ts
+++ b/nuxt.config.ts
@@ -8,14 +8,11 @@ export default defineNuxtConfig({
ownerEmail: "example@example.com",
ownerName: "Example",
description: "Welcome to Example's main page",
- footer: 'an example footer',
+ footer: "an example footer",
hitokotoUrl: "https://v1.hitokoto.cn",
gravatarUrl: "https://gravatar.com",
avatarCacheTime: 60 * 60 * 1000, // 1 hour
- public: {
- links: {},
- socials: {},
- },
+ links: {},
+ socials: {},
},
});
-