feat: reorganize project task planning UI

This commit is contained in:
2026-07-21 01:00:27 +08:00
parent c613d4c997
commit d6395d3c64
13 changed files with 251 additions and 171 deletions

View File

@@ -55,14 +55,9 @@ export function WorkspacePage({
const [editingTask, setEditingTask] = useState<WorkspaceTask | null>(null)
const [draft, setDraft] = useState<TaskDraft>({ title: '', summary: '', projectId: '', tag: '', completed: false })
const tagOptions = useMemo(() => {
const tags = new Set<string>()
const selectedWorkspace = workspaces.find((workspace) => workspace.project.id === draft.projectId)
selectedWorkspace?.tags
.filter((tag) => tag !== 'all' && tag !== '全部')
.forEach((tag) => tags.add(tag))
if (draft.tag) tags.add(draft.tag)
return Array.from(tags)
}, [draft.projectId, draft.tag, workspaces])
return selectedWorkspace?.tags.filter((tag) => tag !== 'all' && tag !== '全部') ?? []
}, [draft.projectId, workspaces])
useEffect(() => {
if (!editingTask) return
@@ -74,6 +69,10 @@ export function WorkspacePage({
completed: editingTask.completed,
})
}, [editingTask])
useEffect(() => {
if (!draft.tag || tagOptions.includes(draft.tag)) return
setDraft((value) => ({ ...value, tag: '' }))
}, [draft.tag, tagOptions])
const aiSessions = workspaces.flatMap((workspace) => workspace.aiSessions)
const notes = workspaces.flatMap((workspace) => workspace.notes)
const urgentProjects = projects.filter((project) => project.urgent).length
@@ -180,10 +179,10 @@ export function WorkspacePage({
<label>
<Text></Text>
<Select
allowCreate
value={draft.tag}
placeholder="选择或输入标签"
onChange={(tag) => setDraft((value) => ({ ...value, tag }))}
allowClear
value={draft.tag || undefined}
placeholder="不设置标签"
onChange={(tag) => setDraft((value) => ({ ...value, tag: tag ?? '' }))}
>
{tagOptions.map((tag) => (
<Select.Option key={tag} value={tag}>{tag}</Select.Option>