--- client/views/pages/main/AIDashboard.vue
+++ client/views/pages/main/AIDashboard.vue
... | ... | @@ -220,8 +220,7 @@ |
220 | 220 |
showModal: false, |
221 | 221 |
searchOpen: false, // 사진 상세보기 모달창 |
222 | 222 |
searchOpen2: false, // 단원 마친 후, 사진 촬영 여부 선택 모달창 |
223 |
- showCameraModal: false, // 카메라 모달창 |
|
224 |
- showPhotoModal: false, // 사진꾸미기 모달창 |
|
223 |
+ showCameraModal: false, // 카메라 모달창 |
|
225 | 224 |
photoTaken: false, |
226 | 225 |
photo: null, //캡쳐 사진 |
227 | 226 |
stream: null, |
... | ... | @@ -229,7 +228,6 @@ |
229 | 228 |
isHidden: false, |
230 | 229 |
images: [], |
231 | 230 |
|
232 |
- photoTaken: false |
|
233 | 231 |
|
234 | 232 |
} |
235 | 233 |
}, |
... | ... | @@ -330,7 +328,6 @@ |
330 | 328 |
this.showCameraModal = false; |
331 | 329 |
this.photoTaken = false; |
332 | 330 |
this.photo = null; |
333 |
- this.showPhotoModal = false; |
|
334 | 331 |
|
335 | 332 |
//스트림 종료 |
336 | 333 |
if (this.stream) { |
--- client/views/pages/main/Dashboard.vue
+++ client/views/pages/main/Dashboard.vue
... | ... | @@ -132,31 +132,14 @@ |
132 | 132 |
</div> |
133 | 133 |
</div> |
134 | 134 |
<div class="race-btn"> |
135 |
- <div class="rabbit-running" style=" |
|
136 |
- display: flex; |
|
137 |
-"><img class="rabbit-end" src="../../../resources/img/img138_72s.png" alt="" |
|
135 |
+ <div class="rabbit-running" style=" display: flex;"><img class="rabbit-end" |
|
136 |
+ src="../../../resources/img/img138_72s.png" alt="" |
|
138 | 137 |
:style="{ display: rabbitEnd ? 'block' : 'none' }"> |
139 | 138 |
<img class="fireworks-end" src="../../../resources/img/fireworks.gif" alt="" |
140 | 139 |
:style="{ display: rabbitEnd ? 'block' : 'none' }"> |
141 | 140 |
</div> |
142 | 141 |
</div> |
143 |
- |
|
144 |
- <button class="login-btn mt50" type="submit" style="width: 100%;" @click="finishSchedule"><img |
|
145 |
- src="../../../resources/img/btn07_s.png" alt="" style="width: 100%; height: 100px;"> |
|
146 |
- <p>학습 종료하기</p> |
|
147 |
- </button> |
|
148 | 142 |
<div class="complete-wrap smt50 myphoto"> |
149 |
- <h2 class="mb40">이 단원을 끝낸 친구들</h2> |
|
150 |
- <article class=" flex-column" style="gap: 5px;"> |
|
151 |
- <div class="flex" style="gap: 5px;"> |
|
152 |
- <div @click="buttonSearch2" class="photo"><img src="../../../resources/img/img143_75s.png" |
|
153 |
- alt=""> |
|
154 |
- </div> |
|
155 |
- <div @click="buttonSearch" class="photo"><img src="../../../resources/img/img143_75s.png" |
|
156 |
- alt=""> |
|
157 |
- </div> |
|
158 |
- </div> |
|
159 |
- </article> |
|
160 | 143 |
<!-- 팝업 --> |
161 | 144 |
<article class="popup-wrap" v-show="searchOpen"> |
162 | 145 |
<div class="popup-box "> |
... | ... | @@ -203,110 +186,56 @@ |
203 | 186 |
<div style="width: 100%;"> |
204 | 187 |
<div id="container" ref="container"> |
205 | 188 |
<video v-if="!photoTaken" autoplay="true" ref="modalVideoElement" class="mirrored" |
206 |
- @canplay="onVideoLoaded"></video> |
|
189 |
+ @canplay="onVideoLoaded" style="position: absolute;"> |
|
190 |
+ </video> |
|
191 |
+ <img src="../../../resources/img/camera-rabbit.png" class="camera-rabbit" |
|
192 |
+ style="position: absolute; "> |
|
193 |
+ <canvas ref="canvas" style="pointer-events: none;"></canvas> |
|
207 | 194 |
</div> |
208 | 195 |
</div> |
209 | 196 |
</div> |
210 | 197 |
<div class="flex justify-center mt20"> |
211 |
- <button type="button" class="new-btn" v-if="!photoTaken" @click="capturePhoto" |
|
212 |
- :disabled="!videoReady"> |
|
213 |
- 사진 촬영 |
|
214 |
- </button> |
|
198 |
+ <button class="new-btn" @click="takePhoto">사진 찍기</button> |
|
215 | 199 |
</div> |
216 | 200 |
</div> |
217 | 201 |
</article> |
202 |
+ </div> |
|
218 | 203 |
|
219 |
- <!-- 사진 모달 --> |
|
220 |
- <article v-show="showPhotoModal" class="popup-wrap"> |
|
221 |
- <div class="popup-box" style="top: 500px; left: auto"> |
|
222 |
- <div class="flex mb10 justify-between"> |
|
223 |
- <p class="popup-title">사진 꾸미기</p> |
|
224 |
- <button type="button" class="popup-close-btn" @click="closePhotoModal"> |
|
204 |
+ |
|
205 |
+ |
|
206 |
+ <div class="complete-wrap myphoto"> |
|
207 |
+ <button class="login-btn mt10" type="submit" style="width: 100%;" @click="finishSchedule"><img |
|
208 |
+ src="../../../resources/img/btn07_s.png" alt="" style="width: 100%; height: 100px;"> |
|
209 |
+ <p>학습 종료하기</p> |
|
210 |
+ </button> |
|
211 |
+ <h2 class="mb40 mt10">이 단원을 끝낸 친구들</h2> |
|
212 |
+ <article class="flex-column" style="gap: 5px;"> |
|
213 |
+ <div class="flex" style="gap: 5px; flex-wrap: wrap;"> |
|
214 |
+ <div v-for="(image, index) in images" :key="image.fileId" @click="buttonSearch(image)" |
|
215 |
+ class="photo"> |
|
216 |
+ <img :src="image.url" :alt="image.fileNm" reloadable="true" /> |
|
217 |
+ </div> |
|
218 |
+ </div> |
|
219 |
+ </article> |
|
220 |
+ <article class="popup-wrap" v-show="searchOpen"> |
|
221 |
+ <div class="popup-box "> |
|
222 |
+ <div class="flex mb10 justify-between"> |
|
223 |
+ <p class="popup-title">알림</p> |
|
224 |
+ <button type="button" class="popup-close-btn" @click="closeModal"> |
|
225 | 225 |
<svg-icon type="mdi" :path="mdiWindowClose" class="close-btn"></svg-icon> |
226 | 226 |
</button> |
227 | 227 |
</div> |
228 |
- <div class="flex justify-between align-center" style="gap: 40px;"> |
|
229 |
- <div class="content" style="padding: 30px; min-width: 401px; min-height: 710px;"> |
|
230 |
- <div class="tool"> |
|
231 |
- <div class="flex justify-center mb20" style="gap: 20px;"> |
|
232 |
- <button class="popTxt" style="width: 101px;" v-for="(item, index) in items_photo" |
|
233 |
- :key="index" @click="updateContent(index)" |
|
234 |
- :class="{ active: selectedIndex === index }"> |
|
235 |
- <img :src="item.imgSrc1" style="display: block;"> |
|
236 |
- <img :src="item.imgSrc2" v-if="selectedIndex === index" style="display: block;"> |
|
237 |
- </button> |
|
238 |
- </div> |
|
239 |
- </div> |
|
240 |
- |
|
241 |
- <div class="stickers" v-show="!stickersVisible"> |
|
242 |
- <div class="toolbar"> |
|
243 |
- <label for="brushSize" style="font-size: 9px;">펜 굵기</label> |
|
244 |
- <input type="color" v-model="color" /> |
|
245 |
- <input type="range" id="brushSize" min="1" max="10" v-model="brushSize" |
|
246 |
- @input="updateBrushSize" style="width: 100px; margin-left: 5px;" /> |
|
247 |
- <button class="new-btn" style="font-size: 9px;" @click="setTool('draw')">펜</button> |
|
248 |
- <button class="new-btn" style="font-size: 9px;" |
|
249 |
- @click="setTool('eraser')">지우개</button> |
|
250 |
- <button class="new-btn" style="font-size: 9px;" @click="clearAll">전체 |
|
251 |
- 지우개</button> |
|
252 |
- </div> |
|
253 |
- </div> |
|
254 |
- |
|
255 |
- <div class="stickers" v-show="stickersVisible"> |
|
256 |
- <button><img src="../../../resources/img/img146_75s.png" alt=""></button> |
|
257 |
- <button><img src="../../../resources/img/img147_75s.png" alt=""></button> |
|
258 |
- <button><img src="../../../resources/img/img148_75s.png" alt=""></button> |
|
259 |
- <button><img src="../../../resources/img/img149_75s.png" alt=""></button> |
|
260 |
- <button><img src="../../../resources/img/img150_75s.png" alt=""></button> |
|
261 |
- <button><img src="../../../resources/img/img151_75s.png" alt=""></button> |
|
262 |
- <button><img src="../../../resources/img/img152_75s.png" alt=""></button> |
|
263 |
- <button><img src="../../../resources/img/img153_75s.png" alt=""></button> |
|
264 |
- <button><img src="../../../resources/img/img154_75s.png" alt=""></button> |
|
265 |
- <button><img src="../../../resources/img/img155_75s.png" alt=""></button> |
|
266 |
- <button><img src="../../../resources/img/img156_75s.png" alt=""></button> |
|
267 |
- <button><img src="../../../resources/img/img157_75s.png" alt=""></button> |
|
268 |
- <button><img src="../../../resources/img/img158_75s.png" alt=""></button> |
|
269 |
- </div> |
|
228 |
+ <div class="box"> |
|
229 |
+ <div style="width: 910px;"><img src="../../../resources/img/img140_747s.png" alt=""></div> |
|
230 |
+ </div> |
|
231 |
+ <div class="flex justify-between mt20"> |
|
232 |
+ <div class="text flex"> |
|
233 |
+ <p class="title2 date ml30">2024-08-06</p> |
|
234 |
+ <span class=" title1 ml30">1단원을 마친 <em class="yellow">가나다</em>친구</span> |
|
270 | 235 |
</div> |
271 |
- <div> |
|
272 |
- <div class="content" style="height: 549px; |
|
273 |
- position: relative; |
|
274 |
- width: 973px; |
|
275 |
- display: flex; |
|
276 |
- justify-content: center; |
|
277 |
- align-items: center;"> |
|
278 |
- <canvas ref="canvas" style="position: absolute;"></canvas> |
|
279 |
- </div> |
|
280 |
- <div class="btn-wrap flex justify-center mt40" style="gap: 40px;"> |
|
281 |
- <button class="login-btn" @click="openCameraModal"> |
|
282 |
- <img src="../../../resources/img/btn07_s.png" alt=""> |
|
283 |
- <p>재촬영</p> |
|
284 |
- </button> |
|
285 |
- |
|
286 |
- <button class="login-btn" type="submit" @click="goToPage('PhotoEdit')"> |
|
287 |
- <img src="../../../resources/img/btn07_s.png" alt=""> |
|
288 |
- <p>완성</p> |
|
289 |
- </button> |
|
290 |
- </div> |
|
291 |
- </div> |
|
292 |
- <div class="content" style="padding: 30px; min-width: 401px; min-height: 710px;"> |
|
293 |
- <div class="mb20"> |
|
294 |
- <p class="popup-title" style="font-size: 32px">랜덤 단어</p> |
|
295 |
- </div> |
|
296 |
- <div class="flex-column" style="gap: 10px;"> |
|
297 |
- <button class="login-btn"><img src="../../../resources/img/img141_75s.png" alt=""> |
|
298 |
- <p class="title">a</p> |
|
299 |
- </button> |
|
300 |
- <button class="login-btn"><img src="../../../resources/img/img152_75s_01.png" alt=""> |
|
301 |
- <p class="title">a</p> |
|
302 |
- </button> |
|
303 |
- <button class="login-btn"><img src="../../../resources/img/img144_75s.png" alt=""> |
|
304 |
- <p class="title" style="color: #fff;">a</p> |
|
305 |
- </button> |
|
306 |
- <button class="login-btn"><img src="../../../resources/img/img145_75s.png" alt=""> |
|
307 |
- <p class="title mt20" style="color: #fff;">a</p> |
|
308 |
- </button> |
|
309 |
- </div> |
|
236 |
+ <div class="title2 flex align-center" style="gap: 10px;"><svg-icon type="mdi" :path="mdiHeart" |
|
237 |
+ style="color: #FFBA08;"></svg-icon> |
|
238 |
+ <p><em class="yellow">1</em></p> |
|
310 | 239 |
</div> |
311 | 240 |
</div> |
312 | 241 |
</div> |
... | ... | @@ -332,53 +261,21 @@ |
332 | 261 |
isSecondImageVisible: false |
333 | 262 |
}, |
334 | 263 |
], |
335 |
- items_photo: [ |
|
336 |
- { |
|
337 |
- imgSrc1: 'client/resources/img/btn20_75s_normal.png', //펜 선택되지 않음 |
|
338 |
- imgSrc2: 'client/resources/img/btn20_75s_click.png' //펜 선택됨 |
|
339 |
- }, |
|
340 |
- { |
|
341 |
- imgSrc1: 'client/resources/img/btn21_75s_normal.png', //스티커 선택되지 않음 |
|
342 |
- imgSrc2: 'client/resources/img/btn21_75s_click.png' //스티커 선택됨 |
|
343 |
- }, |
|
344 |
- ], |
|
345 | 264 |
mdiMagnify: mdiMagnify, |
346 | 265 |
mdiWindowClose: mdiWindowClose, |
347 | 266 |
mdiHeart: mdiHeart, |
348 | 267 |
showModal: false, |
349 | 268 |
searchOpen: false, // 사진 상세보기 모달창 |
350 | 269 |
searchOpen2: false, // 단원 마친 후, 사진 촬영 여부 선택 모달창 |
351 |
- showCameraModal: false, // 카메라 모달창 |
|
352 |
- showPhotoModal: false, // 사진꾸미기 모달창 |
|
270 |
+ showCameraModal: false, // 카메라 모달창 |
|
353 | 271 |
photoTaken: false, |
354 |
- photo: null, //캡쳐 사진 |
|
355 |
- videoReady: false, // 비디오 준비 상태를 나타내는 플래그 |
|
272 |
+ photo: null, //캡쳐 사진 |
|
356 | 273 |
stream: null, |
357 |
- canvasWidth: 0, |
|
358 |
- canvasHeight: 0, |
|
359 |
- selectedIndex: 0, //툴 선택 여부 인덱스 |
|
360 |
- stickersVisible: false, // 스티커 표시 여부 |
|
361 | 274 |
|
362 |
- //사진 꾸미기 관련 변수 |
|
363 |
- drawHistory: [], //도형 기록 |
|
364 |
- tempLines: [], //펜 기록 |
|
365 |
- stickers: [], //스티커 파일 기록 |
|
366 |
- draggingStickerIndex: null, //스티커 드래그 |
|
367 |
- activeStickerIndex: null, // 현재 활성화된 스티커의 인덱스 |
|
368 |
- nextLineId: 0, //획 아이디 |
|
369 |
- tool: 'draw', //툴 결정 |
|
370 |
- color: '#000000', //펜 기본 색상 |
|
371 |
- isDrawing: false, //그리는 중인지 판단하는 변수 |
|
372 |
- brushSize: 5, // 초기 펜 굵기 |
|
373 |
- startX: 0, |
|
374 |
- startY: 0, |
|
375 |
- canvasRect: { |
|
376 |
- topLeft: { x: 0, y: 0 }, |
|
377 |
- bottomRight: { x: 0, y: 0 } |
|
378 |
- }, |
|
275 |
+ |
|
379 | 276 |
roadmapData: [], |
380 | 277 |
labeledItems: [], |
381 |
- |
|
278 |
+ |
|
382 | 279 |
problemCounter: 0, |
383 | 280 |
wordCounter: 0, |
384 | 281 |
textCounter: 0, |
... | ... | @@ -392,10 +289,78 @@ |
392 | 289 |
rabbitPos: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], |
393 | 290 |
rabbitCompl: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], |
394 | 291 |
rabbitEnd: false, |
292 |
+ |
|
293 |
+ images: [], |
|
294 |
+ unit_id: "", |
|
295 |
+ book_id: "", |
|
395 | 296 |
} |
396 | 297 |
}, |
397 | 298 |
methods: { |
398 | 299 |
//은진 |
300 |
+ async findFile(file_mng_id) { |
|
301 |
+ try { |
|
302 |
+ const res = await axios({ |
|
303 |
+ url: "/file/find.json", |
|
304 |
+ method: "post", |
|
305 |
+ headers: { |
|
306 |
+ "Content-Type": "application/json; charset=UTF-8", |
|
307 |
+ }, |
|
308 |
+ data: { |
|
309 |
+ file_mng_id: file_mng_id, |
|
310 |
+ }, |
|
311 |
+ }); |
|
312 |
+ return res.data.list[0]; |
|
313 |
+ } catch (error) { |
|
314 |
+ console.log("result - error : ", error); |
|
315 |
+ return null; |
|
316 |
+ } |
|
317 |
+ }, |
|
318 |
+ fetchImage() { |
|
319 |
+ axios({ |
|
320 |
+ url: "/photo/photoUnitList.json", |
|
321 |
+ method: "post", |
|
322 |
+ headers: { |
|
323 |
+ "Content-Type": "application/json; charset=UTF-8", |
|
324 |
+ }, |
|
325 |
+ data: { |
|
326 |
+ unitId: "UNIT_000000000000001", |
|
327 |
+ sclsId: "1" |
|
328 |
+ } |
|
329 |
+ }) |
|
330 |
+ .then(response => { |
|
331 |
+ this.file_mng_id = response.data; |
|
332 |
+ |
|
333 |
+ const findFilePromises = this.file_mng_id.map(id => |
|
334 |
+ this.findFile(id.file_mng_id) |
|
335 |
+ ); |
|
336 |
+ |
|
337 |
+ return Promise.all(findFilePromises); |
|
338 |
+ }) |
|
339 |
+ .then(fileResults => { |
|
340 |
+ // Format file results to include image URL |
|
341 |
+ this.images = fileResults.map(file => { |
|
342 |
+ if (file) { |
|
343 |
+ return { |
|
344 |
+ url: "http://localhost:9080/" + `${file.fileRpath}`, |
|
345 |
+ fileId: file.fileId, |
|
346 |
+ fileNm: file.fileNm, |
|
347 |
+ // Add any other properties you need here |
|
348 |
+ }; |
|
349 |
+ } |
|
350 |
+ return null; |
|
351 |
+ }).filter(image => image !== null); |
|
352 |
+ }) |
|
353 |
+ .catch(error => { |
|
354 |
+ console.error("Error fetching images:", error); |
|
355 |
+ }); |
|
356 |
+ }, |
|
357 |
+ goToPageImg(page) { |
|
358 |
+ const canvas = document.querySelector('canvas'); |
|
359 |
+ const dataURL = canvas.toDataURL('image/png'); |
|
360 |
+ |
|
361 |
+ this.$router.push({ name: page, query: { image: encodeURIComponent(dataURL) } }); |
|
362 |
+ }, |
|
363 |
+ |
|
399 | 364 |
fetchRabbit() { |
400 | 365 |
for (var i = 0; i < 12; i++) { |
401 | 366 |
this.rabbitPos[i] = false |
... | ... | @@ -467,7 +432,7 @@ |
467 | 432 |
finish: "T" |
468 | 433 |
} |
469 | 434 |
}) |
470 |
- .then(response => { |
|
435 |
+ .then(response => { |
|
471 | 436 |
const nextSchedule = this.schedules.find(schedule => schedule.schdl_id > this.nowSchedule.schdl_id); |
472 | 437 |
alert("학습을 완료했습니다!"); |
473 | 438 |
window.location.reload(); |
... | ... | @@ -494,40 +459,24 @@ |
494 | 459 |
book_id: book_id |
495 | 460 |
} |
496 | 461 |
}) |
497 |
- .then(response => { |
|
498 |
- if (response.data.length != 0) { |
|
462 |
+ .then(response => { |
|
463 |
+ if (response.data.length != 0) { |
|
499 | 464 |
this.roadmapData = response.data; |
500 | 465 |
this.labeledItems = this.processedRoadmap; |
501 |
- } else { |
|
466 |
+ } else { |
|
502 | 467 |
this.state = "noProblem" |
503 |
- } |
|
504 |
- }) |
|
505 |
- .catch(error => { |
|
468 |
+ } |
|
469 |
+ }) |
|
470 |
+ .catch(error => { |
|
506 | 471 |
this.state = "noProblem" |
507 | 472 |
console.error("Error fetching roadmap data:", error); |
508 |
- }); |
|
473 |
+ }); |
|
509 | 474 |
}, |
510 | 475 |
toggleImage(index) { |
511 | 476 |
this.items[index].isSecondImageVisible = !this.items[index].isSecondImageVisible; |
512 | 477 |
}, |
513 |
- toggleImageAndShowPopup(index, dataNum) { |
|
514 |
- this.toggleImage(index); |
|
515 |
- if (dataNum === '11') { |
|
516 |
- this.searchOpen2 = true; |
|
517 |
- } |
|
518 |
- }, |
|
519 | 478 |
ShowPopup() { |
520 | 479 |
this.searchOpen2 = true; // 촬영 여부 묻는 모달창 열기 |
521 |
- }, |
|
522 |
- updateContent(index) { |
|
523 |
- this.selectedIndex = index; |
|
524 |
- |
|
525 |
- // 선택된 버튼이 스티커 버튼(인덱스 1)인지 확인 |
|
526 |
- if (index === 1) { |
|
527 |
- this.stickersVisible = true; // 스티커 툴 보이기 |
|
528 |
- } else { |
|
529 |
- this.stickersVisible = false; // 스티커 툴 숨기기 |
|
530 |
- } |
|
531 | 480 |
}, |
532 | 481 |
goToPage(page) { |
533 | 482 |
const { unit_id, book_id } = this.$route.query; |
... | ... | @@ -535,12 +484,6 @@ |
535 | 484 |
}, |
536 | 485 |
openCameraModal() { |
537 | 486 |
this.closeModal(); |
538 |
- this.closePhotoModal(); |
|
539 |
- |
|
540 |
- this.drawHistory = []; |
|
541 |
- this.stickers = []; |
|
542 |
- this.tempLines = []; |
|
543 |
- this.videoReady = false; // 비디오 준비 상태 초기화 |
|
544 | 487 |
|
545 | 488 |
this.showCameraModal = true; |
546 | 489 |
navigator.mediaDevices.getUserMedia({ video: true }) |
... | ... | @@ -548,7 +491,6 @@ |
548 | 491 |
const modalVideo = this.$refs.modalVideoElement; |
549 | 492 |
modalVideo.srcObject = stream; |
550 | 493 |
this.stream = stream; |
551 |
- modalVideo.addEventListener('loadedmetadata', this.adjustContainerSize); |
|
552 | 494 |
}) |
553 | 495 |
.catch(error => { |
554 | 496 |
console.log("error>>>>>>>>", error); |
... | ... | @@ -561,7 +503,6 @@ |
561 | 503 |
this.showCameraModal = false; |
562 | 504 |
this.photoTaken = false; |
563 | 505 |
this.photo = null; |
564 |
- this.showPhotoModal = false; |
|
565 | 506 |
|
566 | 507 |
//스트림 종료 |
567 | 508 |
if (this.stream) { |
... | ... | @@ -570,24 +511,46 @@ |
570 | 511 |
this.stream = null; |
571 | 512 |
} |
572 | 513 |
}, |
573 |
- closePhotoModal() { //사진꾸미기 팝업 닫기 |
|
574 |
- this.showPhotoModal = false; |
|
575 |
- this.closeModal(); |
|
576 |
- }, |
|
514 |
+ |
|
577 | 515 |
onVideoLoaded() { |
578 |
- this.videoReady = true; |
|
579 |
- this.adjustContainerSize(); |
|
580 |
- }, |
|
581 |
- adjustContainerSize() { |
|
582 | 516 |
const video = this.$refs.modalVideoElement; |
583 |
- const container = this.$refs.container; |
|
584 |
- const body = this.$refs.body; |
|
585 |
- if (video && container) { |
|
586 |
- container.style.width = `${video.videoWidth}px`; |
|
587 |
- container.style.height = `${video.videoHeight}px`; |
|
588 |
- body.style.height = `${video.videoHeight}px`; |
|
589 |
- } |
|
517 |
+ const canvas = this.$refs.canvas; |
|
518 |
+ const ctx = canvas.getContext('2d'); |
|
519 |
+ |
|
520 |
+ canvas.width = video.videoWidth; |
|
521 |
+ canvas.height = video.videoHeight; |
|
522 |
+ }, takePhoto() { |
|
523 |
+ const video = this.$refs.modalVideoElement; |
|
524 |
+ const canvas = this.$refs.canvas; |
|
525 |
+ const ctx = canvas.getContext('2d'); |
|
526 |
+ |
|
527 |
+ ctx.save(); // 현재 상태 저장 |
|
528 |
+ |
|
529 |
+ // 캔버스 좌우 반전 |
|
530 |
+ ctx.scale(-1, 1); |
|
531 |
+ ctx.drawImage(video, -canvas.width, 0, canvas.width, canvas.height); |
|
532 |
+ |
|
533 |
+ ctx.restore(); |
|
534 |
+ |
|
535 |
+ const overlayImg = new Image(); |
|
536 |
+ overlayImg.src = 'client/resources/img/camera-rabbit.png'; |
|
537 |
+ overlayImg.onload = () => { |
|
538 |
+ const overlayWidth = canvas.width * 0.4; |
|
539 |
+ const overlayHeight = (overlayImg.height / overlayImg.width) * overlayWidth; |
|
540 |
+ const overlayX = canvas.width - overlayWidth; |
|
541 |
+ const overlayY = canvas.height - overlayHeight; |
|
542 |
+ |
|
543 |
+ // 오버레이 이미지 그리기 |
|
544 |
+ ctx.drawImage(overlayImg, overlayX, overlayY, overlayWidth, overlayHeight); |
|
545 |
+ |
|
546 |
+ // 사진 저장 함수 호출 |
|
547 |
+ const dataURL = canvas.toDataURL('image/png'); |
|
548 |
+ this.$router.push({ name: 'PhotoEdit', query: { image: encodeURIComponent(dataURL), unit_id: this.unit_id, book_id: this.book_id } }); |
|
549 |
+ }; |
|
590 | 550 |
}, |
551 |
+ |
|
552 |
+ |
|
553 |
+ |
|
591 | 554 |
buttonSearch() { |
592 | 555 |
this.searchOpen = true; |
593 | 556 |
}, |
... | ... | @@ -597,320 +560,26 @@ |
597 | 560 |
closeBtn() { |
598 | 561 |
this.searchOpen = false; |
599 | 562 |
}, |
600 |
- capturePhoto() { |
|
601 |
- // 사진 촬영 기능 구현 |
|
602 |
- console.log("cam on"); |
|
603 |
- |
|
604 |
- if (!this.videoReady) return; // 비디오가 준비되지 않았으면 사진을 찍지 않음 |
|
605 |
- |
|
606 |
- const video = this.$refs.modalVideoElement; |
|
607 |
- const canvas = document.createElement('canvas'); |
|
608 |
- |
|
609 |
- canvas.width = video.videoWidth; |
|
610 |
- canvas.height = video.videoHeight; |
|
611 |
- this.canvasWidth = video.videoWidth; |
|
612 |
- this.canvasHeight = video.videoHeight; |
|
613 |
- const context = canvas.getContext('2d'); |
|
614 |
- context.translate(canvas.width, 0); |
|
615 |
- context.scale(-1, 1); |
|
616 |
- context.drawImage(video, 0, 0, canvas.width, canvas.height); |
|
617 |
- this.photo = canvas.toDataURL('image/png'); |
|
618 |
- this.photoTaken = true; |
|
619 |
- this.showPhotoModal = true; |
|
620 |
- console.log("PhotoModal open"); |
|
621 |
- this.$nextTick(() => { |
|
622 |
- console.log("canvas setup"); |
|
623 |
- // console.log("Photo data>>>>", this.photo); |
|
624 |
- this.setupCanvas(); |
|
625 |
- }); |
|
626 |
- |
|
627 |
- }, |
|
628 |
- setupCanvas() { |
|
629 |
- const canvas = this.$refs.canvas; |
|
630 |
- // const container = this.$refs.container; |
|
631 |
- if (!canvas) { |
|
632 |
- console.error("Canvas reference not found"); |
|
633 |
- resolve(); |
|
634 |
- return; |
|
635 |
- } |
|
636 |
- const context = canvas.getContext('2d'); |
|
637 |
- if (!context) { |
|
638 |
- console.error("Canvas context not found"); |
|
639 |
- return; |
|
640 |
- } |
|
641 |
- const image = new Image(); |
|
642 |
- image.src = this.photo; |
|
643 |
- // console.log("Photo data>>>>", image.src); |
|
644 |
- image.onload = () => { |
|
645 |
- console.log("Image loaded successfully"); |
|
646 |
- // this.canvasWidth = image.width; |
|
647 |
- // this.canvasHeight = image.height; |
|
648 |
- //이미지 크기가 캔버스와 안맞으면 이미지 불러오는데에 에러 남 |
|
649 |
- // container.style.width = this.canvasWidth; |
|
650 |
- // container.style.height = this.canvasHeight; |
|
651 |
- |
|
652 |
- canvas.width = this.canvasWidth; |
|
653 |
- canvas.height = this.canvasHeight; |
|
654 |
- |
|
655 |
- const rect = canvas.getBoundingClientRect(); |
|
656 |
- // 좌측 상단 좌표 |
|
657 |
- const topLeft = { |
|
658 |
- x: rect.left, |
|
659 |
- y: rect.top |
|
660 |
- }; |
|
661 |
- |
|
662 |
- // 우측 하단 좌표 |
|
663 |
- const bottomRight = { |
|
664 |
- x: rect.right, |
|
665 |
- y: rect.bottom |
|
666 |
- }; |
|
667 |
- |
|
668 |
- // 캔버스 크기 초기화 |
|
669 |
- this.updateCanvasRect(); |
|
670 |
- |
|
671 |
- // 윈도우 리사이즈 이벤트 리스너 추가 |
|
672 |
- window.addEventListener('resize', this.updateCanvasRect); |
|
673 |
- |
|
674 |
- // 클릭 이벤트 핸들러 추가 |
|
675 |
- this.$refs.canvas.addEventListener('click', this.handleCanvasClick); |
|
676 |
- |
|
677 |
- |
|
678 |
- // canvas.width = canvas.clientWidth; |
|
679 |
- // canvas.height = canvas.clientHeight; |
|
680 |
- // this.canvasWidth = canvas.clientWidth; |
|
681 |
- // this.canvasHeight = canvas.clientHeight; |
|
682 |
- |
|
683 |
- context.clearRect(0, 0, canvas.width, canvas.height); // 이전 이미지 있으면 초기화 |
|
684 |
- context.drawImage(image, 0, 0, this.canvasWidth, this.canvasHeight); |
|
685 |
- this.addCanvasEventListeners(); //추가해야함 |
|
686 |
- }; |
|
687 |
- image.onerror = (error) => { |
|
688 |
- console.error("Error loading image: ", error); |
|
689 |
- }; |
|
690 |
- }, |
|
691 |
- |
|
692 |
- addCanvasEventListeners() { |
|
693 |
- const canvas = this.$refs.canvas; |
|
694 |
- canvas.addEventListener('mousedown', this.onMouseDown); |
|
695 |
- canvas.addEventListener('mouseup', this.onMouseUp); |
|
696 |
- canvas.addEventListener('mousemove', this.onMouseMove); |
|
697 |
- canvas.addEventListener('click', this.onCanvasClick); |
|
698 |
- }, |
|
699 |
- setTool(tool) { |
|
700 |
- this.tool = tool; |
|
701 |
- }, |
|
702 |
- updateBrushSize() { |
|
703 |
- // 펜 굵기 변경 로직 |
|
704 |
- if (this.tool === 'draw') { |
|
705 |
- this.setBrushSize(this.brushSize); |
|
706 |
- } |
|
707 |
- }, |
|
708 |
- setBrushSize(size) { |
|
709 |
- this.brushSize = size; |
|
710 |
- const context = this.$refs.canvas.getContext('2d'); |
|
711 |
- context.lineWidth = size; |
|
712 |
- }, |
|
713 |
- // 캔버스 크기 갱신 함수 |
|
714 |
- updateCanvasRect() { |
|
715 |
- const rect = this.$refs.canvas.getBoundingClientRect(); |
|
716 |
- this.canvasRect = { |
|
717 |
- topLeft: { x: rect.left, y: rect.top }, |
|
718 |
- bottomRight: { x: rect.right, y: rect.bottom } |
|
719 |
- }; |
|
720 |
- console.log(">>>>>>>>>2222", rect.left); |
|
721 |
- }, |
|
722 |
- getCanvasPosition(event) { |
|
723 |
- |
|
724 |
- const rect = this.canvasRect; |
|
725 |
- console.log(">>>>>>>>>", this.canvasRect); |
|
726 |
- this.updateCanvasRect(); |
|
727 |
- |
|
728 |
- // 윈도우 리사이즈 이벤트 리스너 추가 |
|
729 |
- window.addEventListener('resize', this.updateCanvasRect); |
|
730 |
- |
|
731 |
- // 클릭 이벤트 핸들러 추가 |
|
732 |
- this.$refs.canvas.addEventListener('click', this.handleCanvasClick); |
|
733 |
- |
|
734 |
- // // 좌측 상단 좌표 |
|
735 |
- // const topLeft = { |
|
736 |
- // x: rect.left, |
|
737 |
- // y: rect.top |
|
738 |
- // }; |
|
739 |
- |
|
740 |
- // // 우측 하단 좌표 |
|
741 |
- // const bottomRight = { |
|
742 |
- // x: rect.right, |
|
743 |
- // y: rect.bottom |
|
744 |
- // }; |
|
745 |
- |
|
746 |
- // console.log(this.scrollLeft) |
|
747 |
- |
|
748 |
- const x = event.clientX - rect.topLeft.x |
|
749 |
- const y = event.clientY - rect.topLeft.y |
|
750 |
- |
|
751 |
- |
|
752 |
- console.log(`클릭한 좌표: x=${event.clientX}, y=${event.clientY}`); |
|
753 |
- console.log(`계산베이스 좌표: x=${rect.topLeft.x}, y=${rect.topLeft.y}`); |
|
754 |
- console.log(`계산베이스 좌표: x=${rect.topLeft.x}, y=${rect.topLeft.y}`); |
|
755 |
- console.log(`계산된 좌표: x=${x}, y=${y}`); |
|
756 |
- return { |
|
757 |
- x, y |
|
758 |
- }; |
|
759 |
- }, |
|
760 |
- onMouseDown(event) { |
|
761 |
- |
|
762 |
- // 캔버스 크기 초기화 |
|
763 |
- this.updateCanvasRect(); |
|
764 |
- |
|
765 |
- // 윈도우 리사이즈 이벤트 리스너 추가 |
|
766 |
- window.addEventListener('resize', this.updateCanvasRect); |
|
767 |
- |
|
768 |
- // 클릭 이벤트 핸들러 추가 |
|
769 |
- this.$refs.canvas.addEventListener('click', this.handleCanvasClick); |
|
770 |
- |
|
771 |
- const { x, y } = this.getCanvasPosition(event); |
|
772 |
- this.startX = x; |
|
773 |
- this.startY = y; |
|
774 |
- const context = this.$refs.canvas.getContext('2d'); |
|
775 |
- context.strokeStyle = this.color; |
|
776 |
- context.lineWidth = this.brushSize; // 브러시 크기 설정 |
|
777 |
- if (this.tool === 'draw') { |
|
778 |
- context.beginPath(); |
|
779 |
- context.moveTo(this.startX, this.startY); |
|
780 |
- this.nextLineId++; |
|
781 |
- } |
|
782 |
- this.isDrawing = true; |
|
783 |
- }, |
|
784 |
- onMouseUp(event) { |
|
785 |
- if (!this.isDrawing) return; |
|
786 |
- const { x, y } = this.getCanvasPosition(event); |
|
787 |
- const context = this.$refs.canvas.getContext('2d'); |
|
788 |
- context.strokeStyle = this.color; |
|
789 |
- context.lineWidth = this.brushSize; // 브러시 크기 설정 |
|
790 |
- if (this.tool === 'rectangle') { |
|
791 |
- context.strokeRect(this.startX, this.startY, x - this.startX, y - this.startY); |
|
792 |
- this.drawHistory.push({ type: 'rectangle', startX: this.startX, startY: this.startY, endX: x, endY: y, color: this.color }); |
|
793 |
- } else if (this.tool === 'circle') { |
|
794 |
- context.beginPath(); |
|
795 |
- const radius = Math.sqrt(Math.pow((x - this.startX), 2) + Math.pow((y - this.startY), 2)); |
|
796 |
- context.arc(this.startX, this.startY, radius, 0, 2 * Math.PI); |
|
797 |
- context.stroke(); |
|
798 |
- this.drawHistory.push({ type: 'circle', startX: this.startX, startY: this.startY, radius, color: this.color }); |
|
799 |
- } else if (this.tool === 'draw') { |
|
800 |
- context.lineTo(x, y); |
|
801 |
- context.stroke(); |
|
802 |
- this.tempLines.push({ id: this.nextLineId, startX: this.startX, startY: this.startY, endX: x, endY: y, color: this.color }); |
|
803 |
- } |
|
804 |
- this.isDrawing = false; |
|
805 |
- }, |
|
806 |
- onMouseMove(event) { |
|
807 |
- if (!this.isDrawing || this.tool !== 'draw') return; |
|
808 |
- const { x, y } = this.getCanvasPosition(event); |
|
809 |
- const context = this.$refs.canvas.getContext('2d'); |
|
810 |
- context.strokeStyle = this.color; |
|
811 |
- context.lineWidth = this.brushSize; // 브러시 크기 설정 |
|
812 |
- context.lineTo(x, y); |
|
813 |
- context.stroke(); |
|
814 |
- this.tempLines.push({ id: this.nextLineId, startX: this.startX, startY: this.startY, endX: x, endY: y, color: this.color }); |
|
815 |
- this.startX = x; |
|
816 |
- this.startY = y; |
|
817 |
- }, |
|
818 |
- onCanvasClick(event) { |
|
819 |
- if (this.tool === 'eraser') { |
|
820 |
- const { x, y } = this.getCanvasPosition(event); |
|
821 |
- this.eraseDrawing(x, y); |
|
822 |
- } |
|
823 |
- }, |
|
824 |
- eraseDrawing(x, y) { |
|
825 |
- const eraserRadius = 10; |
|
826 |
- this.drawHistory = this.drawHistory.filter(item => { |
|
827 |
- if (item.type === 'rectangle') { |
|
828 |
- return !(x >= item.startX && x <= item.endX && y >= item.startY && y <= item.endY); |
|
829 |
- } else if (item.type === 'circle') { |
|
830 |
- const distance = Math.sqrt(Math.pow((x - item.startX), 2) + Math.pow((y - item.startY), 2)); |
|
831 |
- return !(distance <= item.radius); |
|
832 |
- } |
|
833 |
- }); |
|
834 |
- const linesToDelete = this.tempLines.filter(line => { |
|
835 |
- const distanceToLine = this.distanceToLineSegment(line.startX, line.startY, line.endX, line.endY, x, y); |
|
836 |
- return distanceToLine <= 10; |
|
837 |
- }).map(line => line.id); |
|
838 |
- this.tempLines = this.tempLines.filter(line => !linesToDelete.includes(line.id)); |
|
839 |
- this.redraw(); |
|
840 |
- }, |
|
841 |
- distanceToLineSegment(x1, y1, x2, y2, px, py) { |
|
842 |
- const lengthSquared = Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2); |
|
843 |
- if (lengthSquared === 0) return Math.sqrt(Math.pow(px - x1, 2) + Math.pow(py - y1, 2)); |
|
844 |
- const t = Math.max(0, Math.min(1, ((px - x1) * (x2 - x1) + (py - y1) * (y2 - y1)) / lengthSquared)); |
|
845 |
- const projX = x1 + t * (x2 - x1); |
|
846 |
- const projY = y1 + t * (y2 - y1); |
|
847 |
- return Math.sqrt(Math.pow(px - projX, 2) + Math.pow(py - projY, 2)); |
|
848 |
- }, |
|
849 |
- clearAll() { |
|
850 |
- this.drawHistory = []; |
|
851 |
- this.stickers = []; |
|
852 |
- this.tempLines = []; |
|
853 |
- this.redraw(); |
|
854 |
- }, |
|
855 |
- redraw() { |
|
856 |
- const canvas = this.$refs.canvas; |
|
857 |
- const context = canvas.getContext('2d'); |
|
858 |
- const image = new Image(); |
|
859 |
- image.src = this.photo; |
|
860 |
- image.onload = () => { |
|
861 |
- context.clearRect(0, 0, this.canvasWidth, this.canvasHeight); |
|
862 |
- context.drawImage(image, 0, 0, this.canvasWidth, this.canvasHeight); |
|
863 |
- this.drawHistory.forEach(item => { |
|
864 |
- context.strokeStyle = item.color; |
|
865 |
- if (item.type === 'draw') { |
|
866 |
- context.beginPath(); |
|
867 |
- context.moveTo(item.startX, item.startY); |
|
868 |
- context.lineTo(item.endX, item.endY); |
|
869 |
- context.stroke(); |
|
870 |
- } else if (item.type === 'rectangle') { |
|
871 |
- context.strokeRect(item.startX, item.startY, item.endX - item.startX, item.endY - item.startY); |
|
872 |
- } else if (item.type === 'circle') { |
|
873 |
- context.beginPath(); |
|
874 |
- context.arc(item.startX, item.startY, item.radius, 0, 2 * Math.PI); |
|
875 |
- context.stroke(); |
|
876 |
- } |
|
877 |
- }); |
|
878 |
- this.tempLines.forEach(line => { |
|
879 |
- context.strokeStyle = line.color; |
|
880 |
- context.beginPath(); |
|
881 |
- context.moveTo(line.startX, line.startY); |
|
882 |
- context.lineTo(line.endX, line.endY); |
|
883 |
- context.stroke(); |
|
884 |
- }); |
|
885 |
- this.stickers.forEach((sticker, index) => { |
|
886 |
- context.drawImage(sticker.img, sticker.x, sticker.y, sticker.width, sticker.height); |
|
887 |
- }); |
|
888 |
- }; |
|
889 |
- }, |
|
890 |
- showConfirm(type) { |
|
891 |
- let message = ''; |
|
892 |
- if (type === 'cancel') { |
|
893 |
- message = '삭제하시겠습니까?'; |
|
894 |
- } else if (type === 'reset') { |
|
895 |
- message = '초기화하시겠습니까?'; |
|
896 |
- } else if (type === 'save') { |
|
897 |
- message = '등록하시겠습니까?'; |
|
898 |
- } |
|
899 |
- |
|
900 |
- if (confirm(message)) { |
|
901 |
- this.goBack(); |
|
902 |
- } |
|
903 |
- }, |
|
904 | 563 |
}, |
905 | 564 |
components: { |
906 | 565 |
SvgIcon, |
907 | 566 |
}, |
908 | 567 |
mounted() { |
568 |
+ this.fetchImage(); |
|
909 | 569 |
const { book_id, unit_id } = this.$route.query; |
570 |
+ |
|
910 | 571 |
console.log('main mounted'); |
911 | 572 |
this.fetchSchedule(unit_id, book_id); |
912 | 573 |
this.fetchRoadmapData(unit_id, book_id); |
913 | 574 |
this.fetchRabbit(); |
575 |
+ |
|
576 |
+ this.onVideoLoaded(); |
|
577 |
+ this.unit_id = unit_id |
|
578 |
+ this.book_id = book_id |
|
579 |
+ |
|
580 |
+ if (this.$route.query.reCapture == 'true') { |
|
581 |
+ this.openCameraModal() |
|
582 |
+ } |
|
914 | 583 |
}, |
915 | 584 |
computed: { |
916 | 585 |
processedRoadmap() { |
... | ... | @@ -1044,4 +713,12 @@ |
1044 | 713 |
left: -40px; |
1045 | 714 |
width: 20rem; |
1046 | 715 |
} |
716 |
+ |
|
717 |
+ |
|
718 |
+.camera-rabbit { |
|
719 |
+ position: absolute; |
|
720 |
+ right: 0; |
|
721 |
+ bottom: 0; |
|
722 |
+ width: 40%; |
|
723 |
+} |
|
1047 | 724 |
</style>(파일 끝에 줄바꿈 문자 없음) |
--- client/views/pages/main/PhotoEdit.vue
+++ client/views/pages/main/PhotoEdit.vue
... | ... | @@ -41,12 +41,14 @@ |
41 | 41 |
imageSrc: '', |
42 | 42 |
file: '', |
43 | 43 |
fileId: '', |
44 |
+ unit_id: '', |
|
45 |
+ book_id: '', |
|
44 | 46 |
} |
45 | 47 |
}, |
46 | 48 |
methods: { |
47 | 49 |
recapture() { |
48 |
- // this.$router.push({ name: 'Dashboard', query: { reCapture: 'true', unit_id, book_id } }); |
|
49 |
- this.$router.push({ name: 'AIDashboard', query: { reCapture: 'true' } }); |
|
50 |
+ // this.$router.push({ name: 'Dashboard', query: { reCapture: 'true', unit_id, book_id } }); |
|
51 |
+ this.$router.push({ name: 'Dashboard', query: { reCapture: 'true', unit_id: this.unit_id, book_id: this.book_id } }); |
|
50 | 52 |
}, |
51 | 53 |
async fetchImageAsFile(imageUrl, filename = "image.jpg") { |
52 | 54 |
try { |
... | ... | @@ -109,7 +111,7 @@ |
109 | 111 |
"fileMngId": this.fileId |
110 | 112 |
} |
111 | 113 |
}); |
112 |
- this.$router.push({ name: 'AIDashboard' }); |
|
114 |
+ this.$router.push({ name: 'Dashboard', query: { unit_id: this.unit_id, book_id: this.book_id } }); |
|
113 | 115 |
} catch (error) { |
114 | 116 |
console.error("사진 삽입 오류:", error); |
115 | 117 |
} |
... | ... | @@ -130,6 +132,8 @@ |
130 | 132 |
components: { |
131 | 133 |
}, |
132 | 134 |
mounted() { |
135 |
+ this.book_id = this.$route.query.book_id; |
|
136 |
+ this.unit_id = this.$route.query.unit_id; |
|
133 | 137 |
this.fetchPhoto(); |
134 | 138 |
} |
135 | 139 |
} |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?