mirror of
https://github.com/hay-kot/homebox.git
synced 2024-11-23 09:05:42 +00:00
18 lines
354 B
TypeScript
18 lines
354 B
TypeScript
|
import type { Ref } from "vue";
|
||
|
|
||
|
type TreeState = Record<string, boolean>;
|
||
|
|
||
|
const store: Record<string, Ref<TreeState>> = {};
|
||
|
|
||
|
export function newTreeKey(): string {
|
||
|
return Math.random().toString(36).substring(2);
|
||
|
}
|
||
|
|
||
|
export function useTreeState(key: string): Ref<TreeState> {
|
||
|
if (!store[key]) {
|
||
|
store[key] = ref({});
|
||
|
}
|
||
|
|
||
|
return store[key];
|
||
|
}
|