fix(todo): 编辑时内容为空则自动删除任务项
This commit is contained in:
@@ -148,7 +148,18 @@ export const TodoPage: React.FC = () => {
|
||||
if (!editingItem) return
|
||||
const { date, index } = editingItem
|
||||
const newContent = editContent.trim()
|
||||
if (!newContent) return
|
||||
if (!newContent) {
|
||||
try {
|
||||
const data = await deleteTodoItem(currentYear, currentMonth, date, index)
|
||||
setDayTodos(data.dayTodos)
|
||||
} catch (error) {
|
||||
console.error('Failed to delete TODO:', error)
|
||||
} finally {
|
||||
setEditingItem(null)
|
||||
setEditContent('')
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const data = await updateTodoItem(currentYear, currentMonth, date, index, newContent)
|
||||
|
||||
Reference in New Issue
Block a user