Skip to content

Commit bfcdcbe

Browse files
committed
fixed: meeting
1 parent f57171f commit bfcdcbe

File tree

4 files changed

+97
-5
lines changed

4 files changed

+97
-5
lines changed

src/api/meeting/meeting.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Send from "@/api/send.ts";
2+
3+
export const getUser = (data: any) => {
4+
return Send({
5+
method: "get",
6+
url: "conference/modify_inviting",
7+
data: data,
8+
});
9+
};

src/sass/base/_reset.sass

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,6 @@ select
6767
height: 0
6868
line-height: 0
6969
text-indent: -9999px
70+
71+
.react-flow__panel
72+
display: none

src/views/meeting/components/MindMapComponent.tsx

Lines changed: 83 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
import { ReactFlow } from "@xyflow/react";
1+
import React, { useCallback } from 'react';
2+
import {
3+
ReactFlow,
4+
Background,
5+
useNodesState,
6+
useEdgesState,
7+
addEdge,
8+
getIncomers,
9+
getOutgoers,
10+
getConnectedEdges,
11+
} from '@xyflow/react';
212

313
// style
414
import "@xyflow/react/dist/style.css";
@@ -58,11 +68,69 @@ const MindMapComponent = ({ setScripts }: MindMapComponentProps) => {
5868
const [mode, setMode] = useState<string>("none");
5969

6070
const initialNodes = [
61-
{ id: "1", position: { x: 0, y: 0 }, data: { label: "2" } },
62-
{ id: "2", position: { x: 0, y: 100 }, data: { label: "2" } },
71+
{
72+
id: '1',
73+
type: 'input',
74+
data: { label: 'Start here...' },
75+
position: { x: -150, y: 0 },
76+
},
77+
{
78+
id: '2',
79+
type: 'input',
80+
data: { label: '...or here!' },
81+
position: { x: 150, y: 0 },
82+
},
83+
{ id: '3', data: { label: 'Delete me.' }, position: { x: 0, y: 100 } },
84+
{ id: '4', data: { label: 'Then me!' }, position: { x: 0, y: 200 } },
85+
{
86+
id: '5',
87+
type: 'output',
88+
data: { label: 'End here!' },
89+
position: { x: 0, y: 300 },
90+
},
6391
];
6492

65-
const initialEdges = [{ id: "e1-2", source: "1", target: "2" }];
93+
const initialEdges = [
94+
{ id: '1->3', source: '1', target: '3' },
95+
{ id: '2->3', source: '2', target: '3' },
96+
{ id: '3->4', source: '3', target: '4' },
97+
{ id: '4->5', source: '4', target: '5' },
98+
];
99+
100+
const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes);
101+
const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges);
102+
103+
const onConnect = useCallback(
104+
(params: any) => setEdges(addEdge(params, edges)),
105+
[edges],
106+
);
107+
108+
const onNodesDelete = useCallback(
109+
(deleted: any[]) => {
110+
setEdges(
111+
deleted.reduce((acc, node) => {
112+
const incomers = getIncomers(node, nodes, edges);
113+
const outgoers = getOutgoers(node, nodes, edges);
114+
const connectedEdges = getConnectedEdges([node], edges);
115+
116+
const remainingEdges = acc.filter(
117+
(edge: { id: string; source: string; target: string; }) => !connectedEdges.includes(edge),
118+
);
119+
120+
const createdEdges = incomers.flatMap(({ id: source }) =>
121+
outgoers.map(({ id: target }) => ({
122+
id: `${source}->${target}`,
123+
source,
124+
target,
125+
})),
126+
);
127+
128+
return [...remainingEdges, ...createdEdges];
129+
}, edges),
130+
);
131+
},
132+
[nodes, edges],
133+
);
66134

67135
return (
68136
<div className="mind-map-container">
@@ -83,7 +151,17 @@ const MindMapComponent = ({ setScripts }: MindMapComponentProps) => {
83151
) : (
84152
<div className="mind-map-main">
85153
<div className="mind-map-wrap">
86-
<ReactFlow nodes={initialNodes} edges={initialEdges} />
154+
<ReactFlow
155+
nodes={nodes}
156+
edges={edges}
157+
onNodesChange={onNodesChange}
158+
onNodesDelete={onNodesDelete}
159+
onEdgesChange={onEdgesChange}
160+
onConnect={onConnect}
161+
fitView
162+
attributionPosition="top-right"
163+
>
164+
</ReactFlow>
87165
</div>
88166
<div className="middle-bar">
89167
<div className="record-length-wrap">

src/views/meeting/style/mind-map.sass

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
.mind-map-main
4141
.mind-map-wrap
4242
+size(100vw, 100vh)
43+
max-width: 100%
44+
max-height: 100%
4345

4446
.middle-bar
4547
+size(435px, 64px)

0 commit comments

Comments
 (0)