@yelon/util 16.0.3 → 16.0.4
Sign up to get free protection for your applications and to get access to all the features.
@@ -8,10 +8,17 @@ export const YZ_TENANT_KEY = '_yz_tenant';
|
|
8
8
|
export const YZ_LANGS_KEY = '_yz_langs';
|
9
9
|
export const YZ_LANG_KEY = '_yz_lang';
|
10
10
|
function get(key) {
|
11
|
+
if (key === YZ_HEADER_TYPE_KEY) {
|
12
|
+
return localStorage.getItem(key);
|
13
|
+
}
|
11
14
|
const item = localStorage.getItem(key);
|
12
15
|
return item ? JSON.parse(item) : null;
|
13
16
|
}
|
14
17
|
function set(key, data) {
|
18
|
+
if (key === YZ_HEADER_TYPE_KEY) {
|
19
|
+
localStorage.setItem(YZ_HEADER_TYPE_KEY, data);
|
20
|
+
return;
|
21
|
+
}
|
15
22
|
localStorage.setItem(key, JSON.stringify(data));
|
16
23
|
}
|
17
24
|
export function useLocalStorageUser() {
|
@@ -59,4 +66,4 @@ export function useLocalStorageLang() {
|
|
59
66
|
const getFn = (key) => get(`${YZ_LANG_KEY}_${key}`);
|
60
67
|
return [setFn, getFn];
|
61
68
|
}
|
62
|
-
//# sourceMappingURL=data:application/json;base64,
|
69
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9jYWxTdG9yYWdlVXRpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy91dGlsL21jYWNoZS9sb2NhbFN0b3JhZ2VVdGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQSxNQUFNLENBQUMsTUFBTSxXQUFXLEdBQUcsVUFBVSxDQUFDO0FBQ3RDLE1BQU0sQ0FBQyxNQUFNLG1CQUFtQixHQUFHLGtCQUFrQixDQUFDO0FBQ3RELE1BQU0sQ0FBQyxNQUFNLGNBQWMsR0FBRyxhQUFhLENBQUM7QUFDNUMsTUFBTSxDQUFDLE1BQU0sYUFBYSxHQUFHLFlBQVks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+IHZvaWQsIChrZXk6IHN0cmluZykgPT4gUmVjb3JkPHN0cmluZywgdW5rbm93bj4gfCBudWxsXSB7XG4gICAgY29uc3Qgc2V0Rm4gPSAoa2V5OiBzdHJpbmcsIGRhdGE6IFJlY29yZDxzdHJpbmcsIHVua25vd24+KSA9PiBzZXQoYCR7WVpfTEFOR19LRVl9XyR7a2V5fWAsIGRhdGEpO1xuICAgIGNvbnN0IGdldEZuID0gKGtleTogc3RyaW5nKTogUmVjb3JkPHN0cmluZywgdW5rbm93bj4gfCBudWxsID0+IGdldDxSZWNvcmQ8c3RyaW5nLCB1bmtub3duPj4oYCR7WVpfTEFOR19LRVl9XyR7a2V5fWApO1xuICAgIHJldHVybiBbc2V0Rm4sIGdldEZuXTtcbn1cblxuIl19
|
package/fesm2022/mcache.mjs
CHANGED
@@ -8,10 +8,17 @@ const YZ_TENANT_KEY = '_yz_tenant';
|
|
8
8
|
const YZ_LANGS_KEY = '_yz_langs';
|
9
9
|
const YZ_LANG_KEY = '_yz_lang';
|
10
10
|
function get(key) {
|
11
|
+
if (key === YZ_HEADER_TYPE_KEY) {
|
12
|
+
return localStorage.getItem(key);
|
13
|
+
}
|
11
14
|
const item = localStorage.getItem(key);
|
12
15
|
return item ? JSON.parse(item) : null;
|
13
16
|
}
|
14
17
|
function set(key, data) {
|
18
|
+
if (key === YZ_HEADER_TYPE_KEY) {
|
19
|
+
localStorage.setItem(YZ_HEADER_TYPE_KEY, data);
|
20
|
+
return;
|
21
|
+
}
|
15
22
|
localStorage.setItem(key, JSON.stringify(data));
|
16
23
|
}
|
17
24
|
function useLocalStorageUser() {
|
package/fesm2022/mcache.mjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"mcache.mjs","sources":["../../../../packages/util/mcache/localStorageUtils.ts","../../../../packages/util/mcache/mcache.ts"],"sourcesContent":["import {LayoutBasicAside, NavType, YunzaiNavTopic, YunzaiProjectInfo, YunzaiUser} from \"@yelon/util/mtypes\";\n\nexport const YZ_USER_KEY = '_yz_user';\nexport const YZ_PROJECT_INFO_KEY = '_yz_project_info';\nexport const YZ_CURRENT_KEY = '_yz_current';\nexport const YZ_HEADER_KEY = '_yz_header';\nexport const YZ_HEADER_TYPE_KEY = '_yz_header_type';\nexport const YZ_DEFAULT_ROUTE_KEY = '_yz_default_route';\nexport const YZ_TENANT_KEY = '_yz_tenant';\nexport const YZ_LANGS_KEY = '_yz_langs';\nexport const YZ_LANG_KEY = '_yz_lang';\n\nfunction get<T>(key: string): T | null {\n
|
1
|
+
{"version":3,"file":"mcache.mjs","sources":["../../../../packages/util/mcache/localStorageUtils.ts","../../../../packages/util/mcache/mcache.ts"],"sourcesContent":["import {LayoutBasicAside, NavType, YunzaiNavTopic, YunzaiProjectInfo, YunzaiUser} from \"@yelon/util/mtypes\";\n\nexport const YZ_USER_KEY = '_yz_user';\nexport const YZ_PROJECT_INFO_KEY = '_yz_project_info';\nexport const YZ_CURRENT_KEY = '_yz_current';\nexport const YZ_HEADER_KEY = '_yz_header';\nexport const YZ_HEADER_TYPE_KEY = '_yz_header_type';\nexport const YZ_DEFAULT_ROUTE_KEY = '_yz_default_route';\nexport const YZ_TENANT_KEY = '_yz_tenant';\nexport const YZ_LANGS_KEY = '_yz_langs';\nexport const YZ_LANG_KEY = '_yz_lang';\n\nfunction get<T>(key: string): T | null {\n if (key === YZ_HEADER_TYPE_KEY) {\n return localStorage.getItem(key) as any\n }\n const item = localStorage.getItem(key);\n return item ? JSON.parse(item) : null;\n}\n\nfunction set<T>(key: string, data: T): void {\n if (key === YZ_HEADER_TYPE_KEY) {\n localStorage.setItem(YZ_HEADER_TYPE_KEY, data as string)\n return\n }\n localStorage.setItem(key, JSON.stringify(data));\n}\n\ntype returnSet<T> = (data: T) => void;\ntype returnGet<T> = () => T | null;\n\nexport function useLocalStorageUser(): [returnSet<YunzaiUser>, returnGet<YunzaiUser>] {\n const setFn: returnSet<YunzaiUser> = (user) => set(YZ_USER_KEY, user);\n const getFn: returnGet<YunzaiUser> = () => get<YunzaiUser>(YZ_USER_KEY);\n return [setFn, getFn];\n}\n\nexport function useLocalStorageProjectInfo(): [returnSet<YunzaiProjectInfo>, returnGet<YunzaiProjectInfo>] {\n const setFn: returnSet<YunzaiProjectInfo> = (data) => set(YZ_PROJECT_INFO_KEY, data);\n const getFn: returnGet<YunzaiProjectInfo> = () => get<YunzaiProjectInfo>(YZ_PROJECT_INFO_KEY);\n return [setFn, getFn];\n}\n\nexport function useLocalStorageCurrent(): [returnSet<LayoutBasicAside>, returnGet<LayoutBasicAside>] {\n const setFn: returnSet<LayoutBasicAside> = (data) => set(YZ_CURRENT_KEY, data);\n const getFn: returnGet<LayoutBasicAside> = () => get<LayoutBasicAside>(YZ_CURRENT_KEY);\n return [setFn, getFn];\n}\n\nexport function useLocalStorageHeaderType(): [returnSet<NavType>, returnGet<NavType>] {\n const setFn: returnSet<NavType> = (data) => set(YZ_HEADER_TYPE_KEY, data);\n const getFn: returnGet<NavType> = () => get<NavType>(YZ_HEADER_TYPE_KEY);\n return [setFn, getFn];\n}\n\nexport function useLocalStorageHeader(): [returnSet<YunzaiNavTopic[]>, returnGet<YunzaiNavTopic[]>] {\n const setFn: returnSet<YunzaiNavTopic[]> = (data) => set(YZ_HEADER_KEY, data);\n const getFn: returnGet<YunzaiNavTopic[]> = () => get<YunzaiNavTopic[]>(YZ_HEADER_KEY);\n return [setFn, getFn];\n}\n\nexport function useLocalStorageDefaultRoute(): [returnSet<string>, returnGet<string>] {\n const setFn: returnSet<string> = (data) => set(YZ_DEFAULT_ROUTE_KEY, data);\n const getFn: returnGet<string> = () => get<string>(YZ_DEFAULT_ROUTE_KEY);\n return [setFn, getFn];\n}\n\nexport function useLocalStorageTenant(): [returnSet<string>, returnGet<string>] {\n const setFn: returnSet<string> = (data) => set(YZ_TENANT_KEY, data);\n const getFn: returnGet<string> = () => get<string>(YZ_TENANT_KEY);\n return [setFn, getFn];\n}\n\ninterface Y18NType {\n code: string;\n text: string;\n abbr: string;\n icon?: string;\n}\n\nexport function useLocalStorageLangs(): [returnSet<Y18NType[]>, returnGet<Y18NType[]>] {\n const setFn: returnSet<Y18NType[]> = (data) => set(YZ_LANGS_KEY, data);\n const getFn: returnGet<Y18NType[]> = () => get<Y18NType[]>(YZ_LANGS_KEY);\n return [setFn, getFn];\n}\n\nexport function useLocalStorageLang(): [(key: string, data: Record<string, unknown>) => void, (key: string) => Record<string, unknown> | null] {\n const setFn = (key: string, data: Record<string, unknown>) => set(`${YZ_LANG_KEY}_${key}`, data);\n const getFn = (key: string): Record<string, unknown> | null => get<Record<string, unknown>>(`${YZ_LANG_KEY}_${key}`);\n return [setFn, getFn];\n}\n\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"AAEO,MAAM,WAAW,GAAG,WAAW;AAC/B,MAAM,mBAAmB,GAAG,mBAAmB;AAC/C,MAAM,cAAc,GAAG,cAAc;AACrC,MAAM,aAAa,GAAG,aAAa;AACnC,MAAM,kBAAkB,GAAG,kBAAkB;AAC7C,MAAM,oBAAoB,GAAG,oBAAoB;AACjD,MAAM,aAAa,GAAG,aAAa;AACnC,MAAM,YAAY,GAAG,YAAY;AACjC,MAAM,WAAW,GAAG,WAAW;AAEtC,SAAS,GAAG,CAAI,GAAW,EAAA;IACvB,IAAI,GAAG,KAAK,kBAAkB,EAAE;AAC5B,QAAA,OAAO,YAAY,CAAC,OAAO,CAAC,GAAG,CAAQ,CAAA;AAC1C,KAAA;IACD,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AACvC,IAAA,OAAO,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAC1C,CAAC;AAED,SAAS,GAAG,CAAI,GAAW,EAAE,IAAO,EAAA;IAChC,IAAI,GAAG,KAAK,kBAAkB,EAAE;AAC5B,QAAA,YAAY,CAAC,OAAO,CAAC,kBAAkB,EAAE,IAAc,CAAC,CAAA;QAC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GED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@yelon/util",
|
3
|
-
"version": "16.0.
|
3
|
+
"version": "16.0.4",
|
4
4
|
"author": "devcui<devcui@outlook.com>",
|
5
5
|
"license": "MIT",
|
6
6
|
"repository": {
|
@@ -47,11 +47,11 @@
|
|
47
47
|
"esm": "./esm2022/array/array.mjs",
|
48
48
|
"default": "./fesm2022/array.mjs"
|
49
49
|
},
|
50
|
-
"./
|
51
|
-
"types": "./
|
52
|
-
"esm2022": "./esm2022/
|
53
|
-
"esm": "./esm2022/
|
54
|
-
"default": "./fesm2022/
|
50
|
+
"./browser": {
|
51
|
+
"types": "./browser/index.d.ts",
|
52
|
+
"esm2022": "./esm2022/browser/browser.mjs",
|
53
|
+
"esm": "./esm2022/browser/browser.mjs",
|
54
|
+
"default": "./fesm2022/browser.mjs"
|
55
55
|
},
|
56
56
|
"./config": {
|
57
57
|
"types": "./config/index.d.ts",
|
@@ -59,11 +59,11 @@
|
|
59
59
|
"esm": "./esm2022/config/config.mjs",
|
60
60
|
"default": "./fesm2022/config.mjs"
|
61
61
|
},
|
62
|
-
"./
|
63
|
-
"types": "./
|
64
|
-
"esm2022": "./esm2022/
|
65
|
-
"esm": "./esm2022/
|
66
|
-
"default": "./fesm2022/
|
62
|
+
"./date-time": {
|
63
|
+
"types": "./date-time/index.d.ts",
|
64
|
+
"esm2022": "./esm2022/date-time/date-time.mjs",
|
65
|
+
"esm": "./esm2022/date-time/date-time.mjs",
|
66
|
+
"default": "./fesm2022/date-time.mjs"
|
67
67
|
},
|
68
68
|
"./decorator": {
|
69
69
|
"types": "./decorator/index.d.ts",
|