From 81ca27689fcce3f1dc4c06895660932b597264a1 Mon Sep 17 00:00:00 2001 From: shinya Date: Mon, 7 Apr 2025 00:59:10 +0800 Subject: [PATCH] fix: theme change when giscus not loaded --- src/components/Comments/Giscus.astro | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/Comments/Giscus.astro b/src/components/Comments/Giscus.astro index 624aa31..8212d73 100644 --- a/src/components/Comments/Giscus.astro +++ b/src/components/Comments/Giscus.astro @@ -62,7 +62,11 @@ const { function changeGiscusTheme() { const iframe = document.querySelector("iframe.giscus-frame"); - if (!iframe) return; + if (!iframe || iframe.classList.contains("giscus-frame--loading")) { + // 脚本未加载场景 + loadGiscus(); + return; + }; const theme = document.documentElement.classList.contains("dark") ? host + "/css/giscus_dark.css" : host + "/css/giscus_light.css";