Skip to content

Commit 2e297a0

Browse files
committed
💄 调整window undefined下的颜色
1 parent feb21c1 commit 2e297a0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

‎docs/.vuepress/components/ProjCardDev.vue

+4-3
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,22 @@ interface ProjCardDevProps {
3636
3737
const props = defineProps<ProjCardDevProps>();
3838
39-
function isDarkTheme(): boolean {
39+
function isDarkTheme(): boolean | null {
4040
const theme = useLocalStorage<"auto" | "dark" | "light">("vuepress-theme-hope-scheme", "auto");
41-
// window is not defined in SSR
42-
if (theme.value === "auto" && typeof window === "undefined") return false;
41+
if (theme.value === "auto" && typeof window === "undefined") return null;
4342
return theme.value === "auto"
4443
? window.matchMedia("(prefers-color-scheme: dark)").matches
4544
: theme.value === "dark";
4645
}
4746
4847
const contentBg = computed(() => {
4948
const theme = isDarkTheme();
49+
if (theme === null) return "transparent";
5050
return theme ? "#333333" : "#ffffff";
5151
});
5252
const shadowColor = computed(() => {
5353
const theme = isDarkTheme();
54+
if (theme === null) return "rgba(0,0,0,0.48)";
5455
return theme ? "rgba(255,223,0,0.48)" : "#d9d9d9";
5556
});
5657

0 commit comments

Comments
 (0)