From e42d5308d4638fa81f1eea89d15a86fe7880e193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E8=99=B9=E7=9D=BF?= <297504645@qq.com> Date: Tue, 15 Aug 2023 17:27:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E9=94=99=E8=AF=AF=E5=8F=8A?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=E5=B0=81=E8=A3=85=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PC/InterFace.Dash/src/permission.js | 6 +++++- PC/InterFace.Dash/src/store/modules/definition.js | 14 +++++++++----- PC/InterFace.Dash/src/utils/request.js | 9 +++++++++ PC/UI.WinIn.FasterZ.Job/src/permission.js | 4 +++- .../src/store/modules/definition.js | 14 +++++++++----- PC/UI.WinIn.FasterZ.Job/src/utils/request.js | 9 +++++++++ PC/UI.WinIn.FasterZ.Store/src/permission.js | 7 +++++-- .../src/store/modules/definition.js | 14 +++++++++----- PC/UI.WinIn.FasterZ.Store/src/utils/request.js | 9 +++++++++ 9 files changed, 67 insertions(+), 19 deletions(-) diff --git a/PC/InterFace.Dash/src/permission.js b/PC/InterFace.Dash/src/permission.js index 04e4b43..bec85f3 100644 --- a/PC/InterFace.Dash/src/permission.js +++ b/PC/InterFace.Dash/src/permission.js @@ -19,7 +19,9 @@ router.beforeEach(async (to, from, next) => { // 获取表头转义 if(!store.getters.columZHList || store.getters.columZHList.length <= 0){ - await store.dispatch('definition/getColumZHList') + await store.dispatch('definition/getColumZHList',()=>{ + NProgress.done() + }) } // 获取菜单数据 @@ -74,6 +76,7 @@ router.beforeEach(async (to, from, next) => { console.log("-------用户信息获取成功-------") localStorage.setItem('alreadyTryLogin',true) next(to) + NProgress.done() // next({ // ...to, // query:{ @@ -114,6 +117,7 @@ router.beforeEach(async (to, from, next) => { }, replace: true }) + NProgress.done() } } } diff --git a/PC/InterFace.Dash/src/store/modules/definition.js b/PC/InterFace.Dash/src/store/modules/definition.js index f8a6563..1a6dfb4 100644 --- a/PC/InterFace.Dash/src/store/modules/definition.js +++ b/PC/InterFace.Dash/src/store/modules/definition.js @@ -148,13 +148,18 @@ const actions = { }) }, // 获取表头转义 - getColumZHList({ commit }) { - return new Promise(resolve => { - getInterfaceBoard().then(res=>{ + getColumZHList({ commit },errCallback) { + return new Promise((resolve,reject) => { + getInterfaceBoard() + .then(res=>{ let _zh = res.resources[localStorage.getItem('columnsApiNamesZh')].texts; commit('SET_COLUMZH_LIST', _zh) resolve(res) }) + .catch(err=>{ + if(errCallback)errCallback() + reject(err) + }) }) } } @@ -164,5 +169,4 @@ export default { state, mutations, actions -} - \ No newline at end of file +} \ No newline at end of file diff --git a/PC/InterFace.Dash/src/utils/request.js b/PC/InterFace.Dash/src/utils/request.js index 625a868..387ff13 100644 --- a/PC/InterFace.Dash/src/utils/request.js +++ b/PC/InterFace.Dash/src/utils/request.js @@ -91,6 +91,15 @@ service.interceptors.response.use( // } }, error => { + if(!error.response || !error.response.data){ + Message({ + message: '访问出错,请重试', + type: 'error', + duration: 5 * 1000, + showClose:true + }) + return Promise.reject(error) + } let err = error.response.data.error // for debug if (err && err.validationErrors) { for (let item in err.validationErrors) { diff --git a/PC/UI.WinIn.FasterZ.Job/src/permission.js b/PC/UI.WinIn.FasterZ.Job/src/permission.js index 04e4b43..07ffcf1 100644 --- a/PC/UI.WinIn.FasterZ.Job/src/permission.js +++ b/PC/UI.WinIn.FasterZ.Job/src/permission.js @@ -19,7 +19,9 @@ router.beforeEach(async (to, from, next) => { // 获取表头转义 if(!store.getters.columZHList || store.getters.columZHList.length <= 0){ - await store.dispatch('definition/getColumZHList') + await store.dispatch('definition/getColumZHList',()=>{ + NProgress.done() + }) } // 获取菜单数据 diff --git a/PC/UI.WinIn.FasterZ.Job/src/store/modules/definition.js b/PC/UI.WinIn.FasterZ.Job/src/store/modules/definition.js index f8a6563..1a6dfb4 100644 --- a/PC/UI.WinIn.FasterZ.Job/src/store/modules/definition.js +++ b/PC/UI.WinIn.FasterZ.Job/src/store/modules/definition.js @@ -148,13 +148,18 @@ const actions = { }) }, // 获取表头转义 - getColumZHList({ commit }) { - return new Promise(resolve => { - getInterfaceBoard().then(res=>{ + getColumZHList({ commit },errCallback) { + return new Promise((resolve,reject) => { + getInterfaceBoard() + .then(res=>{ let _zh = res.resources[localStorage.getItem('columnsApiNamesZh')].texts; commit('SET_COLUMZH_LIST', _zh) resolve(res) }) + .catch(err=>{ + if(errCallback)errCallback() + reject(err) + }) }) } } @@ -164,5 +169,4 @@ export default { state, mutations, actions -} - \ No newline at end of file +} \ No newline at end of file diff --git a/PC/UI.WinIn.FasterZ.Job/src/utils/request.js b/PC/UI.WinIn.FasterZ.Job/src/utils/request.js index 625a868..387ff13 100644 --- a/PC/UI.WinIn.FasterZ.Job/src/utils/request.js +++ b/PC/UI.WinIn.FasterZ.Job/src/utils/request.js @@ -91,6 +91,15 @@ service.interceptors.response.use( // } }, error => { + if(!error.response || !error.response.data){ + Message({ + message: '访问出错,请重试', + type: 'error', + duration: 5 * 1000, + showClose:true + }) + return Promise.reject(error) + } let err = error.response.data.error // for debug if (err && err.validationErrors) { for (let item in err.validationErrors) { diff --git a/PC/UI.WinIn.FasterZ.Store/src/permission.js b/PC/UI.WinIn.FasterZ.Store/src/permission.js index 04e4b43..b507bce 100644 --- a/PC/UI.WinIn.FasterZ.Store/src/permission.js +++ b/PC/UI.WinIn.FasterZ.Store/src/permission.js @@ -10,7 +10,6 @@ import { asyncRoutes } from '@/router' NProgress.configure({ showSpinner: false }) // NProgress Configuration - router.beforeEach(async (to, from, next) => { // start progress bar NProgress.start() @@ -19,7 +18,9 @@ router.beforeEach(async (to, from, next) => { // 获取表头转义 if(!store.getters.columZHList || store.getters.columZHList.length <= 0){ - await store.dispatch('definition/getColumZHList') + await store.dispatch('definition/getColumZHList',()=>{ + NProgress.done() + }) } // 获取菜单数据 @@ -74,6 +75,7 @@ router.beforeEach(async (to, from, next) => { console.log("-------用户信息获取成功-------") localStorage.setItem('alreadyTryLogin',true) next(to) + NProgress.done() // next({ // ...to, // query:{ @@ -114,6 +116,7 @@ router.beforeEach(async (to, from, next) => { }, replace: true }) + NProgress.done() } } } diff --git a/PC/UI.WinIn.FasterZ.Store/src/store/modules/definition.js b/PC/UI.WinIn.FasterZ.Store/src/store/modules/definition.js index f8a6563..1a6dfb4 100644 --- a/PC/UI.WinIn.FasterZ.Store/src/store/modules/definition.js +++ b/PC/UI.WinIn.FasterZ.Store/src/store/modules/definition.js @@ -148,13 +148,18 @@ const actions = { }) }, // 获取表头转义 - getColumZHList({ commit }) { - return new Promise(resolve => { - getInterfaceBoard().then(res=>{ + getColumZHList({ commit },errCallback) { + return new Promise((resolve,reject) => { + getInterfaceBoard() + .then(res=>{ let _zh = res.resources[localStorage.getItem('columnsApiNamesZh')].texts; commit('SET_COLUMZH_LIST', _zh) resolve(res) }) + .catch(err=>{ + if(errCallback)errCallback() + reject(err) + }) }) } } @@ -164,5 +169,4 @@ export default { state, mutations, actions -} - \ No newline at end of file +} \ No newline at end of file diff --git a/PC/UI.WinIn.FasterZ.Store/src/utils/request.js b/PC/UI.WinIn.FasterZ.Store/src/utils/request.js index 625a868..387ff13 100644 --- a/PC/UI.WinIn.FasterZ.Store/src/utils/request.js +++ b/PC/UI.WinIn.FasterZ.Store/src/utils/request.js @@ -91,6 +91,15 @@ service.interceptors.response.use( // } }, error => { + if(!error.response || !error.response.data){ + Message({ + message: '访问出错,请重试', + type: 'error', + duration: 5 * 1000, + showClose:true + }) + return Promise.reject(error) + } let err = error.response.data.error // for debug if (err && err.validationErrors) { for (let item in err.validationErrors) {