-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FE] 게임 중 새로고침 처리, 탈주 및 탈락 표시 (#217)
* feat: 탈주, 탈락자 표시 기능 구현 * chore: 불필요한 코드 제거 * feat: 게임중 키보드 새로고침 동작 방지 기능 추가 * feat: 게임중 입장 불가 Alert 띄우기 제대로 동작 안 하는 상태 이후 추가적인 수정 필요 * docs: README.md 업데이트 * chore: 토스트 메시지 수정
- Loading branch information
1 parent
a8fdf52
commit e463405
Showing
14 changed files
with
137 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { useEffect } from 'react'; | ||
import { toast } from 'react-toastify'; | ||
|
||
export const usePreventRefresh = (isPlaying: boolean) => { | ||
useEffect(() => { | ||
if (!isPlaying) return; | ||
|
||
const preventKeyboardRefresh = (e: KeyboardEvent) => { | ||
if ( | ||
e.key === 'F5' || | ||
(e.ctrlKey && e.key === 'r') || | ||
(e.metaKey && e.key === 'r') | ||
) { | ||
e.preventDefault(); | ||
|
||
toast.error('게임 중에는 새로고침 할 수 없습니다!', { | ||
position: 'top-left', | ||
autoClose: 1000, | ||
style: { | ||
fontFamily: 'Galmuri11, monospace', | ||
width: '25rem', | ||
minWidth: '25rem', | ||
}, | ||
}); | ||
} | ||
}; | ||
|
||
document.addEventListener('keydown', preventKeyboardRefresh); | ||
|
||
return () => { | ||
document.removeEventListener('keydown', preventKeyboardRefresh); | ||
}; | ||
}, [isPlaying]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.