|
|
@@ -12,66 +12,58 @@ const service = axios.create({
|
|
|
withCredentials: true
|
|
|
})
|
|
|
|
|
|
-// const err = (error) => {
|
|
|
-// if (error.response) {
|
|
|
-// const data = error.response.data
|
|
|
-// const token = Vue.ls.get('ACCESS_TOKEN')
|
|
|
-// if (error.response.status === 403) {
|
|
|
-// notification.error({
|
|
|
-// message: 'Forbidden',
|
|
|
-// description: data.message
|
|
|
-// })
|
|
|
-// }
|
|
|
-// if (error.response.status === 401 && !(data.result && data.result.isLogin)) {
|
|
|
-// notification.error({
|
|
|
-// message: 'Unauthorized',
|
|
|
-// description: 'Authorization verification failed'
|
|
|
-// })
|
|
|
-// if (token) {
|
|
|
-// store.dispatch('Logout').then(() => {
|
|
|
-// setTimeout(() => {
|
|
|
-// window.location.reload()
|
|
|
-// }, 1500)
|
|
|
-// })
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// return Promise.reject(error)
|
|
|
-// }
|
|
|
+ const err = (error) => {
|
|
|
+ if (error.response) {
|
|
|
+ const data = error.response.data
|
|
|
+ const token = Vue.ls.get('ACCESS_TOKEN')
|
|
|
+ if (error.response.status === 403) {
|
|
|
+ notification.error({
|
|
|
+ message: 'Forbidden',
|
|
|
+ description: data.message
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (error.response.status === 401 && !(data.result && data.result.isLogin)) {
|
|
|
+ notification.error({
|
|
|
+ message: 'Unauthorized',
|
|
|
+ description: 'Authorization verification failed'
|
|
|
+ })
|
|
|
+ if (token) {
|
|
|
+ store.dispatch('Logout').then(() => {
|
|
|
+ setTimeout(() => {
|
|
|
+ window.location.reload()
|
|
|
+ }, 1500)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Promise.reject(error)
|
|
|
+ }
|
|
|
|
|
|
|
|
|
-// //request incerceptor
|
|
|
-// service.interceptors.request.use((config) => {
|
|
|
-// if (store.getters.token) {
|
|
|
-// config.headers['Authorization'] = getToken()
|
|
|
-// }
|
|
|
-// const requestConfig = {
|
|
|
-// ...config,
|
|
|
-// url: `${config.url}`,
|
|
|
-// }
|
|
|
-// return requestConfig
|
|
|
-// }, err)
|
|
|
+//request incerceptor
|
|
|
+service.interceptors.request.use((config) => {
|
|
|
+ if (store.getters.token) {
|
|
|
+ config.headers['Authorization'] = getToken()
|
|
|
+ }
|
|
|
+ const requestConfig = {
|
|
|
+ ...config,
|
|
|
+ url: `${config.url}`,
|
|
|
+ }
|
|
|
+ return requestConfig
|
|
|
+}, err)
|
|
|
|
|
|
-// service.interceptors.response.use((response) => {
|
|
|
-// switch (response.status) {
|
|
|
-// case 200:
|
|
|
-// switch (response.data.returnCode) {
|
|
|
-// case 200:
|
|
|
-// return response.data.data
|
|
|
-// default:
|
|
|
-// if(response.data.message){
|
|
|
-// message.error(response.data.message)
|
|
|
-// }
|
|
|
-// }
|
|
|
-// break
|
|
|
-// case 404:
|
|
|
-// return false
|
|
|
-// default:
|
|
|
-// if(response.data.message){
|
|
|
-// message.error(response.data.message)
|
|
|
-// }
|
|
|
-// }
|
|
|
-// })
|
|
|
+service.interceptors.response.use((response) => {
|
|
|
+ switch (response.status) {
|
|
|
+ case 200:
|
|
|
+ return response.data
|
|
|
+ case 404:
|
|
|
+ return false
|
|
|
+ default:
|
|
|
+ if(response.data.message){
|
|
|
+ message.error(response.data.message)
|
|
|
+ }
|
|
|
+ }
|
|
|
+})
|
|
|
|
|
|
const installer = {
|
|
|
vm: {},
|