修复: 前端UX一致性(Dashboard状态映射/状态徽章全局/Knowledge下一条与失败反馈/Ideas筛选与错误条/ConfirmDialog安全/快捷菜单状态机/分页越界) + 后端校验(queue/count-list一致/软删拒改/父聚合/promote CAS/MCP状态机收口/update白名单剔除id/created_at) + 销账

This commit is contained in:
lxy
2026-08-09 21:35:58 +08:00
parent 8bc5380ecb
commit fbd8fae44b
30 changed files with 829 additions and 138 deletions
+14 -5
View File
@@ -1,11 +1,15 @@
import { taskApi } from '@/api'
import type { TaskQuery, ProjectId } from '@/api/types'
import { t } from '@/i18n/i18n-helpers'
import { runWithCatch } from '@/composables/useStoreAction'
import { runWithCatch, runWithCatchGuarded } from '@/composables/useStoreAction'
import { state } from './state'
/** 任务 CRUD 子 store(共享全局 state) */
export function createTasksStore() {
// WK-10:并发 loadTasks 竞态守卫(快速切筛选/搜索防旧响应晚到覆盖新结果,
// 对齐 knowledge store 的 _itemsSeq 模式)。旧请求的失败也不污染当前视图。
let _tasksSeq = 0
/**
* 加载任务列表。
*
@@ -17,8 +21,10 @@ export function createTasksStore() {
* status/keyword 下沉后端 WHERE(P1/P2),取代 Tasks.vue 旧的前端内存 filter。
*/
async function loadTasks(queryOrProjectId?: TaskQuery | string) {
await runWithCatch(state, t('tasks.err.loadFailed'), async () => {
state.tasks = await taskApi.list(queryOrProjectId)
const seq = ++_tasksSeq
await runWithCatchGuarded(state, t('tasks.err.loadFailed'), () => seq === _tasksSeq, async () => {
const result = await taskApi.list(queryOrProjectId)
if (seq === _tasksSeq) state.tasks = result
})
}
@@ -51,13 +57,16 @@ export function createTasksStore() {
})
}
async function deleteTask(id: string) {
await runWithCatch(state, t('tasks.err.deleteFailed'), async () => {
async function deleteTask(id: string): Promise<boolean> {
// WK-13:返成功布尔(失败时 runWithCatch 已置 state.error),快捷删除据此 toast 反馈
const ok = await runWithCatch(state, t('tasks.err.deleteFailed'), async () => {
// 后端已级联软删子任务(delete_task 返回 { ok, cascaded });
// 本地同步移除父任务 + 其直接子任务(1 级嵌套,防悬挂 parent_id)
await taskApi.delete(id)
state.tasks = state.tasks.filter(t => t.id !== id && t.parent_id !== id)
return true
})
return ok === true
}
return {