fix: 修复线上国际化切换无效问题

This commit is contained in:
fit2cloud-chenyw 2021-05-19 10:03:00 +08:00
parent 36d5a80190
commit 1107529dc1
2 changed files with 6 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import { format } from '@/utils/formatUi'
import { getLanguage } from '@/lang/index'
import Cookies from 'js-cookie'
import router from '@/router'
import i18n from '@/lang'
const getDefaultState = () => {
return {
token: getToken(),
@ -57,6 +58,9 @@ const mutations = {
SET_LANGUAGE: (state, language) => {
state.language = language
Cookies.set('language', language)
if (language && i18n.locale !== language) {
i18n.locale = language
}
}
}

View File

@ -36,7 +36,8 @@ service.interceptors.request.use(
}
if (i18n.locale) {
config.headers['Accept-Language'] = i18n.locale
const lang = i18n.locale.replace('_', '-')
config.headers['Accept-Language'] = lang
}
// 增加loading