From 83c548d3dba59aaed9b52b5d413c6912a87d2efc Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期日, 16 六月 2024 15:50:14 +0800
Subject: [PATCH] #
---
zy-asrs-flow/src/pages/home/index.jsx | 111 +++++++++++++------------------------------------------
1 files changed, 26 insertions(+), 85 deletions(-)
diff --git a/zy-asrs-flow/src/pages/home/index.jsx b/zy-asrs-flow/src/pages/home/index.jsx
index 92634cc..780dccf 100644
--- a/zy-asrs-flow/src/pages/home/index.jsx
+++ b/zy-asrs-flow/src/pages/home/index.jsx
@@ -1,91 +1,32 @@
-import React, { useEffect, useState } from 'react';
-import ReactDOM from 'react-dom';
-import { data } from './data';
-import G6 from '@antv/g6';
-import "./index.css"
+import React, { useEffect, useRef, useState } from "react";
+import { Graph, Shape } from "@antv/x6";
+import { GraphComponent } from "../../components/Flow/GraphComponent";
+import { GraphTools } from "../../components/Flow/GraphTools";
+import { RightMenu } from "../../components/Flow/RightMenu";
+import { GraphDrawer } from "../../components/Flow/GraphDrawer";
+import './index.less';
-export default function() {
- const ref = React.useRef(null);
- let graph = null;
+export default function () {
+ const graphRef = useRef(null);
+ const [ready, setReady] = useState(false);
- useEffect(() => {
- if (!graph) {
- graph = new G6.Graph({
- container: ReactDOM.findDOMNode(ref.current),
- width: document.documentElement.clientWidth,
- height: document.documentElement.clientHeight,
- modes: {
- default: [
- 'drag-canvas',
- 'zoom-canvas',
- 'drag-node',
- ],
- edit: ['click-select']
- },
- layout: {
- type: 'dagre',
- direction: 'LR',
- },
- defaultNode: {
- shape: 'node',
- type: 'rect',
- labelCfg: {
- style: {
- fill: '#000000A6',
- fontSize: 14,
- },
- },
- style: {
- // 浠呭湪 keyShape 涓婄敓鏁�
- fill: 'lightblue',
- stroke: '#888',
- lineWidth: 1,
- radius: 7,
- },
- linkPoints: {
- top: true,
- bottom: true,
- left: true,
- right: true,
- // ... 鍥涗釜鍦嗙殑鏍峰紡鍙互鍦ㄨ繖閲屾寚瀹�
- },
- },
- defaultEdge: {
- shape: 'polyline',
- },
- nodeStateStyles: {
- // 鍚勭姸鎬佷笅鐨勬牱寮忥紝骞抽摵鐨勯厤缃」浠呭湪 keyShape 涓婄敓鏁堛�傞渶瑕佸湪鍏朵粬 shape 鏍峰紡涓婂搷搴旂姸鎬佸彉鍖栧垯鍐欐硶涓嶅悓锛屽弬瑙佷笂鏂囨彁鍒扮殑 閰嶇疆鐘舵�佹牱寮� 閾炬帴
- hover: {
- fillOpacity: 0.1,
- lineWidth: 1,
- },
- },
- });
+ const initHandle = () => {
+ setReady(true);
}
- graph.data(data);
- graph.render();
-
- // 鐩戝惉榧犳爣杩涘叆鑺傜偣浜嬩欢
- graph.on('node:mouseenter', (evt) => {
- const node = evt.item;
- // 婵�娲昏鑺傜偣鐨� hover 鐘舵��
- graph.setItemState(node, 'hover', true);
- });
- // 鐩戝惉榧犳爣绂诲紑鑺傜偣浜嬩欢
- graph.on('node:mouseleave', (evt) => {
- const node = evt.item;
- // 鍏抽棴璇ヨ妭鐐圭殑 hover 鐘舵��
- graph.setItemState(node, 'hover', false);
- });
+ useEffect(() => {
+ if (ready) {
+ // 浣犻渶瑕佸湪loading鐘舵�佹敼鍙樺悗鎵ц鐨勪唬鐮�
+ console.log('graphRef is ready:', graphRef.current);
+ }
+ }, [ready]);
- graph.on('node:click', (evt) => {
- const node = evt.item;
- const model = node.getModel();
- // 鍦ㄨ繖閲屾墦寮�妯℃�佹鎴栬�呯紪杈戣〃鏍硷紝浼犲叆model浠ヤ究鐢ㄤ簬鍒濆鍖栫紪杈戝唴瀹�
- showModal(model);
- });
- }, []);
-
- return <div ref={ref}></div>;
+ return (
+ <div className="stencil-app">
+ <GraphTools isReady={ready} graphRef={graphRef} />
+ <GraphComponent ref={graphRef} initHandle={initHandle} />
+ <RightMenu isReady={ready} graphRef={graphRef} />
+ <GraphDrawer isReady={ready} graphRef={graphRef} />
+ </div>
+ );
}
\ No newline at end of file
--
Gitblit v1.9.1