增加评论开关,尝试修复循环依赖

This commit is contained in:
mtvpls
2025-12-03 18:20:34 +08:00
parent 567ee54c67
commit 4e05c7bcaa
11 changed files with 416 additions and 194 deletions
+19
View File
@@ -0,0 +1,19 @@
import { useState, useEffect } from 'react';
interface RuntimeConfig {
EnableComments: boolean;
}
export function useEnableComments(): boolean {
const [enableComments, setEnableComments] = useState(true);
useEffect(() => {
// 在客户端获取运行时配置
if (typeof window !== 'undefined') {
const runtimeConfig = (window as any).RUNTIME_CONFIG as RuntimeConfig;
setEnableComments(runtimeConfig?.EnableComments ?? true);
}
}, []);
return enableComments;
}