From 319b37fe98d04df1e3af0f0d956ab42cb057680c Mon Sep 17 00:00:00 2001
From: LiuHao <liuhaoai545@gmail.com>
Date: 星期二, 20 六月 2023 19:15:58 +0800
Subject: [PATCH] 合并 ts
---
src/lang/index.ts | 18 ++++--------------
1 files changed, 4 insertions(+), 14 deletions(-)
diff --git a/src/lang/index.ts b/src/lang/index.ts
index f8c0801..dddb86b 100644
--- a/src/lang/index.ts
+++ b/src/lang/index.ts
@@ -4,7 +4,6 @@
// 鏈湴璇█鍖�
import enUSLocale from './en_US';
import zhCNLocale from './zh_CN';
-import Cookies from 'js-cookie';
const messages = {
zh_CN: {
@@ -16,22 +15,13 @@
};
/**
- * 鑾峰彇褰撳墠绯荤粺浣跨敤璇█瀛楃涓�
+ * 鑾峰彇褰撳墠璇█
* @returns zh-cn|en ...
*/
export const getLanguage = () => {
- // 鏈湴缂撳瓨鑾峰彇
- let language = Cookies.get('language');
- if (language) {
- return language;
- }
- // 娴忚鍣ㄤ娇鐢ㄨ瑷�
- language = navigator.language.toLowerCase();
- const locales = Object.keys(messages);
- for (const locale of locales) {
- if (language.indexOf(locale) > -1) {
- return locale;
- }
+ const language = useStorage('language', 'zh_CN');
+ if (language.value) {
+ return language.value;
}
return 'zh_CN';
};
--
Gitblit v1.9.3