import { useConfigStore } from './store'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Button } from '@/components/ui/button'; import { Checkbox } from '@/components/ui/checkbox'; import { configSchema } from './store/schema'; export const ConfigPage = () => { const { config, setConfig, resetConfig } = useConfigStore(); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); const result = configSchema.safeParse(config); if (result.success) { console.log('配置已保存:', config); // 可以在此处添加 toast 通知 } else { console.error('验证错误:', result.error.format()); } }; const handleChange = (field: keyof typeof config, value: string | boolean) => { setConfig({ [field]: value }); }; return (
CNB 配置 配置您的 CNB API 设置。这些设置会保存在浏览器的本地存储中。
handleChange('CNB_API_KEY', e.target.value)} placeholder="请输入您的 CNB API 密钥" />
handleChange('CNB_COOKIE', e.target.value)} placeholder="请输入您的 CNB Cookie" />
handleChange('CNB_CORS_URL', e.target.value)} placeholder="https://cors.example.com" />
handleChange('ENABLE_CORS', checked === true)} />
handleChange('AI_BASE_URL', e.target.value)} placeholder="请输入 AI 基础地址" />
handleChange('AI_MODEL', e.target.value)} placeholder="请输入 AI 模型名称" />
handleChange('AI_API_KEY', e.target.value)} placeholder="请输入您的 AI API 密钥" />
); }; export default ConfigPage;