diff --git a/nezha-fronted/src/http.js b/nezha-fronted/src/http.js index c2df199c5..d062eeb36 100644 --- a/nezha-fronted/src/http.js +++ b/nezha-fronted/src/http.js @@ -5,7 +5,7 @@ export const requestsArr = [] axios.interceptors.request.use(config => { const source = CancelToken.source() // 申明CancelToken,也可new CancelToken.source()实例一个 config.cancelToken = source.token // 讲实例对象的token赋予该请求 - requestsArr.push(source) // 将该实例添加到队列中 + requestsArr.push({ source, config }) // 将该实例添加到队列中 const token = localStorage.getItem('nz-token') if (token) { config.headers.Authorization = token // 请求头token diff --git a/nezha-fronted/src/permission.js b/nezha-fronted/src/permission.js index be7d0270c..809eb823f 100644 --- a/nezha-fronted/src/permission.js +++ b/nezha-fronted/src/permission.js @@ -10,9 +10,15 @@ Vue.use(VueResource) const loginWhiteList = ['/setup', '/sys/license/upload', '/sys/license/state', '/sys/appearance'] // 免登陆白名单 const permissionWhiteList = ['/profile', '/menu', ...loginWhiteList] // 权限白名单 +const requestsWhiteList = ['js', 'css'] router.beforeEach((to, from, next) => { if (store.getters.getNowPath !== to.path && store.getters.getNowPath !== '/login') { - requestsArr.forEach(xhr => xhr.cancel()) + requestsArr.forEach(xhr => { + const arr = xhr.config.url.split('.') + if (requestsWhiteList.indexOf(arr[arr.length - 1]) === -1) { + xhr.source.cancel() + } + }) } store.commit('setNowPath', to.path) const configUrl = 'static/config.json?Timestamp=' + new Date().getTime()