feat: add SingleRecordMnt component for student record maintenance with search, add, edit, view, and delete functionalities
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
// 全域 HTTP 錯誤事件(Playground 專用)
|
||||
//
|
||||
// 目的:
|
||||
// - 避免 axios interceptor 直接 import router 造成耦合
|
||||
// - 由 router 層或 App 層決定要導到哪個錯誤頁與顯示哪些訊息
|
||||
|
||||
export const HTTP_ERROR_EVENT = 'sk-playground:http-error'
|
||||
|
||||
export type HttpErrorDetail = {
|
||||
status?: number
|
||||
message?: string
|
||||
}
|
||||
|
||||
let httpErrorEmitted = false
|
||||
|
||||
export function emitHttpError (detail: HttpErrorDetail) {
|
||||
// 避免同一波大量錯誤觸發多次導頁
|
||||
if (httpErrorEmitted) return
|
||||
httpErrorEmitted = true
|
||||
|
||||
window.dispatchEvent(new CustomEvent<HttpErrorDetail>(HTTP_ERROR_EVENT, { detail }))
|
||||
|
||||
// 下一個 event loop 再允許觸發(避免把 guard 永久鎖住)
|
||||
setTimeout(() => {
|
||||
httpErrorEmitted = false
|
||||
}, 0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user