Skip to content

Commit 25fa49b

Browse files
committed
fixed: meeting
1 parent 9387610 commit 25fa49b

File tree

6 files changed

+211
-476
lines changed

6 files changed

+211
-476
lines changed

package-lock.json

Lines changed: 50 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"@stomp/stompjs": "^7.1.1",
1414
"@xyflow/react": "^12.6.3",
1515
"axios": "^1.8.4",
16+
"html2canvas": "^1.4.1",
1617
"react": "^18.3.1",
1718
"react-dom": "^18.3.1",
1819
"react-media-recorder": "^1.7.1",

src/api/meeting/meeting.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ export const getMeetingId = () => {
77
});
88
};
99

10+
export const postScript = (data: any) => {
11+
return Send({
12+
method: "post",
13+
url: "conference/script",
14+
data: data
15+
});
16+
};
17+
1018
export const getInviting = (projectId: string, data: any) => {
1119
return Send({
1220
method: "post",

src/views/meeting/components/MindMapComponent.tsx

Lines changed: 77 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ import {
77
getIncomers,
88
getOutgoers,
99
getConnectedEdges,
10+
Node
1011
} from "@xyflow/react";
1112

1213
// style
1314
import "@xyflow/react/dist/style.css";
1415
import "@/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
1921
import UseSpeechToText from "@/views/meeting/components/UseSpeechToText";
@@ -22,6 +24,7 @@ import useRecordingTimer from "@/views/meeting/components/RecodingTimer";
2224
// import
2325
import { useEffect, useState } from "react";
2426
import { Client } from "@stomp/stompjs";
27+
import html2canvas from 'html2canvas';
2528

2629
// type
2730
import { 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
녹음 시작하기

src/views/meeting/components/UseSpeechToText.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,17 @@ const UseSpeechToText = () => {
4343

4444
mediaRecorder.onstop = () => {
4545
const audioBlob = new Blob(audioChunks.current, { type: "audio/webm" });
46-
const url = URL.createObjectURL(audioBlob);
47-
setAudioUrl(url);
46+
47+
const formData = new FormData();
48+
formData.append("file", audioBlob, "recording.webm");
49+
50+
// await fetch("https://your-backend/upload", {
51+
// method: "POST",
52+
// body: formData,
53+
// });
54+
55+
// const url = URL.createObjectURL(audioBlob);
56+
// setAudioUrl(url);
4857
};
4958

5059
mediaRecorder.start();

0 commit comments

Comments
 (0)