generated from kevisual/vite-react-template
feat: 添加远端配置保存与加载功能,优化配置检查逻辑
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user