diff --git a/src/stores/knowledge.ts b/src/stores/knowledge.ts index aa1c6e6..d175c64 100644 --- a/src/stores/knowledge.ts +++ b/src/stores/knowledge.ts @@ -79,8 +79,14 @@ export function useKnowledgeStore() { async function create(input: CreateKnowledgeInput) { const record = await knowledgeApi.create(input) - // 手动录入默认 candidate,刷新收件箱 - await loadCandidates() + // 手动录入默认 candidate,刷新收件箱。 + // create 已成功返回 record,刷新失败不应污染成功语义 —— 直接走原始 API + 非阻塞 console.warn, + // 不经 loadCandidates(后者会写 state.error,污染 create 成功语义)。 + try { + state.candidates = await knowledgeApi.listCandidates() + } catch (e: any) { + console.warn('create 后刷新收件箱失败(非阻塞)', e?.toString?.() ?? e) + } return record } @@ -140,6 +146,11 @@ export function useKnowledgeStore() { // 候选数量(供侧栏 badge 用) const candidateCount = computed(() => state.candidates.length) + // 清除错误条(供 Knowledge.vue error-banner 关闭按钮调用) + function clearError() { + state.error = null + } + return reactive({ // 状态用 getter 实时读 state(防快照不跟随,同 project store 模式) get items() { return state.items }, @@ -152,5 +163,6 @@ export function useKnowledgeStore() { loadList, loadCandidates, search, create, updateStatus, archive, loadConfig, saveConfig, extractNow, getDetail, update, getEvents, + clearError, }) } diff --git a/src/views/Knowledge.vue b/src/views/Knowledge.vue index edce7c5..910d38a 100644 --- a/src/views/Knowledge.vue +++ b/src/views/Knowledge.vue @@ -8,6 +8,12 @@ + +
+