
--- client/views/pages/main/Dashboard.vue
+++ client/views/pages/main/Dashboard.vue
... | ... | @@ -1,6 +1,6 @@ |
1 | 1 |
<template> |
2 | 2 |
<p class="title1" v-if="state === 'finish'">오늘 공부를 다했어요! 너무 고생했어요!</p> |
3 |
- <p class="title1" v-else-if="state === ''">지금은 학습 루트가 등록이 안됐어요! 학습 일정에서 학습루트를 등록해볼까요?</p> |
|
3 |
+ <p class="title1" v-else-if="state === 'notRegistered'">지금은 학습 루트가 등록이 안됐어요! 학습 일정에서 학습루트를 등록해볼까요?</p> |
|
4 | 4 |
<!-- 1번 템플릿 --> |
5 | 5 |
<div v-else class="main"> |
6 | 6 |
<div class="race-wrap"> |
... | ... | @@ -8,20 +8,6 @@ |
8 | 8 |
<p class="title">{{ roadmapData[0].unit_nm }}</p> |
9 | 9 |
<p class="subtitle">{{ roadmapData[0].book_nm }}</p> |
10 | 10 |
</div> |
11 |
- <!-- |
|
12 |
- <div class="race-box"> |
|
13 |
- <div class="rabbit-start"><img src="../../../resources/img/img09_s.png" alt=""></div> |
|
14 |
- <div class="rcon flex justify-between mb5"> |
|
15 |
- <div class="race-btn" v-for="roadmap in roadmapData" :key="roadmap.learning_id" @click="goToPage('Chapter7')"> |
|
16 |
- <button class="popTxt" v-for="(item, index) in items" :key="index" @click="toggleImage(index)" data-num="2"> |
|
17 |
- <img :src="item.imgSrc1"> |
|
18 |
- <img :src="item.imgSrc2" :style="{ display: item.isSecondImageVisible ? 'block' : 'none' }"> |
|
19 |
- </button> |
|
20 |
- <p>{{getNonNullColumn(roadmap)}}</p> |
|
21 |
- </div> |
|
22 |
- </div> |
|
23 |
- </div> |
|
24 |
- --> |
|
25 | 11 |
<div class="race-box"> |
26 | 12 |
<div class="rabbit-start"><img src="../../../resources/img/img09_s.png" alt=""></div> |
27 | 13 |
<div class="rcon flex justify-end mb5"> |
... | ... | @@ -137,161 +123,8 @@ |
137 | 123 |
</div> |
138 | 124 |
</div> |
139 | 125 |
</article> |
140 |
- <!-- 팝업 --> |
|
141 |
- <article class="popup-wrap" v-show="searchOpen"> |
|
142 |
- <div class="popup-box "> |
|
143 |
- <div class="flex mb10 justify-between"> |
|
144 |
- <p class="popup-title">알림</p> |
|
145 |
- <button type="button" class="popup-close-btn" @click="closeBtn2"> |
|
146 |
- <svg-icon type="mdi" :path="mdiWindowClose" class="close-btn"></svg-icon> |
|
147 |
- </button> |
|
148 |
- </div> |
|
149 |
- </div> |
|
150 |
- </article> |
|
151 | 126 |
</div> |
152 | 127 |
</div> |
153 |
- |
|
154 |
- <!-- 팝업 --> |
|
155 |
- <div v-show="searchOpen2" class="popup-wrap"> |
|
156 |
- <div class="popup-box"> |
|
157 |
- <button type="button" class="popup-close-btn" style="position:absolute; top:10px; right: 10px;" |
|
158 |
- @click="closeModal"> |
|
159 |
- <svg-icon type="mdi" :path="mdiWindowClose" class="close-btn"></svg-icon> |
|
160 |
- </button> |
|
161 |
- |
|
162 |
- <div class="mb30 text-ct"> |
|
163 |
- <p class="title1 mb20">1단원이 끝났습니다!</p> |
|
164 |
- <p class="title1"><em class="yellow">기념사진</em>을 촬영하러 가요</p> |
|
165 |
- </div> |
|
166 |
- <div class="flex justify-center"> |
|
167 |
- <button type="button" title="사진촬영" class="new-btn" @click="openCameraModal"> |
|
168 |
- 사진 촬영 |
|
169 |
- </button> |
|
170 |
- </div> |
|
171 |
- </div> |
|
172 |
- </div> |
|
173 |
- |
|
174 |
- <!-- 카메라 모달 --> |
|
175 |
- <article v-show="showCameraModal" class="popup-wrap"> |
|
176 |
- <div class="popup-box" style="top: 500px; left:500px"> |
|
177 |
- <div class="flex mb10 justify-between"> |
|
178 |
- <p class="popup-title">사진 촬영</p> |
|
179 |
- <button type="button" class="popup-close-btn" @click="closeModal"> |
|
180 |
- <svg-icon type="mdi" :path="mdiWindowClose" class="close-btn"></svg-icon> |
|
181 |
- </button> |
|
182 |
- </div> |
|
183 |
- <div class="box"> |
|
184 |
- <div style="width: 100%;"> |
|
185 |
- <div id="container" ref="container"> |
|
186 |
- <video v-if="!photoTaken" autoplay="true" ref="modalVideoElement" class="mirrored" |
|
187 |
- @canplay="onVideoLoaded"></video> |
|
188 |
- </div> |
|
189 |
- </div> |
|
190 |
- </div> |
|
191 |
- <div class="flex justify-center mt20"> |
|
192 |
- <button type="button" class="new-btn" v-if="!photoTaken" @click="capturePhoto" |
|
193 |
- :disabled="!videoReady"> |
|
194 |
- 사진 촬영 |
|
195 |
- </button> |
|
196 |
- </div> |
|
197 |
- </div> |
|
198 |
- </article> |
|
199 |
- |
|
200 |
- <!-- 사진 모달 --> |
|
201 |
- <article v-show="showPhotoModal" class="popup-wrap"> |
|
202 |
- <div class="popup-box" style="top: 500px; left: auto"> |
|
203 |
- <div class="flex mb10 justify-between"> |
|
204 |
- <p class="popup-title">사진 꾸미기</p> |
|
205 |
- <button type="button" class="popup-close-btn" @click="closePhotoModal"> |
|
206 |
- <svg-icon type="mdi" :path="mdiWindowClose" class="close-btn"></svg-icon> |
|
207 |
- </button> |
|
208 |
- </div> |
|
209 |
- <div class="flex justify-between align-center" style="gap: 40px;"> |
|
210 |
- <div class="content" style="padding: 30px; min-width: 401px; min-height: 710px;"> |
|
211 |
- <div class="tool"> |
|
212 |
- <div class="flex justify-center mb20" style="gap: 20px;"> |
|
213 |
- <button class="popTxt" style="width: 101px;" v-for="(item, index) in items_photo" |
|
214 |
- :key="index" @click="updateContent(index)" |
|
215 |
- :class="{ active: selectedIndex === index }"> |
|
216 |
- <img :src="item.imgSrc1" style="display: block;"> |
|
217 |
- <img :src="item.imgSrc2" v-if="selectedIndex === index" style="display: block;"> |
|
218 |
- </button> |
|
219 |
- </div> |
|
220 |
- </div> |
|
221 |
- |
|
222 |
- <div class="stickers" v-show="!stickersVisible"> |
|
223 |
- <div class="toolbar"> |
|
224 |
- <label for="brushSize" style="font-size: 9px;">펜 굵기</label> |
|
225 |
- <input type="color" v-model="color" /> |
|
226 |
- <input type="range" id="brushSize" min="1" max="10" v-model="brushSize" |
|
227 |
- @input="updateBrushSize" style="width: 100px; margin-left: 5px;" /> |
|
228 |
- <button class="new-btn" style="font-size: 9px;" @click="setTool('draw')">펜</button> |
|
229 |
- <button class="new-btn" style="font-size: 9px;" |
|
230 |
- @click="setTool('eraser')">지우개</button> |
|
231 |
- <button class="new-btn" style="font-size: 9px;" @click="clearAll">전체 |
|
232 |
- 지우개</button> |
|
233 |
- </div> |
|
234 |
- </div> |
|
235 |
- |
|
236 |
- <div class="stickers" v-show="stickersVisible"> |
|
237 |
- <button><img src="../../../resources/img/img146_75s.png" alt=""></button> |
|
238 |
- <button><img src="../../../resources/img/img147_75s.png" alt=""></button> |
|
239 |
- <button><img src="../../../resources/img/img148_75s.png" alt=""></button> |
|
240 |
- <button><img src="../../../resources/img/img149_75s.png" alt=""></button> |
|
241 |
- <button><img src="../../../resources/img/img150_75s.png" alt=""></button> |
|
242 |
- <button><img src="../../../resources/img/img151_75s.png" alt=""></button> |
|
243 |
- <button><img src="../../../resources/img/img152_75s.png" alt=""></button> |
|
244 |
- <button><img src="../../../resources/img/img153_75s.png" alt=""></button> |
|
245 |
- <button><img src="../../../resources/img/img154_75s.png" alt=""></button> |
|
246 |
- <button><img src="../../../resources/img/img155_75s.png" alt=""></button> |
|
247 |
- <button><img src="../../../resources/img/img156_75s.png" alt=""></button> |
|
248 |
- <button><img src="../../../resources/img/img157_75s.png" alt=""></button> |
|
249 |
- <button><img src="../../../resources/img/img158_75s.png" alt=""></button> |
|
250 |
- </div> |
|
251 |
- </div> |
|
252 |
- <div> |
|
253 |
- <div class="content" style="height: 549px; |
|
254 |
- position: relative; |
|
255 |
- width: 973px; |
|
256 |
- display: flex; |
|
257 |
- justify-content: center; |
|
258 |
- align-items: center;"> |
|
259 |
- <canvas ref="canvas" style="position: absolute;"></canvas> |
|
260 |
- </div> |
|
261 |
- <div class="btn-wrap flex justify-center mt40" style="gap: 40px;"> |
|
262 |
- <button class="login-btn" @click="openCameraModal"> |
|
263 |
- <img src="../../../resources/img/btn07_s.png" alt=""> |
|
264 |
- <p>재촬영</p> |
|
265 |
- </button> |
|
266 |
- |
|
267 |
- <button class="login-btn" type="submit" @click="goToPage('PhotoEdit')"> |
|
268 |
- <img src="../../../resources/img/btn07_s.png" alt=""> |
|
269 |
- <p>완성</p> |
|
270 |
- </button> |
|
271 |
- </div> |
|
272 |
- </div> |
|
273 |
- <div class="content" style="padding: 30px; min-width: 401px; min-height: 710px;"> |
|
274 |
- <div class="mb20"> |
|
275 |
- <p class="popup-title" style="font-size: 32px">랜덤 단어</p> |
|
276 |
- </div> |
|
277 |
- <div class="flex-column" style="gap: 10px;"> |
|
278 |
- <button class="login-btn"><img src="../../../resources/img/img141_75s.png" alt=""> |
|
279 |
- <p class="title">a</p> |
|
280 |
- </button> |
|
281 |
- <button class="login-btn"><img src="../../../resources/img/img152_75s_01.png" alt=""> |
|
282 |
- <p class="title">a</p> |
|
283 |
- </button> |
|
284 |
- <button class="login-btn"><img src="../../../resources/img/img144_75s.png" alt=""> |
|
285 |
- <p class="title" style="color: #fff;">a</p> |
|
286 |
- </button> |
|
287 |
- <button class="login-btn"><img src="../../../resources/img/img145_75s.png" alt=""> |
|
288 |
- <p class="title mt20" style="color: #fff;">a</p> |
|
289 |
- </button> |
|
290 |
- </div> |
|
291 |
- </div> |
|
292 |
- </div> |
|
293 |
- </div> |
|
294 |
- </article> |
|
295 | 128 |
</div> |
296 | 129 |
</div> |
297 | 130 |
</template> |
... | ... | @@ -313,16 +146,6 @@ |
313 | 146 |
isSecondImageVisible: false |
314 | 147 |
}, |
315 | 148 |
], |
316 |
- items_photo: [ |
|
317 |
- { |
|
318 |
- imgSrc1: 'client/resources/img/btn20_75s_normal.png', //펜 선택되지 않음 |
|
319 |
- imgSrc2: 'client/resources/img/btn20_75s_click.png' //펜 선택됨 |
|
320 |
- }, |
|
321 |
- { |
|
322 |
- imgSrc1: 'client/resources/img/btn21_75s_normal.png', //스티커 선택되지 않음 |
|
323 |
- imgSrc2: 'client/resources/img/btn21_75s_click.png' //스티커 선택됨 |
|
324 |
- }, |
|
325 |
- ], |
|
326 | 149 |
mdiMagnify: mdiMagnify, |
327 | 150 |
mdiWindowClose: mdiWindowClose, |
328 | 151 |
mdiHeart: mdiHeart, |
... | ... | @@ -339,24 +162,6 @@ |
339 | 162 |
canvasHeight: 0, |
340 | 163 |
selectedIndex: 0, //툴 선택 여부 인덱스 |
341 | 164 |
stickersVisible: false, // 스티커 표시 여부 |
342 |
- |
|
343 |
- //사진 꾸미기 관련 변수 |
|
344 |
- drawHistory: [], //도형 기록 |
|
345 |
- tempLines: [], //펜 기록 |
|
346 |
- stickers: [], //스티커 파일 기록 |
|
347 |
- draggingStickerIndex: null, //스티커 드래그 |
|
348 |
- activeStickerIndex: null, // 현재 활성화된 스티커의 인덱스 |
|
349 |
- nextLineId: 0, //획 아이디 |
|
350 |
- tool: 'draw', //툴 결정 |
|
351 |
- color: '#000000', //펜 기본 색상 |
|
352 |
- isDrawing: false, //그리는 중인지 판단하는 변수 |
|
353 |
- brushSize: 5, // 초기 펜 굵기 |
|
354 |
- startX: 0, |
|
355 |
- startY: 0, |
|
356 |
- canvasRect: { |
|
357 |
- topLeft: { x: 0, y: 0 }, |
|
358 |
- bottomRight: { x: 0, y: 0 } |
|
359 |
- }, |
|
360 | 165 |
|
361 | 166 |
|
362 | 167 |
roadViewTF: false, |
... | ... | @@ -383,20 +188,28 @@ |
383 | 188 |
this.schedules = response.data; |
384 | 189 |
|
385 | 190 |
if (this.schedules.length == 0) { |
386 |
- this.state = '' |
|
191 |
+ this.state = 'notRegistered'; |
|
387 | 192 |
} else { |
388 |
- this.nowSchedule = this.schedules.find(schedule => schedule.finish === null || schedule.finish === ""); |
|
389 |
- if (this.nowSchedule) { |
|
390 |
- this.fetchRoadmapData(); // 진행 중인 스케줄이 있을 때 데이터를 가져오는 함수 호출 |
|
391 |
- this.state = 'studying' |
|
193 |
+ // 모든 계획의 finish 값이 T인지 확인 |
|
194 |
+ const allFinished = this.schedules.every(schedule => schedule.finish === "T"); |
|
195 |
+ |
|
196 |
+ if (allFinished) { |
|
197 |
+ this.state = 'finish'; |
|
392 | 198 |
} else { |
393 |
- this.state = 'finish' |
|
199 |
+ this.nowSchedule = this.schedules.find(schedule => schedule.finish === null || schedule.finish === "F"); |
|
200 |
+ if (this.nowSchedule) { |
|
201 |
+ this.fetchRoadmapData(); // 진행 중인 스케줄이 있을 때 데이터를 가져오는 함수 호출 |
|
202 |
+ this.state = 'studying'; |
|
203 |
+ } else { |
|
204 |
+ this.state = 'notRegistered'; |
|
205 |
+ } |
|
394 | 206 |
} |
395 | 207 |
} |
208 |
+ console.log(this.state); |
|
396 | 209 |
}) |
397 |
- .catch(error => { |
|
398 |
- console.error("Error fetching roadmap data:", error); |
|
399 |
- }); |
|
210 |
+ .catch(error => { |
|
211 |
+ console.error("Error fetching roadmap data:", error); |
|
212 |
+ }); |
|
400 | 213 |
}, |
401 | 214 |
finishSchedule() { |
402 | 215 |
axios({ |
... | ... | @@ -410,16 +223,25 @@ |
410 | 223 |
finish: "T" |
411 | 224 |
} |
412 | 225 |
}) |
413 |
- .then(response => { |
|
414 |
- window.location.reload(); |
|
415 |
- }) |
|
416 |
- .catch(error => { |
|
417 |
- console.error("Error fetching roadmap data:", error); |
|
418 |
- }); |
|
226 |
+ .then(response => { |
|
227 |
+ const nextSchedule = this.schedules.find(schedule => schedule.schdl_id > this.nowSchedule.schdl_id); |
|
228 |
+ alert("학습을 완료했습니다!"); |
|
229 |
+ if (nextSchedule) { |
|
230 |
+ // 다음 스케줄로 이동 |
|
231 |
+ this.nowSchedule = nextSchedule; |
|
232 |
+ this.$router.push({ name: 'Dashboard' }); |
|
233 |
+ } else { |
|
234 |
+ window.location.reload(); // 전체 페이지 새로고침 |
|
235 |
+ alert("모든 학습을 완료했습니다!"); |
|
236 |
+ // 페이지를 새로고침하여 Dashboard.vue를 다시 로드 |
|
237 |
+ |
|
238 |
+ } |
|
239 |
+ }) |
|
240 |
+ .catch(error => { |
|
241 |
+ console.error("Error updating schedule:", error); |
|
242 |
+ }); |
|
419 | 243 |
}, |
420 |
- |
|
421 | 244 |
fetchRoadmapData() { |
422 |
- const vm = this; |
|
423 | 245 |
axios({ |
424 | 246 |
url: "/unitLearning/find.json", |
425 | 247 |
method: "post", |
... | ... | @@ -431,91 +253,16 @@ |
431 | 253 |
book_id: this.schedules[0].book_id |
432 | 254 |
} |
433 | 255 |
}) |
434 |
- .then(response => { |
|
435 |
- this.roadmapData = response.data; |
|
436 |
- console.log(this.roadmapData) |
|
437 |
- this.roadViewTF = vm.roadmapData.length > 0; |
|
438 |
- }) |
|
439 |
- .catch(error => { |
|
440 |
- console.error("Error fetching roadmap data:", error); |
|
441 |
- }); |
|
442 |
- }, |
|
443 |
- getNonNullColumn(item) { |
|
444 |
- if (item.prblm_id !== null) return '문제'; |
|
445 |
- if (item.wd_book_id !== null) return '단어장'; |
|
446 |
- if (item.text_id !== null) return '지문'; |
|
447 |
- if (item.eval_id !== null) return '평가'; |
|
448 |
- return ''; |
|
449 |
- }, |
|
450 |
- toggleImage(index) { |
|
451 |
- this.items[index].isSecondImageVisible = !this.items[index].isSecondImageVisible; |
|
452 |
- }, |
|
453 |
- toggleImageAndShowPopup(index, dataNum) { |
|
454 |
- this.toggleImage(index); |
|
455 |
- if (dataNum === '11') { |
|
456 |
- this.searchOpen2 = true; |
|
457 |
- } |
|
458 |
- }, |
|
459 |
- ShowPopup() { |
|
460 |
- this.searchOpen2 = true; // 촬영 여부 묻는 모달창 열기 |
|
461 |
- }, |
|
462 |
- updateContent(index) { |
|
463 |
- this.selectedIndex = index; |
|
464 |
- |
|
465 |
- // 선택된 버튼이 스티커 버튼(인덱스 1)인지 확인 |
|
466 |
- if (index === 1) { |
|
467 |
- this.stickersVisible = true; // 스티커 툴 보이기 |
|
468 |
- } else { |
|
469 |
- this.stickersVisible = false; // 스티커 툴 숨기기 |
|
470 |
- } |
|
256 |
+ .then(response => { |
|
257 |
+ this.roadmapData = response.data; |
|
258 |
+ this.roadViewTF = this.roadmapData.length > 0; |
|
259 |
+ }) |
|
260 |
+ .catch(error => { |
|
261 |
+ console.error("Error fetching roadmap data:", error); |
|
262 |
+ }); |
|
471 | 263 |
}, |
472 | 264 |
goToPage(page) { |
473 | 265 |
this.$router.push({ name: page }); |
474 |
- }, |
|
475 |
- openCameraModal() { |
|
476 |
- this.closeModal(); |
|
477 |
- this.closePhotoModal(); |
|
478 |
- |
|
479 |
- this.drawHistory = []; |
|
480 |
- this.stickers = []; |
|
481 |
- this.tempLines = []; |
|
482 |
- this.videoReady = false; // 비디오 준비 상태 초기화 |
|
483 |
- |
|
484 |
- this.showCameraModal = true; |
|
485 |
- navigator.mediaDevices.getUserMedia({ video: true }) |
|
486 |
- .then(stream => { |
|
487 |
- const modalVideo = this.$refs.modalVideoElement; |
|
488 |
- modalVideo.srcObject = stream; |
|
489 |
- this.stream = stream; |
|
490 |
- modalVideo.addEventListener('loadedmetadata', this.adjustContainerSize); |
|
491 |
- }) |
|
492 |
- .catch(error => { |
|
493 |
- console.log("error>>>>>>>>", error); |
|
494 |
- }); |
|
495 |
- }, |
|
496 |
- closeModal() { //웹캠 및 모든 팝업 닫기 |
|
497 |
- // this.showModal = false; |
|
498 |
- this.searchOpen = false; |
|
499 |
- this.searchOpen2 = false; |
|
500 |
- this.showCameraModal = false; |
|
501 |
- this.photoTaken = false; |
|
502 |
- this.photo = null; |
|
503 |
- this.showPhotoModal = false; |
|
504 |
- |
|
505 |
- //스트림 종료 |
|
506 |
- if (this.stream) { |
|
507 |
- let tracks = this.stream.getTracks(); |
|
508 |
- tracks.forEach(track => track.stop()); |
|
509 |
- this.stream = null; |
|
510 |
- } |
|
511 |
- }, |
|
512 |
- closePhotoModal() { //사진꾸미기 팝업 닫기 |
|
513 |
- this.showPhotoModal = false; |
|
514 |
- this.closeModal(); |
|
515 |
- }, |
|
516 |
- onVideoLoaded() { |
|
517 |
- this.videoReady = true; |
|
518 |
- this.adjustContainerSize(); |
|
519 | 266 |
}, |
520 | 267 |
adjustContainerSize() { |
521 | 268 |
const video = this.$refs.modalVideoElement; |
... | ... | @@ -527,7 +274,6 @@ |
527 | 274 |
body.style.height = `${video.videoHeight}px`; |
528 | 275 |
} |
529 | 276 |
}, |
530 |
- |
|
531 | 277 |
buttonSearch() { |
532 | 278 |
this.searchOpen = true; |
533 | 279 |
}, |
... | ... | @@ -536,296 +282,6 @@ |
536 | 282 |
}, |
537 | 283 |
closeBtn() { |
538 | 284 |
this.searchOpen = false; |
539 |
- }, |
|
540 |
- capturePhoto() { |
|
541 |
- // 사진 촬영 기능 구현 |
|
542 |
- console.log("cam on"); |
|
543 |
- |
|
544 |
- if (!this.videoReady) return; // 비디오가 준비되지 않았으면 사진을 찍지 않음 |
|
545 |
- |
|
546 |
- const video = this.$refs.modalVideoElement; |
|
547 |
- const canvas = document.createElement('canvas'); |
|
548 |
- |
|
549 |
- canvas.width = video.videoWidth; |
|
550 |
- canvas.height = video.videoHeight; |
|
551 |
- this.canvasWidth = video.videoWidth; |
|
552 |
- this.canvasHeight = video.videoHeight; |
|
553 |
- const context = canvas.getContext('2d'); |
|
554 |
- context.translate(canvas.width, 0); |
|
555 |
- context.scale(-1, 1); |
|
556 |
- context.drawImage(video, 0, 0, canvas.width, canvas.height); |
|
557 |
- this.photo = canvas.toDataURL('image/png'); |
|
558 |
- this.photoTaken = true; |
|
559 |
- this.showPhotoModal = true; |
|
560 |
- console.log("PhotoModal open"); |
|
561 |
- this.$nextTick(() => { |
|
562 |
- console.log("canvas setup"); |
|
563 |
- // console.log("Photo data>>>>", this.photo); |
|
564 |
- this.setupCanvas(); |
|
565 |
- }); |
|
566 |
- |
|
567 |
- }, |
|
568 |
- setupCanvas() { |
|
569 |
- const canvas = this.$refs.canvas; |
|
570 |
- // const container = this.$refs.container; |
|
571 |
- if (!canvas) { |
|
572 |
- console.error("Canvas reference not found"); |
|
573 |
- resolve(); |
|
574 |
- return; |
|
575 |
- } |
|
576 |
- const context = canvas.getContext('2d'); |
|
577 |
- if (!context) { |
|
578 |
- console.error("Canvas context not found"); |
|
579 |
- return; |
|
580 |
- } |
|
581 |
- const image = new Image(); |
|
582 |
- image.src = this.photo; |
|
583 |
- // console.log("Photo data>>>>", image.src); |
|
584 |
- image.onload = () => { |
|
585 |
- console.log("Image loaded successfully"); |
|
586 |
- // this.canvasWidth = image.width; |
|
587 |
- // this.canvasHeight = image.height; |
|
588 |
- //이미지 크기가 캔버스와 안맞으면 이미지 불러오는데에 에러 남 |
|
589 |
- // container.style.width = this.canvasWidth; |
|
590 |
- // container.style.height = this.canvasHeight; |
|
591 |
- |
|
592 |
- canvas.width = this.canvasWidth; |
|
593 |
- canvas.height = this.canvasHeight; |
|
594 |
- |
|
595 |
- const rect = canvas.getBoundingClientRect(); |
|
596 |
- // 좌측 상단 좌표 |
|
597 |
- const topLeft = { |
|
598 |
- x: rect.left, |
|
599 |
- y: rect.top |
|
600 |
- }; |
|
601 |
- |
|
602 |
- // 우측 하단 좌표 |
|
603 |
- const bottomRight = { |
|
604 |
- x: rect.right, |
|
605 |
- y: rect.bottom |
|
606 |
- }; |
|
607 |
- |
|
608 |
- // 캔버스 크기 초기화 |
|
609 |
- this.updateCanvasRect(); |
|
610 |
- |
|
611 |
- // 윈도우 리사이즈 이벤트 리스너 추가 |
|
612 |
- window.addEventListener('resize', this.updateCanvasRect); |
|
613 |
- |
|
614 |
- // 클릭 이벤트 핸들러 추가 |
|
615 |
- this.$refs.canvas.addEventListener('click', this.handleCanvasClick); |
|
616 |
- |
|
617 |
- |
|
618 |
- // canvas.width = canvas.clientWidth; |
|
619 |
- // canvas.height = canvas.clientHeight; |
|
620 |
- // this.canvasWidth = canvas.clientWidth; |
|
621 |
- // this.canvasHeight = canvas.clientHeight; |
|
622 |
- |
|
623 |
- context.clearRect(0, 0, canvas.width, canvas.height); // 이전 이미지 있으면 초기화 |
|
624 |
- context.drawImage(image, 0, 0, this.canvasWidth, this.canvasHeight); |
|
625 |
- this.addCanvasEventListeners(); //추가해야함 |
|
626 |
- }; |
|
627 |
- image.onerror = (error) => { |
|
628 |
- console.error("Error loading image: ", error); |
|
629 |
- }; |
|
630 |
- }, |
|
631 |
- |
|
632 |
- addCanvasEventListeners() { |
|
633 |
- const canvas = this.$refs.canvas; |
|
634 |
- canvas.addEventListener('mousedown', this.onMouseDown); |
|
635 |
- canvas.addEventListener('mouseup', this.onMouseUp); |
|
636 |
- canvas.addEventListener('mousemove', this.onMouseMove); |
|
637 |
- canvas.addEventListener('click', this.onCanvasClick); |
|
638 |
- }, |
|
639 |
- setTool(tool) { |
|
640 |
- this.tool = tool; |
|
641 |
- }, |
|
642 |
- updateBrushSize() { |
|
643 |
- // 펜 굵기 변경 로직 |
|
644 |
- if (this.tool === 'draw') { |
|
645 |
- this.setBrushSize(this.brushSize); |
|
646 |
- } |
|
647 |
- }, |
|
648 |
- setBrushSize(size) { |
|
649 |
- this.brushSize = size; |
|
650 |
- const context = this.$refs.canvas.getContext('2d'); |
|
651 |
- context.lineWidth = size; |
|
652 |
- }, |
|
653 |
- // 캔버스 크기 갱신 함수 |
|
654 |
- updateCanvasRect() { |
|
655 |
- const rect = this.$refs.canvas.getBoundingClientRect(); |
|
656 |
- this.canvasRect = { |
|
657 |
- topLeft: { x: rect.left, y: rect.top }, |
|
658 |
- bottomRight: { x: rect.right, y: rect.bottom } |
|
659 |
- }; |
|
660 |
- console.log(">>>>>>>>>2222", rect.left); |
|
661 |
- }, |
|
662 |
- getCanvasPosition(event) { |
|
663 |
- |
|
664 |
- const rect = this.canvasRect; |
|
665 |
- console.log(">>>>>>>>>", this.canvasRect); |
|
666 |
- this.updateCanvasRect(); |
|
667 |
- |
|
668 |
- // 윈도우 리사이즈 이벤트 리스너 추가 |
|
669 |
- window.addEventListener('resize', this.updateCanvasRect); |
|
670 |
- |
|
671 |
- // 클릭 이벤트 핸들러 추가 |
|
672 |
- this.$refs.canvas.addEventListener('click', this.handleCanvasClick); |
|
673 |
- |
|
674 |
- // // 좌측 상단 좌표 |
|
675 |
- // const topLeft = { |
|
676 |
- // x: rect.left, |
|
677 |
- // y: rect.top |
|
678 |
- // }; |
|
679 |
- |
|
680 |
- // // 우측 하단 좌표 |
|
681 |
- // const bottomRight = { |
|
682 |
- // x: rect.right, |
|
683 |
- // y: rect.bottom |
|
684 |
- // }; |
|
685 |
- |
|
686 |
- // console.log(this.scrollLeft) |
|
687 |
- |
|
688 |
- const x = event.clientX - rect.topLeft.x |
|
689 |
- const y = event.clientY - rect.topLeft.y |
|
690 |
- |
|
691 |
- |
|
692 |
- console.log(`클릭한 좌표: x=${event.clientX}, y=${event.clientY}`); |
|
693 |
- console.log(`계산베이스 좌표: x=${rect.topLeft.x}, y=${rect.topLeft.y}`); |
|
694 |
- console.log(`계산베이스 좌표: x=${rect.topLeft.x}, y=${rect.topLeft.y}`); |
|
695 |
- console.log(`계산된 좌표: x=${x}, y=${y}`); |
|
696 |
- return { |
|
697 |
- x, y |
|
698 |
- }; |
|
699 |
- }, |
|
700 |
- onMouseDown(event) { |
|
701 |
- |
|
702 |
- // 캔버스 크기 초기화 |
|
703 |
- this.updateCanvasRect(); |
|
704 |
- |
|
705 |
- // 윈도우 리사이즈 이벤트 리스너 추가 |
|
706 |
- window.addEventListener('resize', this.updateCanvasRect); |
|
707 |
- |
|
708 |
- // 클릭 이벤트 핸들러 추가 |
|
709 |
- this.$refs.canvas.addEventListener('click', this.handleCanvasClick); |
|
710 |
- |
|
711 |
- const { x, y } = this.getCanvasPosition(event); |
|
712 |
- this.startX = x; |
|
713 |
- this.startY = y; |
|
714 |
- const context = this.$refs.canvas.getContext('2d'); |
|
715 |
- context.strokeStyle = this.color; |
|
716 |
- context.lineWidth = this.brushSize; // 브러시 크기 설정 |
|
717 |
- if (this.tool === 'draw') { |
|
718 |
- context.beginPath(); |
|
719 |
- context.moveTo(this.startX, this.startY); |
|
720 |
- this.nextLineId++; |
|
721 |
- } |
|
722 |
- this.isDrawing = true; |
|
723 |
- }, |
|
724 |
- onMouseUp(event) { |
|
725 |
- if (!this.isDrawing) return; |
|
726 |
- const { x, y } = this.getCanvasPosition(event); |
|
727 |
- const context = this.$refs.canvas.getContext('2d'); |
|
728 |
- context.strokeStyle = this.color; |
|
729 |
- context.lineWidth = this.brushSize; // 브러시 크기 설정 |
|
730 |
- if (this.tool === 'rectangle') { |
|
731 |
- context.strokeRect(this.startX, this.startY, x - this.startX, y - this.startY); |
|
732 |
- this.drawHistory.push({ type: 'rectangle', startX: this.startX, startY: this.startY, endX: x, endY: y, color: this.color }); |
|
733 |
- } else if (this.tool === 'circle') { |
|
734 |
- context.beginPath(); |
|
735 |
- const radius = Math.sqrt(Math.pow((x - this.startX), 2) + Math.pow((y - this.startY), 2)); |
|
736 |
- context.arc(this.startX, this.startY, radius, 0, 2 * Math.PI); |
|
737 |
- context.stroke(); |
|
738 |
- this.drawHistory.push({ type: 'circle', startX: this.startX, startY: this.startY, radius, color: this.color }); |
|
739 |
- } else if (this.tool === 'draw') { |
|
740 |
- context.lineTo(x, y); |
|
741 |
- context.stroke(); |
|
742 |
- this.tempLines.push({ id: this.nextLineId, startX: this.startX, startY: this.startY, endX: x, endY: y, color: this.color }); |
|
743 |
- } |
|
744 |
- this.isDrawing = false; |
|
745 |
- }, |
|
746 |
- onMouseMove(event) { |
|
747 |
- if (!this.isDrawing || this.tool !== 'draw') return; |
|
748 |
- const { x, y } = this.getCanvasPosition(event); |
|
749 |
- const context = this.$refs.canvas.getContext('2d'); |
|
750 |
- context.strokeStyle = this.color; |
|
751 |
- context.lineWidth = this.brushSize; // 브러시 크기 설정 |
|
752 |
- context.lineTo(x, y); |
|
753 |
- context.stroke(); |
|
754 |
- this.tempLines.push({ id: this.nextLineId, startX: this.startX, startY: this.startY, endX: x, endY: y, color: this.color }); |
|
755 |
- this.startX = x; |
|
756 |
- this.startY = y; |
|
757 |
- }, |
|
758 |
- onCanvasClick(event) { |
|
759 |
- if (this.tool === 'eraser') { |
|
760 |
- const { x, y } = this.getCanvasPosition(event); |
|
761 |
- this.eraseDrawing(x, y); |
|
762 |
- } |
|
763 |
- }, |
|
764 |
- eraseDrawing(x, y) { |
|
765 |
- const eraserRadius = 10; |
|
766 |
- this.drawHistory = this.drawHistory.filter(item => { |
|
767 |
- if (item.type === 'rectangle') { |
|
768 |
- return !(x >= item.startX && x <= item.endX && y >= item.startY && y <= item.endY); |
|
769 |
- } else if (item.type === 'circle') { |
|
770 |
- const distance = Math.sqrt(Math.pow((x - item.startX), 2) + Math.pow((y - item.startY), 2)); |
|
771 |
- return !(distance <= item.radius); |
|
772 |
- } |
|
773 |
- }); |
|
774 |
- const linesToDelete = this.tempLines.filter(line => { |
|
775 |
- const distanceToLine = this.distanceToLineSegment(line.startX, line.startY, line.endX, line.endY, x, y); |
|
776 |
- return distanceToLine <= 10; |
|
777 |
- }).map(line => line.id); |
|
778 |
- this.tempLines = this.tempLines.filter(line => !linesToDelete.includes(line.id)); |
|
779 |
- this.redraw(); |
|
780 |
- }, |
|
781 |
- distanceToLineSegment(x1, y1, x2, y2, px, py) { |
|
782 |
- const lengthSquared = Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2); |
|
783 |
- if (lengthSquared === 0) return Math.sqrt(Math.pow(px - x1, 2) + Math.pow(py - y1, 2)); |
|
784 |
- const t = Math.max(0, Math.min(1, ((px - x1) * (x2 - x1) + (py - y1) * (y2 - y1)) / lengthSquared)); |
|
785 |
- const projX = x1 + t * (x2 - x1); |
|
786 |
- const projY = y1 + t * (y2 - y1); |
|
787 |
- return Math.sqrt(Math.pow(px - projX, 2) + Math.pow(py - projY, 2)); |
|
788 |
- }, |
|
789 |
- clearAll() { |
|
790 |
- this.drawHistory = []; |
|
791 |
- this.stickers = []; |
|
792 |
- this.tempLines = []; |
|
793 |
- this.redraw(); |
|
794 |
- }, |
|
795 |
- redraw() { |
|
796 |
- const canvas = this.$refs.canvas; |
|
797 |
- const context = canvas.getContext('2d'); |
|
798 |
- const image = new Image(); |
|
799 |
- image.src = this.photo; |
|
800 |
- image.onload = () => { |
|
801 |
- context.clearRect(0, 0, this.canvasWidth, this.canvasHeight); |
|
802 |
- context.drawImage(image, 0, 0, this.canvasWidth, this.canvasHeight); |
|
803 |
- this.drawHistory.forEach(item => { |
|
804 |
- context.strokeStyle = item.color; |
|
805 |
- if (item.type === 'draw') { |
|
806 |
- context.beginPath(); |
|
807 |
- context.moveTo(item.startX, item.startY); |
|
808 |
- context.lineTo(item.endX, item.endY); |
|
809 |
- context.stroke(); |
|
810 |
- } else if (item.type === 'rectangle') { |
|
811 |
- context.strokeRect(item.startX, item.startY, item.endX - item.startX, item.endY - item.startY); |
|
812 |
- } else if (item.type === 'circle') { |
|
813 |
- context.beginPath(); |
|
814 |
- context.arc(item.startX, item.startY, item.radius, 0, 2 * Math.PI); |
|
815 |
- context.stroke(); |
|
816 |
- } |
|
817 |
- }); |
|
818 |
- this.tempLines.forEach(line => { |
|
819 |
- context.strokeStyle = line.color; |
|
820 |
- context.beginPath(); |
|
821 |
- context.moveTo(line.startX, line.startY); |
|
822 |
- context.lineTo(line.endX, line.endY); |
|
823 |
- context.stroke(); |
|
824 |
- }); |
|
825 |
- this.stickers.forEach((sticker, index) => { |
|
826 |
- context.drawImage(sticker.img, sticker.x, sticker.y, sticker.width, sticker.height); |
|
827 |
- }); |
|
828 |
- }; |
|
829 | 285 |
}, |
830 | 286 |
getNonNullColumn(item) { |
831 | 287 |
if (item.prblm_id !== null) return '문제'; |
... | ... | @@ -883,8 +339,6 @@ |
883 | 339 |
align-items: center; |
884 | 340 |
z-index: 100; |
885 | 341 |
} |
886 |
- |
|
887 |
- |
|
888 | 342 |
video { |
889 | 343 |
width: 100%; |
890 | 344 |
height: auto; |
... | ... | @@ -899,17 +353,6 @@ |
899 | 353 |
background-color: #FFF3D7; |
900 | 354 |
cursor: not-allowed; |
901 | 355 |
} |
902 |
- |
|
903 |
-/* button { |
|
904 |
- margin: auto; |
|
905 |
- padding: 5px 10px; |
|
906 |
- font-size: 13px; |
|
907 |
- cursor: pointer; |
|
908 |
- display: flex; |
|
909 |
- justify-content: center; |
|
910 |
- text-align: center; |
|
911 |
-} */ |
|
912 |
- |
|
913 | 356 |
.sticker { |
914 | 357 |
position: absolute; |
915 | 358 |
cursor: move; |
--- client/views/pages/main/MyPlan.vue
+++ client/views/pages/main/MyPlan.vue
... | ... | @@ -25,8 +25,10 @@ |
25 | 25 |
<p class="title2">{{ schedule.book_nm }}</p> |
26 | 26 |
<!-- <p class="title2">wirte a</p> --> |
27 | 27 |
</div> |
28 |
- <div><img src="../../../resources/img/img214_19s.png" alt=""></div> |
|
29 |
- </div> |
|
28 |
+ <div> |
|
29 |
+ <p class="title" @click="goToPage('Dashboard', schedule.schdl_id)">바로가기</p> |
|
30 |
+ <img src="../../../resources/img/img214_19s.png" alt=""></div> |
|
31 |
+ </div> |
|
30 | 32 |
</div> |
31 | 33 |
</div> |
32 | 34 |
</div> |
... | ... | @@ -38,7 +40,7 @@ |
38 | 40 |
<p class="title">오늘 공부를 계획해봅시다.</p> |
39 | 41 |
<p class="title1 mt20"> 스스로 학습 일정을 바꿔볼까요?</p> |
40 | 42 |
</div> |
41 |
- <button type="button" title="바로가기" class="yellow-btn" @click="goToPage('MyPlan2')"> |
|
43 |
+ <button type="button" title="바로가기" class="yellow-btn" @click="goToPage2('MyPlan2')"> |
|
42 | 44 |
바로가기 |
43 | 45 |
</button> |
44 | 46 |
</div> |
... | ... | @@ -88,11 +90,51 @@ |
88 | 90 |
{ label: "5교시", time: "13:00 ~ 14:00", value: "5" }, |
89 | 91 |
{ label: "6교시", time: "14:00 ~ 15:00", value: "6" }, |
90 | 92 |
], |
93 |
+ |
|
91 | 94 |
} |
92 | 95 |
}, |
93 | 96 |
methods: { |
94 |
- goToPage(page) { |
|
95 |
- this.$router.push({ name: page }); |
|
97 |
+ goToPage(page, scheduleId) { |
|
98 |
+ const startScheduleIndex = this.schedules.findIndex(schedule => schedule.schdl_id === scheduleId); |
|
99 |
+ |
|
100 |
+ if (startScheduleIndex === -1) { |
|
101 |
+ console.error("해당 스케줄을 찾을 수 없습니다."); |
|
102 |
+ return; |
|
103 |
+ } |
|
104 |
+ |
|
105 |
+ const updates = []; |
|
106 |
+ const currentSchedule = this.schedules[startScheduleIndex]; |
|
107 |
+ if (currentSchedule.finish === null || currentSchedule.finish === "T") { |
|
108 |
+ updates.push( |
|
109 |
+ axios.post("/schedule/scheduleUpdate.json", { scheduleId: currentSchedule.schdl_id, finish: "F" }, { |
|
110 |
+ headers: { |
|
111 |
+ "Content-Type": "application/json; charset=UTF-8", |
|
112 |
+ } |
|
113 |
+ }) |
|
114 |
+ ); |
|
115 |
+ } |
|
116 |
+ |
|
117 |
+ for (let i = startScheduleIndex + 1; i < this.schedules.length; i++) { |
|
118 |
+ const nextSchedule = this.schedules[i]; |
|
119 |
+ if (nextSchedule.finish === "T") { |
|
120 |
+ updates.push( |
|
121 |
+ axios.post("/schedule/scheduleUpdate.json", { scheduleId: nextSchedule.schdl_id, finish: "F" }, { |
|
122 |
+ headers: { |
|
123 |
+ "Content-Type": "application/json; charset=UTF-8", |
|
124 |
+ } |
|
125 |
+ }) |
|
126 |
+ ); |
|
127 |
+ } |
|
128 |
+ } |
|
129 |
+ |
|
130 |
+ Promise.all(updates) |
|
131 |
+ .then(() => { |
|
132 |
+ this.$router.push({ name: page }); |
|
133 |
+ }) |
|
134 |
+ .catch(error => { |
|
135 |
+ console.error("Error updating schedules:", error); |
|
136 |
+ alert("학습 계획을 업데이트하는 중 오류가 발생했습니다."); |
|
137 |
+ }); |
|
96 | 138 |
}, |
97 | 139 |
showConfirm(type) { |
98 | 140 |
let message = ''; |
... | ... | @@ -108,6 +150,9 @@ |
108 | 150 |
this.goBack(); |
109 | 151 |
} |
110 | 152 |
}, |
153 |
+ goToPage2(page) { |
|
154 |
+ this.$router.push({ name: page }); |
|
155 |
+ }, |
|
111 | 156 |
closeModal() { |
112 | 157 |
this.showModal = false; |
113 | 158 |
}, |
... | ... | @@ -117,7 +162,8 @@ |
117 | 162 |
closeBtn() { |
118 | 163 |
this.searchOpen = false; |
119 | 164 |
|
120 |
- }, fetchSchedules() { |
|
165 |
+ }, |
|
166 |
+ fetchSchedules() { |
|
121 | 167 |
axios.post("/schedule/selectSchedule.json", { stdId: this.stdId }, { |
122 | 168 |
headers: { |
123 | 169 |
"Content-Type": "application/json; charset=UTF-8", |
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?