From 720af762f95e89108d174c604a355b4fd135d7ab Mon Sep 17 00:00:00 2001 From: leoliu Date: Sun, 12 Jul 2020 11:52:23 +0800 Subject: [PATCH] fix: Fix language switch error --- src/core/i18n.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/core/i18n.js b/src/core/i18n.js index f492db87938..a755742cdad 100644 --- a/src/core/i18n.js +++ b/src/core/i18n.js @@ -30,19 +30,12 @@ const getLocales = { const init = async () => { const supportLangs = globals.config.supportLangs.map(item => item.value) - const defaultLang = get(globals.user, 'lang') - if (defaultLang && cookie('lang') !== defaultLang) { - cookie('lang', defaultLang) + const userLang = get(globals.user, 'lang') || getBrowserLang() + if (userLang && cookie('lang') !== userLang) { + cookie('lang', userLang) } - let lang = cookie('lang') || getBrowserLang() - - if (!supportLangs.includes(lang)) { - lang = defaultLang - cookie('lang', lang) - } - - if (lang === 'zh') { + if (userLang === 'zh') { moment.locale('zh', { relativeTime: { s: '1秒',