XiaoDaiGua-Ray 15b1da763f
fix: address system-wide UI and data review findings
Restore keyboard navigation and fix page refresh, icons, and table interactions.

Guard concurrent edits and align Mock persistence with the API contracts.
2026-11-18 10:25:41 +08:00

56 lines
1.6 KiB
TypeScript

export interface RuntimeState {
globalSpinning: boolean
globalDrawerValue: boolean
refreshingPath: string | null
globalMainLayoutLoad: boolean
layoutContentMaximize: boolean
layoutContentMaximizeVersion: number
layoutContentSpinning: boolean
layoutContentMaximizeStyle: {
zIndex: number
backgroundColor?: string
transition?: string
}
}
export const piniaRuntimeStore = defineStore('runtime', () => {
const state = reactive<RuntimeState>({
globalSpinning: false,
globalDrawerValue: false,
refreshingPath: null,
globalMainLayoutLoad: true,
layoutContentMaximize: false,
layoutContentMaximizeVersion: 0,
layoutContentSpinning: false,
layoutContentMaximizeStyle: { zIndex: 999 },
})
let reloadTimer: ReturnType<typeof setTimeout> | undefined
const setRuntimeState = <K extends keyof RuntimeState>(
key: K,
value: RuntimeState[K],
) => {
if (key === 'layoutContentMaximize' && state[key] !== value) {
state.layoutContentMaximizeVersion += 1
}
state[key] = value
}
// 刷新会卸载发起调用的页面,计时器必须由 store 持有;重复刷新以最后一次为准。
const reloadContent = (wait = 800, path: string | null = null) => {
clearTimeout(reloadTimer)
state.refreshingPath = path
state.globalMainLayoutLoad = false
reloadTimer = setTimeout(() => {
state.globalMainLayoutLoad = true
state.refreshingPath = null
reloadTimer = void 0
}, wait)
}
onScopeDispose(() => clearTimeout(reloadTimer))
return { ...toRefs(state), setRuntimeState, reloadContent }
})