From f9cd66f3c1cd1db394bbfdefd0c377573b20df0e Mon Sep 17 00:00:00 2001 From: linhaojun857 Date: Thu, 30 Nov 2023 17:03:30 +0800 Subject: [PATCH] Refactor: simplified code --- aurora-vue/aurora-blog/src/main.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/aurora-vue/aurora-blog/src/main.ts b/aurora-vue/aurora-blog/src/main.ts index ffab3fe..17ea0cf 100644 --- a/aurora-vue/aurora-blog/src/main.ts +++ b/aurora-vue/aurora-blog/src/main.ts @@ -40,6 +40,7 @@ axios.interceptors.request.use((config: any) => { config.headers['Authorization'] = 'Bearer ' + sessionStorage.getItem('token') return config }) +const proxy = app.config.globalProperties axios.interceptors.response.use( (response) => { if (response.data.flag) { @@ -47,7 +48,7 @@ axios.interceptors.response.use( } switch (response.data.code) { case 50000: { - app.config.globalProperties.$notify({ + proxy.$notify({ title: 'Error', message: '系统异常', type: 'error' @@ -55,7 +56,7 @@ axios.interceptors.response.use( break } case 40001: { - app.config.globalProperties.$notify({ + proxy.$notify({ title: 'Error', message: '用户未登录', type: 'error' @@ -69,7 +70,7 @@ axios.interceptors.response.use( break } default: { - app.config.globalProperties.$notify({ + proxy.$notify({ title: 'Error', message: response.data.message, type: 'error'