修复ai总开关关闭后ai评论仍然显示

This commit is contained in:
mtvpls
2026-06-22 09:20:14 +08:00
parent 741e49e75a
commit 5bf15e4086
+4 -1
View File
@@ -1,6 +1,7 @@
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
interface RuntimeConfig { interface RuntimeConfig {
AI_ENABLED?: boolean;
AIConfig?: { AIConfig?: {
EnableAIComments?: boolean; EnableAIComments?: boolean;
}; };
@@ -13,7 +14,9 @@ export function useEnableAIComments(): boolean {
// 在客户端获取运行时配置 // 在客户端获取运行时配置
if (typeof window !== 'undefined') { if (typeof window !== 'undefined') {
const runtimeConfig = (window as any).RUNTIME_CONFIG as RuntimeConfig; const runtimeConfig = (window as any).RUNTIME_CONFIG as RuntimeConfig;
setEnableAIComments(runtimeConfig?.AIConfig?.EnableAIComments ?? false); setEnableAIComments(
Boolean(runtimeConfig?.AI_ENABLED && runtimeConfig?.AIConfig?.EnableAIComments)
);
} }
}, []); }, []);