From 30e8cc41bb5691995edf86fcab74308918438c22 Mon Sep 17 00:00:00 2001 From: ronger Date: Wed, 3 Feb 2021 09:15:23 +0800 Subject: [PATCH] :bugs: https://github.com/ronger-x/nebula/issues/5 --- plugins/axios.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/axios.js b/plugins/axios.js index 5278e8b..d566a52 100644 --- a/plugins/axios.js +++ b/plugins/axios.js @@ -22,17 +22,19 @@ export default function ({app, $axios, store, redirect}) { if (response.data.success) { resolve(response.data); } else { - if (response.data.code === 0) { + if (response.data.code === '0') { Message.error(message ? message : '服务异常') - } else if (response.data.code === 401) { + } else if (response.data.code === '401') { Cookie.remove('auth'); store.commit('setAuth', null); - } else if (response.data.code === 402) { + window.location.reload() + } else if (response.data.code === '402') { Cookie.remove('auth'); store.commit('setAuth', null); - } else if (response.data.code === 404) { + window.location.reload() + } else if (response.data.code === '404') { Message.error('操作失败,请稍后再试......') - } else if (response.data.code === 500) { + } else if (response.data.code === '500') { Message.error('服务器正在开小差,请稍后再试......') } else { Message.error(response.data.message);