This commit is contained in:
liangjian
2026-01-27 16:32:15 +08:00
commit 836c61ac55
303 changed files with 34442 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
import type { App } from 'vue'
import { errorLog } from '/@/config'
import pinia from '/@/store'
import { useErrorLogStore } from '/@/store/modules/errorLog'
import { isArray } from '/@/utils/validate'
export const needErrorLog = () => {
const errorLogArray = isArray(errorLog) ? [...errorLog] : [errorLog]
return errorLogArray.includes(import.meta.env.MODE)
}
export const addErrorLog = (err: any) => {
if (!err.isRequest) console.error('school-apartment 错误拦截:', err)
const url = window.location.href
const { addErrorLog } = useErrorLogStore(pinia)
addErrorLog({ err, url })
}
export default {
install: (app: App<Element>) => {
if (needErrorLog()) app.config.errorHandler = addErrorLog
},
}