This commit is contained in:
2025-03-02 22:49:17 +08:00
parent d2c13c43a8
commit f8b874ae61
6 changed files with 651 additions and 191 deletions

View File

@@ -1,12 +1,14 @@
import { useReactFlow } from '@xyflow/react';
import { useEffect } from 'react';
import { useWallStore } from '../store/wall';
import { useShallow } from 'zustand/react/shallow';
export const useTabNode = () => {
const reactFlowInstance = useReactFlow();
const open = useWallStore(useShallow((state) => state.open));
useEffect(() => {
if (open) return;
const listener = (event: any) => {
if (event.key === 'Tab') {
console.log('tab');
const nodes = reactFlowInstance.getNodes();
const selectedNode = nodes.find((node) => node.selected);
if (!selectedNode) return;
@@ -58,5 +60,5 @@ export const useTabNode = () => {
return () => {
window.removeEventListener('keydown', listener);
};
}, [reactFlowInstance]);
}, [reactFlowInstance, open]);
};

View File

@@ -1,14 +1,16 @@
import { get, set, clear } from 'idb-keyval';
import { MyCache } from '@kevisual/cache';
const cache = new MyCache('cacheWall');
export async function getWallData() {
const data = await get('cacheWall');
const data = await cache.getData();
return data;
}
export async function setWallData(data: any) {
await set('cacheWall', data);
await cache.setData(data);
}
export async function clearWallData() {
await clear();
await cache.del();
}