🔨 全局异常处理.

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,28 +1,14 @@
import type { App, ComponentPublicInstance } from 'vue'; 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 = ( Vue.config.errorHandler = (
err: unknown, err: unknown,
instance: ComponentPublicInstance | null, instance: ComponentPublicInstance | null,
info: string info: string
) => { ) => {
// send error info console.error(info, err);
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
// ...
});
}; };
} }