From c7aa9cc76f90cf4c7510c59e1eff90f762cf400d Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期四, 29 二月 2024 16:25:39 +0800
Subject: [PATCH] #
---
zy-asrs-flow/src/pages/home/index.jsx | 100 +++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 90 insertions(+), 10 deletions(-)
diff --git a/zy-asrs-flow/src/pages/home/index.jsx b/zy-asrs-flow/src/pages/home/index.jsx
index d517241..92634cc 100644
--- a/zy-asrs-flow/src/pages/home/index.jsx
+++ b/zy-asrs-flow/src/pages/home/index.jsx
@@ -1,11 +1,91 @@
-import ProSkeleton from '@ant-design/pro-skeleton';
+import React, { useEffect, useState } from 'react';
+import ReactDOM from 'react-dom';
+import { data } from './data';
+import G6 from '@antv/g6';
+import "./index.css"
-export default () => (
- <div
- style={{
- padding: 24,
- }}
- >
- <ProSkeleton type="list" />
- </div>
-);
\ No newline at end of file
+export default function() {
+ const ref = React.useRef(null);
+ let graph = null;
+
+ 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,
+ },
+ },
+ });
+ }
+ 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);
+ });
+
+ graph.on('node:click', (evt) => {
+ const node = evt.item;
+ const model = node.getModel();
+ // 鍦ㄨ繖閲屾墦寮�妯℃�佹鎴栬�呯紪杈戣〃鏍硷紝浼犲叆model浠ヤ究鐢ㄤ簬鍒濆鍖栫紪杈戝唴瀹�
+ showModal(model);
+ });
+ }, []);
+
+ return <div ref={ref}></div>;
+}
\ No newline at end of file
--
Gitblit v1.9.1