|
|
@@ -5,7 +5,7 @@ import cryptojs from 'crypto-js'
|
|
|
//import { addPending, removePending } from './pending'
|
|
|
import { encryptBody, decryptBody } from '@/services/websocket/package/crypto'
|
|
|
import { IMessageHead } from '@/types/proto/proto'
|
|
|
-import { useGlobalStore, useLoginStore, useAccountStore, useErrorInfoStore } from '@/stores'
|
|
|
+import { useGlobalStore, useLoginStore, useAccountStore, useErrorInfoStore, i18n } from '@/stores'
|
|
|
import { CommonResult, ResultCode, SendMsgToMQ } from './types'
|
|
|
import { FunCode } from '@/constants/funcode'
|
|
|
import service from '@/services'
|
|
|
@@ -47,7 +47,7 @@ export default new (class {
|
|
|
},
|
|
|
(err) => {
|
|
|
console.error(err)
|
|
|
- return Promise.reject('发生错误,请稍后再试')
|
|
|
+ return Promise.reject(i18n.global.t('common.tips20'))
|
|
|
}
|
|
|
)
|
|
|
|
|
|
@@ -59,24 +59,24 @@ export default new (class {
|
|
|
},
|
|
|
(err) => {
|
|
|
if (err.message === 'Network Error') {
|
|
|
- return Promise.reject('网络或服务器错误')
|
|
|
+ return Promise.reject(i18n.global.t('common.tips21'))
|
|
|
}
|
|
|
if (err.response) {
|
|
|
const { code, msg, message } = err.response.data ?? {}
|
|
|
switch (err.response.status) {
|
|
|
case 408: {
|
|
|
- return Promise.reject('请求超时,请稍后再试')
|
|
|
+ return Promise.reject(i18n.global.t('common.tips19'))
|
|
|
}
|
|
|
default: {
|
|
|
const loginStore = useLoginStore()
|
|
|
if (loginStore.token && code === ResultCode.InvalidToken) {
|
|
|
- eventBus.$emit('LogoutNotify', '登录失效,请重新登录')
|
|
|
+ eventBus.$emit('LogoutNotify', i18n.global.t('common.tips18'))
|
|
|
}
|
|
|
return Promise.reject(msg || message)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return Promise.reject('发生错误,请稍后再试')
|
|
|
+ return Promise.reject(i18n.global.t('common.tips20'))
|
|
|
}
|
|
|
)
|
|
|
}
|
|
|
@@ -122,7 +122,7 @@ export default new (class {
|
|
|
resolve(res.data)
|
|
|
}
|
|
|
}).catch((err) => {
|
|
|
- const msg = err ?? (errMsg ? '请求失败: ' + errMsg : '请求失败,请稍后重试')
|
|
|
+ const msg = err ?? (errMsg ? i18n.global.t('common.tips23') + errMsg : i18n.global.t('common.tips22'))
|
|
|
reject(msg)
|
|
|
})
|
|
|
})
|
|
|
@@ -140,7 +140,7 @@ export default new (class {
|
|
|
const res = await this.request<CommonResult<T>>(config, errMsg)
|
|
|
switch (res.code) {
|
|
|
case ResultCode.InvalidToken: {
|
|
|
- return Promise.reject('登录失效')
|
|
|
+ return Promise.reject(i18n.global.t('common.tips24'))
|
|
|
}
|
|
|
case ResultCode.Success: {
|
|
|
return res
|
|
|
@@ -163,7 +163,7 @@ export default new (class {
|
|
|
const res = await this.request<CommonResult<T>>(config, errMsg)
|
|
|
switch (res.code) {
|
|
|
case ResultCode.InvalidToken: {
|
|
|
- return Promise.reject('登录失效')
|
|
|
+ return Promise.reject(i18n.global.t('common.tips24'))
|
|
|
}
|
|
|
case 0: {
|
|
|
return res
|