优化: 知识检索同项目加权与拒绝池
This commit is contained in:
+73
-1
@@ -17,6 +17,8 @@ import type {
|
||||
const state = reactive({
|
||||
items: [] as KnowledgeRecord[],
|
||||
candidates: [] as KnowledgeRecord[],
|
||||
archived: [] as KnowledgeRecord[],
|
||||
rejected: [] as KnowledgeRecord[],
|
||||
config: null as KnowledgeConfig | null,
|
||||
loading: false,
|
||||
error: null as string | null,
|
||||
@@ -161,11 +163,78 @@ export function useKnowledgeStore() {
|
||||
return ok === true
|
||||
}
|
||||
|
||||
// 分池:审核否决(候选/审核中 → rejected 独立池,不混归档箱)
|
||||
async function reject(id: string): Promise<boolean> {
|
||||
const ok = await runWithCatch(state, t('knowledge.err.rejectFailed'), async () => {
|
||||
await knowledgeApi.updateStatus(id, 'rejected')
|
||||
state.items = state.items.filter(k => k.id !== id)
|
||||
state.candidates = state.candidates.filter(k => k.id !== id)
|
||||
state.rejected = state.rejected.filter(k => k.id !== id)
|
||||
return true
|
||||
})
|
||||
return ok === true
|
||||
}
|
||||
|
||||
// 分池恢复:rejected → candidate 重新送审(拒绝池唯一出边)
|
||||
async function resubmit(id: string): Promise<boolean> {
|
||||
const ok = await runWithCatch(state, t('knowledge.err.resubmitFailed'), async () => {
|
||||
await knowledgeApi.updateStatus(id, 'candidate')
|
||||
state.rejected = state.rejected.filter(k => k.id !== id)
|
||||
return true
|
||||
})
|
||||
return ok === true
|
||||
}
|
||||
|
||||
async function archive(id: string): Promise<boolean> {
|
||||
const ok = await runWithCatch(state, t('knowledge.err.archiveFailed'), async () => {
|
||||
await knowledgeApi.archive(id)
|
||||
state.items = state.items.filter(k => k.id !== id)
|
||||
state.candidates = state.candidates.filter(k => k.id !== id)
|
||||
state.archived = state.archived.filter(k => k.id !== id)
|
||||
return true
|
||||
})
|
||||
return ok === true
|
||||
}
|
||||
|
||||
// ── 归档箱(2026-10-05 归档功能尾巴):查归档 + 恢复发布 ──
|
||||
async function loadArchived() {
|
||||
const seq = ++_itemsSeq
|
||||
state.loading = true
|
||||
state.error = null
|
||||
try {
|
||||
const result = await knowledgeApi.list('archived')
|
||||
if (seq !== _itemsSeq) return
|
||||
state.archived = result
|
||||
} catch (e: any) {
|
||||
if (seq !== _itemsSeq) return
|
||||
state.error = e?.toString() ?? t('knowledge.err.loadFailed')
|
||||
} finally {
|
||||
if (seq === _itemsSeq) state.loading = false
|
||||
}
|
||||
}
|
||||
|
||||
// 拒绝池(2026-10-05 分池):与归档箱分开可见
|
||||
async function loadRejected() {
|
||||
const seq = ++_itemsSeq
|
||||
state.loading = true
|
||||
state.error = null
|
||||
try {
|
||||
const result = await knowledgeApi.list('rejected')
|
||||
if (seq !== _itemsSeq) return
|
||||
state.rejected = result
|
||||
} catch (e: any) {
|
||||
if (seq !== _itemsSeq) return
|
||||
state.error = e?.toString() ?? t('knowledge.err.loadFailed')
|
||||
} finally {
|
||||
if (seq === _itemsSeq) state.loading = false
|
||||
}
|
||||
}
|
||||
|
||||
async function restore(id: string): Promise<boolean> {
|
||||
// archived → published 状态机恢复边(后端 validate_transition 已放行)
|
||||
const ok = await runWithCatch(state, t('knowledge.err.restoreFailed'), async () => {
|
||||
await knowledgeApi.updateStatus(id, 'published')
|
||||
state.archived = state.archived.filter(k => k.id !== id)
|
||||
return true
|
||||
})
|
||||
return ok === true
|
||||
@@ -228,12 +297,15 @@ export function useKnowledgeStore() {
|
||||
// 状态用 getter 实时读 state(防快照不跟随,同 project store 模式)
|
||||
get items() { return state.items },
|
||||
get candidates() { return state.candidates },
|
||||
get archived() { return state.archived },
|
||||
get rejected() { return state.rejected },
|
||||
get config() { return state.config },
|
||||
get loading() { return state.loading },
|
||||
get error() { return state.error },
|
||||
candidateCount,
|
||||
// actions
|
||||
loadList, loadCandidates, search, create, updateStatus, archive,
|
||||
loadList, loadCandidates, search, create, updateStatus, archive, loadArchived, restore,
|
||||
reject, loadRejected, resubmit,
|
||||
loadConfig, saveConfig, extractNow,
|
||||
getDetail, update, getEvents,
|
||||
clearError,
|
||||
|
||||
Reference in New Issue
Block a user