refactor: 에러 로그 수정
This commit is contained in:
@@ -64,7 +64,6 @@ const { tm } = useI18n()
|
|||||||
const props = withDefaults(defineProps<ErrorProps>(), {
|
const props = withDefaults(defineProps<ErrorProps>(), {
|
||||||
error: () => ({})
|
error: () => ({})
|
||||||
})
|
})
|
||||||
const router = useRouter()
|
|
||||||
const nuxtError = useError()
|
const nuxtError = useError()
|
||||||
const currentError = computed(() => props.error || nuxtError.value)
|
const currentError = computed(() => props.error || nuxtError.value)
|
||||||
|
|
||||||
@@ -74,7 +73,6 @@ const errorTitle = ref('')
|
|||||||
const errorMsg = ref('')
|
const errorMsg = ref('')
|
||||||
|
|
||||||
//error clear 함수 생성
|
//error clear 함수 생성
|
||||||
|
|
||||||
const localePath = useLocalePath()
|
const localePath = useLocalePath()
|
||||||
|
|
||||||
// const handleError = () => clearError({ redirect: '/' })
|
// const handleError = () => clearError({ redirect: '/' })
|
||||||
@@ -90,15 +88,10 @@ const handleBack = () => {
|
|||||||
// navigateTo(`${router.currentRoute.value.path}`)
|
// navigateTo(`${router.currentRoute.value.path}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 500 에러 발생 시 /error 페이지로 리다이렉트
|
// 500 에러 발생 시 /error 페이지로 리다이렉트
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
console.log("🚀 ~ 1111 handleBack ~ router:", router)
|
|
||||||
console.log("🚀 ~ 2222 router.currentRoute.value.path) ~ router:", router.currentRoute.value.path)
|
|
||||||
|
|
||||||
const statusCode = currentError.value?.statusCode
|
const statusCode = currentError.value?.statusCode
|
||||||
console.log("🚀 ~ 2222 currentError==:", currentError.value?.message)
|
|
||||||
console.log("🚀 ~ 222222 statusCode:", statusCode)
|
|
||||||
|
|
||||||
if (statusCode === 500) {
|
if (statusCode === 500) {
|
||||||
errorTitle.value = tm('Error_500_Inconvenience')
|
errorTitle.value = tm('Error_500_Inconvenience')
|
||||||
@@ -114,7 +107,6 @@ onMounted(() => {
|
|||||||
|
|
||||||
// 백스페이스 키 처리
|
// 백스페이스 키 처리
|
||||||
const handleKeydown = (e: KeyboardEvent) => {
|
const handleKeydown = (e: KeyboardEvent) => {
|
||||||
console.log("🚀 ~ handleKeydown ~ e:", e.key)
|
|
||||||
if (e.key === 'Backspace' &&
|
if (e.key === 'Backspace' &&
|
||||||
!['INPUT', 'TEXTAREA'].includes((e.target as HTMLElement).tagName)) {
|
!['INPUT', 'TEXTAREA'].includes((e.target as HTMLElement).tagName)) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
@@ -122,18 +114,12 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 브라우저 뒤로가기 버튼 처리
|
|
||||||
const handlePopState = () => {
|
|
||||||
// clearError()
|
|
||||||
handleBack()
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener('keydown', handleKeydown)
|
window.addEventListener('keydown', handleKeydown)
|
||||||
window.addEventListener('popstate', handlePopState)
|
window.addEventListener('popstate', handleBack)
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
window.removeEventListener('keydown', handleKeydown)
|
window.removeEventListener('keydown', handleKeydown)
|
||||||
window.removeEventListener('popstate', handlePopState)
|
window.removeEventListener('popstate', handleBack)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user