From 1876f71537adea9b65790c05ecefdf14ef12cdfd Mon Sep 17 00:00:00 2001 From: cfdaily Date: Sun, 17 May 2026 06:16:07 +0800 Subject: [PATCH] auto-sync: 2026-05-17 06:16:06 --- src/frontend/src/pages/Config.tsx | 113 ++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 src/frontend/src/pages/Config.tsx diff --git a/src/frontend/src/pages/Config.tsx b/src/frontend/src/pages/Config.tsx new file mode 100644 index 0000000..a7d78f7 --- /dev/null +++ b/src/frontend/src/pages/Config.tsx @@ -0,0 +1,113 @@ +// 系统配置页面 + +import React, { useState } from 'react'; +import { useProjects } from '../hooks/useApi'; +import * as api from '../api'; + +export function Config() { + const { projects, loading, refresh } = useProjects(); + const [newName, setNewName] = useState(''); + const [newDesc, setNewDesc] = useState(''); + const [creating, setCreating] = useState(false); + const [error, setError] = useState(null); + + const handleCreate = async () => { + if (!newName.trim()) return; + try { + setCreating(true); + setError(null); + await api.createProject({ name: newName, description: newDesc || null }); + setNewName(''); + setNewDesc(''); + refresh(); + } catch (e) { + setError(String(e)); + } finally { + setCreating(false); + } + }; + + return ( +
+

系统配置

+ + {/* 创建项目 */} +
+
创建项目
+
+ setNewName(e.target.value)} + style={{ + flex: 1, + padding: '6px 10px', + borderRadius: 'var(--radius)', + border: '1px solid var(--line)', + background: 'var(--bg)', + color: 'var(--fg)', + }} + /> + setNewDesc(e.target.value)} + style={{ + flex: 2, + padding: '6px 10px', + borderRadius: 'var(--radius)', + border: '1px solid var(--line)', + background: 'var(--bg)', + color: 'var(--fg)', + }} + /> + +
+ {error &&

{error}

} +
+ + {/* 项目列表 */} +
+
已有项目
+ {loading ? ( +
加载中...
+ ) : ( +
+ + + + + + + + + + + {projects.map(p => ( + + + + + + + ))} + +
ID名称描述状态
{p.id.substring(0, 8)}{p.name}{p.description || '-'} + + {p.status} + +
+
+ )} +
+
+ ); +}