优化:完善分类规则与Excel配置维护并加速查询翻页
This commit is contained in:
+15
-1
@@ -1,5 +1,19 @@
|
||||
import { createContext, useContext } from 'react';
|
||||
import { createContext, useContext, useEffect, useRef } from 'react';
|
||||
|
||||
export const WORKSPACE_INVALIDATED = 'quality-workspace-invalidated';
|
||||
export const PageCacheContext = createContext({ active: true, initialSearch: undefined as string | undefined, refreshKey: 0, onLocationChange: (_search: string) => {} });
|
||||
export const usePageCache = () => useContext(PageCacheContext);
|
||||
|
||||
/** Revalidate retained maintenance data on a real revision change, not on every visit. */
|
||||
export function useMaintenanceRefresh(reload: () => void) {
|
||||
const { active, refreshKey } = usePageCache();
|
||||
const seen = useRef(refreshKey);
|
||||
const latest = useRef(reload);
|
||||
latest.current = reload;
|
||||
useEffect(() => {
|
||||
if (active && seen.current !== refreshKey) {
|
||||
seen.current = refreshKey;
|
||||
latest.current();
|
||||
}
|
||||
}, [active, refreshKey]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user