Merge pull request #1875 from dataease/pr@v1.8@fix_mobile_login_i18n

fix: 移动端登录失败提示国际化
This commit is contained in:
fit2cloud-chenyw 2022-03-02 21:35:08 +08:00 committed by GitHub
commit 179b9b02e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,6 @@
import axios from 'axios'
import Config from '@/settings'
import { getToken, setToken, setUserInfo } from '@/common/utils'
import { getToken, setToken, setUserInfo, parseLanguage } from '@/common/utils'
const TokenKey = Config.TokenKey
const RefreshTokenKey = Config.RefreshTokenKey
const white_list = Config.WHITE_LIST
@ -15,6 +15,17 @@ let service = axios.create({
// request interceptor
service.interceptors.request.use(
config => {
let lang = parseLanguage() || uni.getLocale()
if (lang === 'en') {
config.headers['Accept-Language'] = 'en-US'
}else if(lang === 'zh-Hant'){
config.headers['Accept-Language'] = 'zh-TW'
}else {
config.headers['Accept-Language'] = 'zh-CN'
}
if (white_list.includes(config.url)) {
return config
}