Skip to content

Commit

Permalink
feat: 流程图工具栏组件之整理画布
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangshigui committed Sep 20, 2024
1 parent 037366c commit 25d0edb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/views/process/components/FlowTool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: zhangshigui
* @Date: 2024-09-04 00:34:01
* @LastEditors: zhangshigui
* @LastEditTime: 2024-09-20 16:34:24
* @LastEditTime: 2024-09-20 16:47:37
* @Description: 工具栏组件
*
*/
Expand All @@ -13,10 +13,11 @@ import { useTranslation } from 'react-i18next';

export interface Iprops {
zoom: (val: number) => void;
tidy: () => void;
}
const FlowTool = (props: Iprops) => {
const { t } = useTranslation();
const { zoom } = props;
const { zoom, tidy } = props;

const [percent, Setpercent] = useState<number>(100);
// 最小|最大缩放比例
Expand Down Expand Up @@ -51,7 +52,7 @@ const FlowTool = (props: Iprops) => {
<PlusOutlined className={percent >= maxPercent ? 'disabled' : ''} onClick={() => handleZoom(20)} />
</Tooltip>
<Tooltip title={t('整理画布')}>
<BranchesOutlined />
<BranchesOutlined onClick={() => tidy()} />
</Tooltip>
</div>
);
Expand Down
8 changes: 7 additions & 1 deletion src/views/process/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ const Process = () => {
function handleZoom(value: number) {
graphMain?.graph.zoomTo(value);
}
// 整理画布
function handleTidy() {
//销毁并从父节点中移除节点/边
graphMain?.graph.dispose();
graphMain?.createGraph(map.current, minMap.current, data);
}
return (
<div className="graph-container">
{/* 画布容器 */}
Expand All @@ -32,7 +38,7 @@ const Process = () => {
<div id="min-map" ref={minMap} />

{/* 工具栏组件 */}
<FlowTool zoom={handleZoom} />
<FlowTool zoom={handleZoom} tidy={handleTidy} />
</div>
);
};
Expand Down

0 comments on commit 25d0edb

Please sign in to comment.