diff --git a/src/components/code/Normal.vue b/src/components/code/Normal.vue index 5e2bd3f..b925512 100644 --- a/src/components/code/Normal.vue +++ b/src/components/code/Normal.vue @@ -192,12 +192,11 @@ export default { backOff() { this.gameEnd = false document.body.style.overflow = 'auto' - //우승한 memberNo, roomMemberList의 size 보내기(exp추가) - this.disconnect() - console.log(this.roomMemberList.length) - console.log(this.resultMemberNo) - const url = `${this.backURL}/member/exp?memberNo=${this.resultMemberNo}&roomSize=${this.roomMemberList.length}` + + //우승한 memberNo, roomMemberList의 size 보내기(exp추가) + var roomMemberSize = this.roomMemberList.length * 5 + const url = `${this.backURL}/member/exp?memberNo=${this.resultMemberNo}&roomSize=${roomMemberSize}` if (this.resultMemberNo == this.memberNo) { // apiClient 보내기 apiClient @@ -319,6 +318,13 @@ export default { this.reportModal = false }, exitButtonClickHandler() { + var talkMessage = { + type: 'ROOM_TALK', + roomNo: this.roomNo, + sender: this.memberName, + message: this.memberNo + } + this.socket.send(JSON.stringify(talkMessage)) this.disconnect() this.$router.push({ path: `/` }) }, @@ -684,7 +690,7 @@ body.flex-container { border-radius: 10px; width: 400px; height: 540px; - margin-top: 250px; + margin-top: 100px; margin-left: 10px; z-index: 2; overflow: hidden; diff --git a/src/components/code/NormalMonaco.vue b/src/components/code/NormalMonaco.vue index 8d76755..4075a02 100644 --- a/src/components/code/NormalMonaco.vue +++ b/src/components/code/NormalMonaco.vue @@ -45,6 +45,7 @@ export default defineComponent({ }, language: { type: String, default: 'java' }, theme: { type: String, default: 'vs-dark' }, //vs, vs-dark, hc-black + // fontSize: {defalut: 15px} options: { type: Object, default() { @@ -70,7 +71,8 @@ export default defineComponent({ height: fixedHeight, 'text-align': 'left', 'align-items': 'center', - 'margin-left': '15px' + 'margin-left': '15px', + 'font-size' : '15px' } }) return { @@ -244,7 +246,6 @@ export default defineComponent({ this.output = response.data.result this.gameResult = response.data.gameResult - this.gameResult = '1' if (this.gameResult == '1') { this.$emit('monacoWinMemberNo', this.memberNo) } diff --git a/src/components/code/RankMonaco.vue b/src/components/code/RankMonaco.vue index 2f76aa9..4260a3c 100644 --- a/src/components/code/RankMonaco.vue +++ b/src/components/code/RankMonaco.vue @@ -245,26 +245,9 @@ export default defineComponent({ this.output = response.data.result this.gameResult = response.data.gameResult - this.gameResult = '1' if (this.gameResult == '1') { this.$emit('monacoWinMemberNo', this.memberNo) } - - //게임 결과 update - // const data = { - // gameResult: this.gameResult - // } - // const url2 = `${this.backURL}/rankgame/${this.rankNo}` - // apiClient - // .put(url2, JSON.stringify(data), { - // headers: { - // 'Content-Type': 'application/json' - // } - // }) - // .catch(error => { - // console.log('Server Error:', error); - // alert('서버 에러 발생. 자세한 내용은 콘솔을 확인하세요.'); - // }); }) //네트워크에 의한 요청 실패일 경우 .catch((error) => { diff --git a/src/components/home/MainHomeRoom.vue b/src/components/home/MainHomeRoom.vue index 82681f4..93a73ad 100644 --- a/src/components/home/MainHomeRoom.vue +++ b/src/components/home/MainHomeRoom.vue @@ -106,7 +106,7 @@ export default { } ) .then(() => { - this.$router.push({ + this.$router.replace({ path: `/room/${this.roomInfo.roomNo}`, state: { rightAccess: true diff --git a/src/components/profile/MyCode.vue b/src/components/profile/MyCode.vue index 0bdd8e4..4ef63d6 100644 --- a/src/components/profile/MyCode.vue +++ b/src/components/profile/MyCode.vue @@ -10,7 +10,7 @@ > {{ code.quizCorrect === 1 ? '성공' : '실패' }} {{ code.quizTitle }} - {{ code.quizDt }} + {{ code.quizDt }} @@ -88,7 +88,6 @@ export default { }, mounted() { this.memberNo = this.$route.params.memberNo - console.log(this.memberNo) const url = `${this.backURL}/mycode/${this.memberNo}` apiClient .get(url, { @@ -195,7 +194,7 @@ export default { ); } -.opposing-name { +.opposing-name, .regdate { width: 20%; line-height: 45px; color: var(--main1-color); @@ -206,6 +205,10 @@ export default { text-overflow: ellipsis; /* 넘치는 텍스트에 "..." 추가 */ } +.regdate { + width: 40%; +} + .game-result { color: var(--main1-color); width: 50%; diff --git a/src/components/rank/RankMatching.vue b/src/components/rank/RankMatching.vue index 53bf118..a09f1bd 100644 --- a/src/components/rank/RankMatching.vue +++ b/src/components/rank/RankMatching.vue @@ -95,7 +95,7 @@ export default { }, setQuiz() { apiClient.get(`${this.backURL}/rankroom/quiz/${this.rankRoom.roomNo}`).then((res) => { - this.$router.push({ + this.$router.replace({ path: '/rank/' + res.data, state: { rightAccess: true @@ -139,7 +139,7 @@ export default { this.rankRoom.quizNo != '' ) { this.stopMatching() - this.$router.push({ + this.$router.replace({ path: '/rank/' + this.rankRoom.rankNo, state: { rightAccess: true diff --git a/src/components/room/AddRoom.vue b/src/components/room/AddRoom.vue index 5519d48..15da949 100644 --- a/src/components/room/AddRoom.vue +++ b/src/components/room/AddRoom.vue @@ -221,7 +221,7 @@ export default { } }) .then(() => { - this.$router.push({ + this.$router.replace({ path: `/room/${res.data}`, state: { rightAccess: true diff --git a/src/util/axios-interceptor.js b/src/util/axios-interceptor.js index 83f1143..fa60dc6 100644 --- a/src/util/axios-interceptor.js +++ b/src/util/axios-interceptor.js @@ -25,9 +25,12 @@ apiClient.interceptors.response.use( async (error) => { if (error.response?.status === 401) { - sweetAlert.warning('로그인이 필요합니다', '', '로그인창으로 가기').then(() => { - window.location.href = '/login' - }) + sweetAlert.warning('로그인이 필요합니다', '', '로그인창으로 가기') + .then((result) => { + if (result.isConfirmed) { + window.location.href = '/login'; + } + }); } if (error.response?.status === 403) { console.error('403 Forbidden 에러 발생 :', error.response) diff --git a/src/views/code/Rank.vue b/src/views/code/Rank.vue index 4278f0e..a298ad9 100644 --- a/src/views/code/Rank.vue +++ b/src/views/code/Rank.vue @@ -98,8 +98,8 @@ export default { quizContent: '', quizTitle: '', timerRunning: true, - minutes: 0, - seconds: 10, + minutes: 60, + seconds: 0, socket: null, buttonValue: '', buttonValuePlayer1: '', @@ -138,7 +138,25 @@ export default { document.body.style.overflow = 'auto' this.disconnect() - console.log(this.winMemberNo) + //우승한 memberNo, roomMemberList의 size 보내기(exp추가) + var roomMemberSize = 10 + const url = `${this.backURL}/member/exp?memberNo=${this.resultMemberNo}&roomSize=${roomMemberSize}` + console.log(this.resultMemberNo) + console.log(this.memberNo) + console.log(roomMemberSize) + if (this.resultMemberNo == this.memberNo) { + // apiClient 보내기 + apiClient + .put(url, { + headers: { + 'Content-Type': 'application/json' + } + }) + .then((response) => { + console.log(response.data); + }) + } + if (this.memberNo == this.member1No && this.winMemberNo == this.memberNo) { if (this.resultMemberNo == this.memberNo) { // 게임 결과 update @@ -175,30 +193,11 @@ export default { alert('서버 에러 발생. 자세한 내용은 콘솔을 확인하세요.') }) } - } else { - if (this.resultMemberNo == this.memberNo) { - // 게임 결과 update - const data = { - gameResult: '0' - } - const url2 = `${this.backURL}/rankgame/${this.rankNo}` - apiClient - .put(url2, JSON.stringify(data), { - headers: { - 'Content-Type': 'application/json' - } - }) - .catch((error) => { - console.log('Server Error:', error) - alert('서버 에러 발생. 자세한 내용은 콘솔을 확인하세요.') - }) - } } this.$router.push({ path: `/` }) }, setWinMember(dataFromChild) { this.winMemberNo = dataFromChild - console.log(this.winMemberNo) var winMember = { type: 'CODE_STATUS', codeRoomNo: this.rankNo, @@ -206,14 +205,6 @@ export default { codeStatus: this.winMemberNo + ',win' } this.socket.send(JSON.stringify(winMember)) - - // var talkMessage = { - // type: 'CODE_STATUS', - // codeRoomNo: this.rankNo, - // codeSender: this.memberName, - // codeStatus: this.buttonValue - // } - // this.socket.send(JSON.stringify(talkMessage)) }, connect() { this.socket = new WebSocket(this.socketURL) @@ -231,12 +222,9 @@ export default { this.socket.onerror = () => {} this.socket.onmessage = (e) => { - console.log(e.data) if (this.socket.readyState === WebSocket.OPEN) { - console.log(e.data) const rawData = e.data const colonIndex = rawData.indexOf(':') - console.log(rawData) var msgMemberName = '' var msgMemberButtonValue = '' //test1: run @@ -250,9 +238,8 @@ export default { this.buttonValuePlayer2 = msgMemberButtonValue } } - console.log(msgMemberButtonValue) + const colonIndex2 = msgMemberButtonValue.indexOf(',') - console.log(colonIndex2) if (colonIndex2 !== -1) { this.resultMemberNo = msgMemberButtonValue.substring(0, colonIndex2).trim() this.gameEnd = true @@ -264,7 +251,7 @@ export default { this.socket.readyState === WebSocket.CLOSING || this.socket.readyState === WebSocket.CLOSED ) { - console.log('?') + this.connect() } } @@ -312,6 +299,19 @@ export default { event.returnValue = '' }, exitButtonClickHandler() { + if(this.memberNo == this.member1No){ + this.resultMemberNo = this.member2No + }else{ + this.resultMemberNo = this.member1No + } + // const enterMessage = { + // type: 'CODE_QUIT', + // codeRoomNo: this.rankNo, + // codeSender: this.resultMemberNo + // } + // this.socket.send(JSON.stringify(enterMessage)) + // } + // this.gameEnd = true this.disconnect() this.$router.push({ path: `/` }) }, @@ -332,6 +332,25 @@ export default { setTimeout(this.updateTimer, 1000) // 1초마다 업데이트 } if (this.seconds === 0 && this.minutes === 0) { + if (confirm('시간이 초과되어 메인으로 이동합니다')) { + // 게임 결과 update + const data = { + gameResult: '0' + } + const url2 = `${this.backURL}/rankgame/${this.rankNo}` + apiClient + .put(url2, JSON.stringify(data), { + headers: { + 'Content-Type': 'application/json' + } + }) + .catch((error) => { + console.log('Server Error:', error) + alert('서버 에러 발생. 자세한 내용은 콘솔을 확인하세요.') + }) + + this.$router.push({ path: `/` }) + } SweetAlert.warning('시간이 초과되어\n게임을 종료합니다', '랭크는 무승부처리로 인정됩니다', '확인').then(()=>{ this.$router.push({ path: `/` }) }) @@ -355,7 +374,20 @@ export default { } }, created() { - window.addEventListener('beforeunload', this.beforeUnloadHandler) + console.log('history.state: ', history.state.rightAccess) + + if (!history.state.rightAccess) { + SweetAlert.error('잘못된 접근입니다.').then((ok) => { + if (ok.isConfirmed) { + this.$router.replace({path: '/', state: { + rightAccess: false + }}).then(() => { + this.$router.go() + }) + } + }) + } else{ + window.addEventListener('beforeunload', this.beforeUnloadHandler) //타이머 시작 this.updateTimer() this.rankNo = this.$router.currentRoute.value.params.rankNo @@ -383,9 +415,7 @@ export default { this.quizContent = response.data.quizContent this.quizTitle = response.data.quizTitle }) - .catch(() => { - alert('문제 조회에 실패하였습니다') - }) + // testcaseList const url3 = `${this.backURL}/submit/${this.quizNo}` @@ -398,13 +428,9 @@ export default { .then((response) => { this.testcaseList = response.data }) - .catch(() => { - alert('테스트케이스 조회에 실패하였습니다') - }) - }) - .catch(() => { - alert('문제 정보 조회에 실패하였습니다') + }) + //memberNo const url4 = `${this.backURL}/member/memberNo` apiClient @@ -428,9 +454,13 @@ export default { this.memberName = response.data.memberName }) }) + } }, mounted() { - const url = `${this.backURL}/rankgame/${this.rankNo}` + console.log(history.state.rightAccess) + if (!history.state.rightAccess) { + }else{ + const url = `${this.backURL}/rankgame/${this.rankNo}` apiClient .get(url, { headers: { @@ -450,8 +480,8 @@ export default { } }) window.addEventListener('beforeunload', this.unLoadEvent) - this.rankNo = this.$router.currentRoute.value.params.rankNo this.connect() + } }, beforeUnmount() { const outMessage = { @@ -677,7 +707,7 @@ body.flex-container { border-radius: 10px; width: 400px; height: 540px; - margin-top: 250px; + margin-top: 100px; margin-left: 10px; z-index: 2; overflow: hidden; diff --git a/src/views/quiz/AddQuiz.vue b/src/views/quiz/AddQuiz.vue index 18e8a7a..2f3a094 100644 --- a/src/views/quiz/AddQuiz.vue +++ b/src/views/quiz/AddQuiz.vue @@ -55,8 +55,8 @@ >
diff --git a/src/views/room/WaitingRoom.vue b/src/views/room/WaitingRoom.vue index 9e60670..3da3387 100644 --- a/src/views/room/WaitingRoom.vue +++ b/src/views/room/WaitingRoom.vue @@ -395,11 +395,16 @@ export default { } }, mounted() { + console.log('history.state: ', history.state.rightAccess) + if (!history.state.rightAccess) { - console.log('history.state: ', history.state.rightAccess) SweetAlert.error('잘못된 접근입니다.').then((ok) => { if (ok.isConfirmed) { - this.$router.go(-1) + this.$router.replace({path: '/', state: { + rightAccess: false + }}).then(() => { + this.$router.go() + }) } }) } else {