tremble 3 anni fa
parent
commit
82f4897b20
2 ha cambiato i file con 20 aggiunte e 19 eliminazioni
  1. 20 0
      src/components/Information/View.Mobile.vue
  2. 0 19
      src/i18n/index.js

+ 20 - 0
src/components/Information/View.Mobile.vue

@@ -135,7 +135,18 @@ import i18n, { getLocale, setI18nLanguage, useI18n, loadLocaleMessages } from "@
 const store = useStore();
 
 const { t } = useI18n({ useScope: "global" });
+let getUrl = (href, queryArr) => {
+  queryArr.forEach((item) => {
+    if (!browser.hasURLParam(item.key)) {
+      let ttt = href.split("index.html?");
+      href = `${ttt[0]}index.html?${item.key}=${item.val}&${ttt[1]}`;
+    } else {
+      href = browser.replaceQueryString(href, item.key, item.val);
+    }
+  });
 
+  return href;
+};
 let share_url = browser.getURLParam("share_url");
 if (share_url) {
   share_url = decodeURIComponent(share_url);
@@ -292,6 +303,15 @@ const onMenuClick = (name) => {
       store.commit("SetPlayerOptions", {
         lang: name,
       });
+
+      let tmp = getUrl(window.location.href, [
+        {
+          key: "lang",
+          val: name,
+        },
+      ]);
+      console.log(tmp);
+      history.replaceState(null, null, tmp);
     });
   });
 };

+ 0 - 19
src/i18n/index.js

@@ -4,18 +4,7 @@ import browser from '@/utils/browser'
 
 export { useI18n }
 export const SUPPORT_LOCALES = ['zh_CN', 'en', 'zh_HK']
-let getUrl = (href, queryArr) => {
-    queryArr.forEach((item) => {
-        if (!browser.hasURLParam(item.key)) {
-            let ttt = href.split("index.html?");
-            href = `${ttt[0]}index.html?${item.key}=${item.val}&${ttt[1]}`;
-        } else {
-            href = browser.replaceQueryString(href, item.key, item.val);
-        }
-    });
 
-    return href;
-};
 
 export function getLocale() {
     let lang = browser.getURLParam('lang')
@@ -56,14 +45,6 @@ export function setI18nLanguage(i18n, locale) {
      * axios.defaults.headers.common['Accept-Language'] = locale
      */
 
-    let tmp = getUrl(window.location.href, [
-        {
-            key: "lang",
-            val: locale,
-        },
-    ]);
-    history.replaceState(null, null, tmp);
-
     document.querySelector('html').setAttribute('lang', locale)
 }