diff --git a/src/components/widget/Profile.astro b/src/components/widget/Profile.astro
index dabe5ba..26e7dc3 100644
--- a/src/components/widget/Profile.astro
+++ b/src/components/widget/Profile.astro
@@ -3,6 +3,7 @@ import { Icon } from "astro-icon/components";
import { profileConfig } from "../../config";
import { url } from "../../utils/url-utils";
import ImageWrapper from "../misc/ImageWrapper.astro";
+import TotalWords from "./TotalWords.astro";
const config = profileConfig;
---
@@ -45,6 +46,8 @@ const config = profileConfig;
}
+
+
@@ -74,18 +77,37 @@ const config = profileConfig;
fetch("https://v1.hitokoto.cn")
.then(response => response.json())
.then(data => {
- // API 返回的字段是 data.text
- document.getElementById("hitokoto").innerText = data.hitokoto;
+ const hitokotoElement = document.getElementById("hitokoto");
+ if (hitokotoElement) {
+ hitokotoElement.innerText = data.hitokoto;
+ }
})
.catch(error => {
console.error("获取一言失败:", error);
- //document.getElementById("hitokoto").innerText = "获取失败,请稍后再试。";
- //失败后用内置的,成功了用别人的。
- document.getElementById("hitokoto").innerText = "再热情的心也经不起冷漠,再爱你的人也经不起冷落。";
+ const hitokotoElement = document.getElementById("hitokoto");
+ if (hitokotoElement) {
+ hitokotoElement.innerText = "再热情的心也经不起冷漠,再爱你的人也经不起冷落。";
+ }
});