Files
jindengchen-ai-report/cool-unix/cool/hooks/cache.ts

29 lines
379 B
TypeScript
Raw Normal View History

2025-11-13 10:36:23 +08:00
import { reactive, watch } from "vue";
import { isDark } from "../theme";
type CacheData = {
key: number;
};
type UseCache = {
cache: CacheData;
};
export const useCache = (source: () => any[]): UseCache => {
const cache = reactive<CacheData>({
key: 0
});
watch(source, () => {
cache.key++;
});
watch(isDark, () => {
cache.key++;
});
return {
cache
};
};