🔨 全局异常处理.

This commit is contained in:
lijiahangmax
2025-11-27 09:44:20 +08:00
parent 21e7d29077
commit 61fa7a6e32
7 changed files with 10 additions and 28 deletions

View File

@@ -169,7 +169,6 @@
Message.success('删除成功');
// 重新加载
reload();
} catch (e) {
} finally {
setLoading(false);
}
@@ -200,7 +199,6 @@
pagination.total = data.total;
pagination.current = request.page;
pagination.pageSize = request.limit;
} catch (e) {
} finally {
setLoading(false);
}

View File

@@ -135,8 +135,6 @@
}
handleClose();
return true;
} catch (e) {
return false;
} finally {
setLoading(false);
}

View File

@@ -139,8 +139,6 @@
}
handleClose();
return true;
} catch (e) {
return false;
} finally {
setLoading(false);
}

View File

@@ -202,7 +202,6 @@
selectedKeys.value = [];
// 重新加载
reload();
} catch (e) {
} finally {
setLoading(false);
}
@@ -220,7 +219,6 @@
Message.success('删除成功');
// 重新加载
reload();
} catch (e) {
} finally {
setLoading(false);
}
@@ -246,7 +244,6 @@
#if($vue.enableRowSelection)
selectedKeys.value = [];
#end
} catch (e) {
} finally {
setLoading(false);
}

View File

@@ -14,6 +14,7 @@ import '@/assets/style/chart.less';
import '@/assets/style/arco-extends.less';
import '@/api/interceptor';
import App from './App.vue';
import globalErrorHandler from '@/utils/monitor';
const app = createApp(App);
@@ -26,6 +27,9 @@ app.use(i18n);
app.use(globalComponents);
app.use(directive);
// 全局异常处理
globalErrorHandler(app);
app.mount('#app');
// 监听 PWA 注册事件

View File

@@ -40,5 +40,6 @@ export const playBellHz = (frequency: number = 400, duration: number = .15) => {
source.connect(audioCtx.destination);
source.start();
} catch (e) {
// ignored
}
};

View File

@@ -1,28 +1,14 @@
import type { App, ComponentPublicInstance } from 'vue';
import axios from 'axios';
export default function handleError(Vue: App, baseUrl: string) {
if (!baseUrl) {
return;
}
/**
* 全局异常处理
*/
export default function globalErrorHandler(Vue: App) {
Vue.config.errorHandler = (
err: unknown,
instance: ComponentPublicInstance | null,
info: string
) => {
// send error info
axios.post(`${baseUrl}/report-error`, {
err,
instance,
info,
// location: window.location.href,
// message: err.message,
// stack: err.stack,
// browserInfo: getBrowserInfo(),
// user info
// dom info
// url info
// ...
});
console.error(info, err);
};
}