"use client" import {useMutation, useQueryClient, type UseQueryResult} from "@tanstack/react-query" import {Globe, Search} from "lucide-react" import {Card, CardContent, CardDescription, CardHeader, CardTitle} from "@/components/ui/card" import {Switch} from "@/components/ui/switch" import {AdminService} from "@/lib/services" import type {SystemConfig} from "@/lib/services/admin" import {TemplatesManager} from "./templates" import {toast} from "sonner" interface OperationTabProps { configs: Record systemConfigsQuery: UseQueryResult } export function OperationTab({ configs, systemConfigsQuery }: OperationTabProps) { const queryClient = useQueryClient() const updateConfigMutation = useMutation({ mutationFn: async ({ key, value }: { key: string; value: boolean }) => { const config = configs[key] if (!config) { throw new Error(`缺少配置项: ${key}`) } await AdminService.updateSystemConfig(key, { value: value ? "true" : "false", description: config.description, }) }, onSuccess: async () => { await queryClient.invalidateQueries({ queryKey: ["admin", "system-configs"] }) await queryClient.invalidateQueries({ queryKey: ["public-config"] }) toast.success("运营配置已更新") }, onError: (error: Error) => { toast.error(error.message || "更新配置失败") }, }) const indexingEnabled = configs["search_engine_indexing_enabled"]?.value === "true" return (
{/* 搜索引擎检索设置 */}
SEO 与搜索引擎检索 配置站点是否允许被搜索引擎抓取和检索
允许被搜索引擎检索

默认关闭。关闭后系统将自动下发 noindex 指令并限制 robots.txt,禁止搜索引擎爬虫抓取本站页面。

updateConfigMutation.mutate({ key: "search_engine_indexing_enabled", value: checked }) } />
{/* 通知模板管理 */}
) }