import { useGiteaConfigStore } from './store'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Button } from '@/components/ui/button'; import { giteaConfigSchema } from './store/schema'; import { toast } from 'sonner'; import { useLayoutStore } from '../../auth/store'; import { useShallow } from 'zustand/shallow'; import { useEffect } from 'react'; export const GiteaConfigPage = () => { const { config, setConfig, resetConfig, saveToRemote, loadFromRemote, checkConfig } = useGiteaConfigStore(); const layoutStore = useLayoutStore(useShallow(state => ({ me: state.me }))) useEffect(() => { if (layoutStore.me) { checkConfig({ isUser: !!layoutStore.me, reload: true }) } }, []) const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); const result = giteaConfigSchema.safeParse(config); if (result.success) { toast.success('Gitea 配置已保存'); setTimeout(() => { location.reload(); }, 400); } else { console.error('验证错误:', result.error.format()); toast.error('配置验证失败'); } }; const handleChange = (field: keyof typeof config, value: string) => { setConfig({ [field]: value }); }; return (
配置您的 Gitea API 设置。这些设置会保存在浏览器的本地存储中。