mirror of
https://gitee.com/mateos/mateclaw.git
synced 2026-09-13 03:13:41 +08:00
fix(wiki): keep the raw-material filter across page-list refreshes (#156)
This commit is contained in:
parent
fb4206e356
commit
cfb123dda2
@ -1,4 +1,4 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { acceptHMRUpdate, defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
import { agentApi } from '@/api/index'
|
||||
import type { Agent } from '@/types/index'
|
||||
@ -41,3 +41,9 @@ export const useAgentStore = defineStore('agent', () => {
|
||||
|
||||
return { agents, loading, fetchAgents, createAgent, updateAgent, deleteAgent }
|
||||
})
|
||||
|
||||
// Enable HMR for this store: editing it during `pnpm dev` patches the live
|
||||
// store instead of requiring a full page reload. Stripped from prod builds.
|
||||
if (import.meta.hot) {
|
||||
import.meta.hot.accept(acceptHMRUpdate(useAgentStore, import.meta.hot))
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { acceptHMRUpdate, defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
import { cronJobApi } from '@/api/index'
|
||||
import type { CronJob } from '@/types/index'
|
||||
@ -51,3 +51,9 @@ export const useCronJobStore = defineStore('cronJob', () => {
|
||||
|
||||
return { jobs, loading, fetchJobs, createJob, updateJob, deleteJob, toggleJob, runNow }
|
||||
})
|
||||
|
||||
// Enable HMR for this store: editing it during `pnpm dev` patches the live
|
||||
// store instead of requiring a full page reload. Stripped from prod builds.
|
||||
if (import.meta.hot) {
|
||||
import.meta.hot.accept(acceptHMRUpdate(useCronJobStore, import.meta.hot))
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { acceptHMRUpdate, defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
import { http } from '@/api'
|
||||
|
||||
@ -85,3 +85,9 @@ export const useMemoryStore = defineStore('memory', () => {
|
||||
subscribeEvents, unsubscribeEvents,
|
||||
}
|
||||
})
|
||||
|
||||
// Enable HMR for this store: editing it during `pnpm dev` patches the live
|
||||
// store instead of requiring a full page reload. Stripped from prod builds.
|
||||
if (import.meta.hot) {
|
||||
import.meta.hot.accept(acceptHMRUpdate(useMemoryStore, import.meta.hot))
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { acceptHMRUpdate, defineStore } from 'pinia'
|
||||
import { ref, watch } from 'vue'
|
||||
|
||||
export type ThemeMode = 'light' | 'dark' | 'system'
|
||||
@ -48,3 +48,9 @@ export const useThemeStore = defineStore('theme', () => {
|
||||
|
||||
return { mode, isDark, setMode, toggle }
|
||||
})
|
||||
|
||||
// Enable HMR for this store: editing it during `pnpm dev` patches the live
|
||||
// store instead of requiring a full page reload. Stripped from prod builds.
|
||||
if (import.meta.hot) {
|
||||
import.meta.hot.accept(acceptHMRUpdate(useThemeStore, import.meta.hot))
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { acceptHMRUpdate, defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
import { wikiApi } from '@/api/index'
|
||||
|
||||
@ -129,14 +129,18 @@ export const useWikiStore = defineStore('wiki', () => {
|
||||
if (!rawId) totalPageCount.value = pages.value.length
|
||||
}
|
||||
|
||||
async function refreshCurrentKB(options: { preserveRawFilter?: boolean } = {}) {
|
||||
// Background refreshes (job completion, SSE events, fallback polling) must
|
||||
// not drop the user's active raw-material filter. Re-fetch the page list
|
||||
// scoped to selectedRawId whenever a filter is applied — otherwise the list
|
||||
// silently reverts to every material's pages while the filter banner still
|
||||
// claims a filter is active.
|
||||
async function refreshCurrentKB() {
|
||||
if (!currentKB.value) return
|
||||
const kbId = currentKB.value.id
|
||||
const rawId = options.preserveRawFilter ? selectedRawId.value : null
|
||||
const [kbRes] = await Promise.all([
|
||||
wikiApi.getKB(kbId),
|
||||
fetchRawMaterials(kbId),
|
||||
fetchPages(kbId, rawId ?? undefined),
|
||||
fetchPages(kbId, selectedRawId.value ?? undefined),
|
||||
])
|
||||
const nextKB = (kbRes as any).data || kbRes
|
||||
currentKB.value = nextKB
|
||||
@ -221,3 +225,9 @@ export const useWikiStore = defineStore('wiki', () => {
|
||||
scanDirectory,
|
||||
}
|
||||
})
|
||||
|
||||
// Enable HMR for this store: editing it during `pnpm dev` patches the live
|
||||
// store instead of requiring a full page reload. Stripped from prod builds.
|
||||
if (import.meta.hot) {
|
||||
import.meta.hot.accept(acceptHMRUpdate(useWikiStore, import.meta.hot))
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { acceptHMRUpdate, defineStore } from 'pinia'
|
||||
import { ref, computed } from 'vue'
|
||||
import { workspaceTeamApi } from '@/api/index'
|
||||
import type { Capability, WorkspaceRole } from '@/composables/capabilities'
|
||||
@ -126,3 +126,9 @@ export const useWorkspaceStore = defineStore('workspace', () => {
|
||||
refreshAccess,
|
||||
}
|
||||
})
|
||||
|
||||
// Enable HMR for this store: editing it during `pnpm dev` patches the live
|
||||
// store instead of requiring a full page reload. Stripped from prod builds.
|
||||
if (import.meta.hot) {
|
||||
import.meta.hot.accept(acceptHMRUpdate(useWorkspaceStore, import.meta.hot))
|
||||
}
|
||||
|
||||
@ -295,7 +295,8 @@ async function handleBatchDelete() {
|
||||
try {
|
||||
await wikiApi.batchDeletePages(store.currentKB.id, selectedSlugs.value)
|
||||
exitBatchMode()
|
||||
await store.fetchPages(store.currentKB.id)
|
||||
// Keep the active raw-material filter so the list doesn't jump to all pages.
|
||||
await store.fetchPages(store.currentKB.id, store.selectedRawId)
|
||||
} catch (e: any) {
|
||||
alert(e?.message || 'Batch delete failed')
|
||||
}
|
||||
@ -322,7 +323,8 @@ async function restoreArchivedPage(slug: string) {
|
||||
try {
|
||||
await wikiApi.unarchivePage(store.currentKB.id, slug)
|
||||
archivedPages.value = archivedPages.value.filter(p => p.slug !== slug)
|
||||
await store.fetchPages(store.currentKB.id)
|
||||
// Keep the active raw-material filter so the list doesn't jump to all pages.
|
||||
await store.fetchPages(store.currentKB.id, store.selectedRawId)
|
||||
} catch (e: any) {
|
||||
console.error('[Wiki] Unarchive failed', e)
|
||||
alert(e?.message || 'Unarchive failed')
|
||||
|
||||
@ -186,7 +186,8 @@ async function handleDelete() {
|
||||
try {
|
||||
await wikiApi.deletePage(store.currentKB.id, store.currentPage.slug)
|
||||
store.currentPage = null
|
||||
await store.fetchPages(store.currentKB.id)
|
||||
// Keep the active raw-material filter so the list doesn't jump to all pages.
|
||||
await store.fetchPages(store.currentKB.id, store.selectedRawId)
|
||||
} catch (e: any) {
|
||||
alert(e?.message || 'Delete failed')
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user