feat: 添加远端配置保存与加载功能,优化配置检查逻辑

This commit is contained in:
2026-02-27 01:59:06 +08:00
parent ee176fd80b
commit 58563ece93
2 changed files with 72 additions and 2 deletions

View File

@@ -5,10 +5,20 @@ 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 } = useGiteaConfigStore();
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();
@@ -66,6 +76,15 @@ export const GiteaConfigPage = () => {
<Button type="button" variant="outline" onClick={resetConfig}>
</Button>
{layoutStore.me && <>
<Button type="button" variant="outline" onClick={loadFromRemote}>
</Button>
<Button type="button" variant="outline" onClick={saveToRemote}>
</Button>
</>
}
</div>
</form>
</CardContent>