refactor: 重构前端代码并增加注释

This commit is contained in:
2026-04-06 14:24:45 +08:00
parent 882e14a47b
commit 120edca338
13 changed files with 463 additions and 312 deletions
+21
View File
@@ -0,0 +1,21 @@
import { useState, useCallback } from 'react';
import type { GraphLayoutConfig } from '../types/graph';
import { DEFAULT_LAYOUT } from '../config/layout';
/**
* 知识图谱布局管理 Hook
* 负责布局状态的管理和切换
*/
export const useGraphLayout = () => {
const [layout, setLayout] = useState<GraphLayoutConfig>(DEFAULT_LAYOUT);
// 切换布局类型(目前只支持 force 力导向布局)
const handleLayoutChange = useCallback((newLayoutType: GraphLayoutConfig['type']) => {
setLayout({ type: newLayoutType });
}, []);
return {
layout,
handleLayoutChange,
};
};