@@ -7,13 +7,15 @@ import {
77 getIncomers ,
88 getOutgoers ,
99 getConnectedEdges ,
10+ Node
1011} from "@xyflow/react" ;
1112
1213// style
1314import "@xyflow/react/dist/style.css" ;
1415import "@/views/meeting/style/mind-map.sass" ;
1516
16- // import { getProfile } from "@/api/main/profile";
17+ // api
18+ import { postScript } from "@/api/meeting/meeting" ;
1719
1820// component
1921import UseSpeechToText from "@/views/meeting/components/UseSpeechToText" ;
@@ -22,6 +24,7 @@ import useRecordingTimer from "@/views/meeting/components/RecodingTimer";
2224// import
2325import { useEffect , useState } from "react" ;
2426import { Client } from "@stomp/stompjs" ;
27+ import html2canvas from 'html2canvas' ;
2528
2629// type
2730import { conferenceData } from "@/types/conferanceData" ;
@@ -52,10 +55,12 @@ const MindMapComponent = ({
5255 // audioUrl,
5356 } = UseSpeechToText ( ) ;
5457
55- console . log ( "컨퍼런스 데이터 :" , conferenceData ) ;
56-
5758 const { formattedTime } = useRecordingTimer ( isRecording , isPaused ) ;
5859
60+ const [ scriptList , setScriptList ] = useState <
61+ { time : string ; script : string } [ ]
62+ > ( [ ] ) ;
63+
5964 const [ mode , setMode ] = useState < string > ( "none" ) ;
6065
6166 const meetingStart = ( ) => {
@@ -103,49 +108,88 @@ const MindMapComponent = ({
103108 // })
104109 } ;
105110
111+ const handleDownload = ( title : string , ref : React . RefObject < HTMLDivElement > ) => ( ) => {
112+ if ( ! ref . current ) return ;
113+
114+ html2canvas ( ref . current ) . then ( ( canvas ) => {
115+ const link = document . createElement ( 'a' ) ;
116+ link . href = canvas . toDataURL ( 'image/png' ) ;
117+ link . download = title === '' ? '제목없음' : title ;
118+ document . body . appendChild ( link ) ;
119+ link . click ( ) ;
120+ } ) ;
121+ } ;
122+
106123 useEffect ( ( ) => {
107124 if ( finalTranscript !== "" ) {
108- // console.log("🎙️ 시간", formattedTime);
109- // console.log("🎙️ 인식된 텍스트:", finalTranscript);
110- setScripts ( ( prev ) => [
111- ...prev ,
112- {
113- time : formattedTime ,
114- script : finalTranscript ,
115- } ,
116- ] ) ;
125+ const newScript = {
126+ time : formattedTime ,
127+ script : finalTranscript ,
128+ } ;
129+
130+ setScripts ( ( prev ) => [ ...prev , newScript ] ) ;
131+ setScriptList ( ( prev ) => {
132+ const updated = [ ...prev , newScript ] ;
133+
134+ if ( updated . length >= 2 ) {
135+ const testString = updated . map ( ( item ) => item . script ) . join ( " " ) ;
136+
137+ let data = {
138+ "event" : "script" ,
139+ "projectId" : conferenceData . projectId ,
140+ "scription" : testString
141+ }
142+ postScript ( data ) . then ( ( res : any ) => {
143+ setScriptList ( [ ] ) ;
144+ setInitialNodes ( res . data . data . nodes )
145+ } ) ;
146+ }
147+
148+ return updated . length >= 7 ? [ ] : updated ;
149+ } ) ;
150+
151+ resetTranscript ( ) ;
117152 }
118-
119- // 여기서 백엔드한테 보내기
120- resetTranscript ( ) ;
121153 } , [ finalTranscript ] ) ;
122154
123155 const stopClick = ( ) => {
124156 toggleListening ( ) ;
125157 } ;
126158
127- const initialNodes = [
159+ const [ initialNodes , setInitialNodes ] = useState < Node [ ] > ( [
128160 {
129- id : "1" ,
130- type : " input" ,
131- data : { label : "Start here..." } ,
161+ id : '1' ,
162+ type : ' input' ,
163+ data : { label : '회의 시작' } ,
132164 position : { x : - 150 , y : 0 } ,
133165 } ,
134166 {
135- id : "2" ,
136- type : "input" ,
137- data : { label : "...or here!" } ,
167+ id : '2' ,
168+ type : 'output' ,
169+ data : { label : '키워드' } ,
138170 position : { x : 150 , y : 0 } ,
139171 } ,
140- { id : "3" , data : { label : "Delete me." } , position : { x : 0 , y : 100 } } ,
141- { id : "4" , data : { label : "Then me!" } , position : { x : 0 , y : 200 } } ,
142- {
143- id : "5" ,
144- type : "output" ,
145- data : { label : "End here!" } ,
146- position : { x : 0 , y : 300 } ,
147- } ,
148- ] ;
172+ // {
173+ // id: '1',
174+ // type: 'input',
175+ // data: { label: 'Start here...' },
176+ // position: { x: -150, y: 0 },
177+ // },
178+ // {
179+ // id: '2',
180+ // type: 'input',
181+ // data: { label: '...or here!' },
182+ // position: { x: 150, y: 0 },
183+ // },
184+ // { id: '3', data: { label: 'Delete me.' }, position: { x: 0, y: 100 } },
185+ // { id: '4', data: { label: 'Then me!' }, position: { x: 0, y: 200 } },
186+ // {
187+ // id: '5',
188+ // type: 'output',
189+ // data: { label: 'End here!' },
190+ // position: { x: 0, y: 300 },
191+ // },
192+ ] ) ;
149193
150194 const initialEdges = [
151195 { id : "1->3" , source : "1" , target : "3" } ,
@@ -159,7 +203,7 @@ const MindMapComponent = ({
159203
160204 useEffect ( ( ) => {
161205 setNodes ( initialNodes ) ;
162- } , [ ] ) ; // 임시방편으로 만듦
206+ } , [ initialNodes ] ) ; // 임시방편으로 만듦
163207
164208 const onConnect = useCallback (
165209 ( params : any ) => setEdges ( addEdge ( params , edges ) ) ,
@@ -208,8 +252,7 @@ const MindMapComponent = ({
208252 onClick = { ( ) => (
209253 toggleListening ( ) . then ( ( ) => {
210254 setMode ( "meeting" ) ;
211- } ) ,
212- meetingStart ( )
255+ } )
213256 ) }
214257 >
215258 녹음 시작하기
0 commit comments