[update 系统] i18n抽离单独js文件
This commit is contained in:
+15
-14
@@ -5,6 +5,7 @@ import { VueAxios } from './axios'
|
||||
import router from '@/router/index'
|
||||
import { ACCESS_TOKEN, TENANT_ID } from '@/store/mutation-types'
|
||||
import { Modal } from 'ant-design-vue'
|
||||
import i18n from '@/common/lang'
|
||||
|
||||
/**
|
||||
* 【指定 axios的 baseURL】
|
||||
@@ -29,7 +30,7 @@ const err = (error) => {
|
||||
console.log('------异常响应------', error.response.status)
|
||||
switch (error.response.status) {
|
||||
case 403:
|
||||
Vue.prototype.$Jnotification.error({ message: '系统提示', description: '拒绝访问', duration: 4 })
|
||||
Vue.prototype.$Jnotification.error({ message: i18n.t('prompted'), description: i18n.t('noAccess'), duration: 4 })
|
||||
break
|
||||
case 500:
|
||||
console.log('------error.response------', error.response)
|
||||
@@ -42,12 +43,12 @@ const err = (error) => {
|
||||
if (typeof data === 'string' ? data.includes('Token失效') : data.message.includes('Token失效')) {
|
||||
// update-begin- --- author:scott ------ date:20190225 ---- for:Token失效采用弹框模式,不直接跳转----
|
||||
if (/wxwork|dingtalk/i.test(navigator.userAgent)) {
|
||||
Vue.prototype.$Jmessage.loading('登录已过期,正在重新登陆', 0)
|
||||
Vue.prototype.$Jmessage.loading(i18n.t('loggingBackIn'), 0)
|
||||
} else {
|
||||
Vue.prototype.$Jmodal.error({
|
||||
title: '登录已过期',
|
||||
content: '很抱歉,登录已过期,请重新登录',
|
||||
okText: '重新登录',
|
||||
title: i18n.t('loginExpired'),
|
||||
content: i18n.t('loginExpiredMessage'),
|
||||
okText: i18n.t('logInAgain'),
|
||||
mask: false,
|
||||
onOk: () => {
|
||||
store.dispatch('Logout')
|
||||
@@ -58,13 +59,13 @@ const err = (error) => {
|
||||
}
|
||||
break
|
||||
case 404:
|
||||
Vue.prototype.$Jnotification.error({ message: '系统提示', description: '很抱歉,资源未找到!', duration: 4 })
|
||||
Vue.prototype.$Jnotification.error({ message: i18n.t('prompted'), description: i18n.t('resourceNotFound'), duration: 4 })
|
||||
break
|
||||
case 504:
|
||||
Vue.prototype.$Jnotification.error({ message: '系统提示', description: '网络超时' })
|
||||
Vue.prototype.$Jnotification.error({ message: i18n.t('prompted'), description: i18n.t('networkTimeout') })
|
||||
break
|
||||
case 401:
|
||||
Vue.prototype.$Jnotification.error({ message: '系统提示', description: '未授权,请重新登录', duration: 4 })
|
||||
Vue.prototype.$Jnotification.error({ message: i18n.t('prompted'), description: i18n.t('unauthorized'), duration: 4 })
|
||||
if (token) {
|
||||
store.dispatch('Logout').then(() => {
|
||||
setTimeout(() => {
|
||||
@@ -75,7 +76,7 @@ const err = (error) => {
|
||||
break
|
||||
default:
|
||||
Vue.prototype.$Jnotification.error({
|
||||
message: '系统提示',
|
||||
message: i18n.t('prompted'),
|
||||
description: data.message,
|
||||
duration: 4
|
||||
})
|
||||
@@ -83,9 +84,9 @@ const err = (error) => {
|
||||
}
|
||||
} else if (error.message) {
|
||||
if (error.message.includes('timeout')) {
|
||||
Vue.prototype.$Jnotification.error({ message: '系统提示', description: '网络超时' })
|
||||
Vue.prototype.$Jnotification.error({ message: i18n.t('prompted'), description: i18n.t('networkTimeout') })
|
||||
} else {
|
||||
Vue.prototype.$Jnotification.error({ message: '系统提示', description: error.message })
|
||||
Vue.prototype.$Jnotification.error({ message: i18n.t('prompted'), description: error.message })
|
||||
}
|
||||
}
|
||||
return Promise.reject(error)
|
||||
@@ -157,9 +158,9 @@ function blobToJson (data) {
|
||||
console.log('token----------》', token)
|
||||
if (token && jsonData.message.includes('Token失效')) {
|
||||
Modal.error({
|
||||
title: '登录已过期',
|
||||
content: '很抱歉,登录已过期,请重新登录',
|
||||
okText: '重新登录',
|
||||
title: i18n.t('loginExpired'),
|
||||
content: i18n.t('loginExpiredMessage'),
|
||||
okText: i18n.t('logInAgain'),
|
||||
mask: false,
|
||||
onOk: () => {
|
||||
store.dispatch('Logout').then(() => {
|
||||
|
||||
Reference in New Issue
Block a user