@lambo-design/shared 1.0.0-beta.286 → 1.0.0-beta.288
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/config.js +3 -3
- package/config/locale.js +59 -0
- package/package.json +1 -1
package/config/config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {getLocale} from './locale'
|
|
2
2
|
|
|
3
3
|
let config = {
|
|
4
4
|
title: 'LamboDesign',
|
|
@@ -14,7 +14,7 @@ let config = {
|
|
|
14
14
|
"query": {},
|
|
15
15
|
"meta": {
|
|
16
16
|
"hideInMenu": true,
|
|
17
|
-
"title":
|
|
17
|
+
"title": getLocale('config.home'),
|
|
18
18
|
"icon": "md-home",
|
|
19
19
|
"appId": "home"
|
|
20
20
|
},
|
|
@@ -30,7 +30,7 @@ let config = {
|
|
|
30
30
|
immServerContext: '/imarket-manage-server',
|
|
31
31
|
mobileWidth:375,
|
|
32
32
|
mobileHeight:667,
|
|
33
|
-
errorMessage:
|
|
33
|
+
errorMessage: getLocale('config.error-message'),
|
|
34
34
|
nHomeRouteName: "home",
|
|
35
35
|
showMenus:false,
|
|
36
36
|
ecagiLamboPagingTableAppId: '',
|
package/config/locale.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import lamboZh from '@lambo-design/shared/utils/locale/zh-CN';
|
|
2
|
+
import lamboEn from '@lambo-design/shared/utils/locale/en-US';
|
|
3
|
+
|
|
4
|
+
export const getLocale = (path) => {
|
|
5
|
+
let paths = path.split('.');
|
|
6
|
+
let data = lamboZh;
|
|
7
|
+
let lang = 'zh';
|
|
8
|
+
if (Cookie.get('lambo_lang_code')) {
|
|
9
|
+
lang = Cookie.get('lambo_lang_code')
|
|
10
|
+
}
|
|
11
|
+
if (lang === 'zh') {
|
|
12
|
+
data = lamboZh
|
|
13
|
+
} else if (lang === 'en') {
|
|
14
|
+
data = lamboEn;
|
|
15
|
+
}
|
|
16
|
+
return getDataByKey(data, paths, 0);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const getDataByKey = (data,keys,index) => {
|
|
20
|
+
let key = keys[index];
|
|
21
|
+
index++;
|
|
22
|
+
if (data && key && data[key]) {
|
|
23
|
+
return getDataByKey(data[key],keys,index);
|
|
24
|
+
}
|
|
25
|
+
return '';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const Cookie = {
|
|
29
|
+
set: function (key, value, exdays) {
|
|
30
|
+
//校验Key, key中不能有等号【=】
|
|
31
|
+
if (key.indexOf('=') !== -1) {
|
|
32
|
+
throw new Error('Cookie不支持key中使用等号【=】, key:' + key);
|
|
33
|
+
}
|
|
34
|
+
let exdate = new Date(); // 获取时间
|
|
35
|
+
exdate.setTime(exdate.getTime() + 24 * 60 * 60 * 1000 * exdays); // 保存的天数
|
|
36
|
+
// 字符串拼接cookie
|
|
37
|
+
// eslint-disable-next-line camelcase
|
|
38
|
+
window.document.cookie = key + '=' + value + ';path=/;expires=' + exdate.toGMTString();
|
|
39
|
+
},
|
|
40
|
+
get: function (key) {
|
|
41
|
+
if (document.cookie.length > 0) {
|
|
42
|
+
// 这里显示的格式需要切割一下自己可输出看下
|
|
43
|
+
var arr = document.cookie.split('; ');
|
|
44
|
+
for (let i = 0; i < arr.length; i++) {
|
|
45
|
+
let arr2 = arr[i].split('='); // 再次切割
|
|
46
|
+
// 判断查找相对应的值
|
|
47
|
+
if (arr2[0] === key) {
|
|
48
|
+
var value = arr2[1];
|
|
49
|
+
for (let j = 2; j < arr2.length; j++) {
|
|
50
|
+
value += '=' + arr2[j];
|
|
51
|
+
}
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export {Cookie}
|