MCPcopy
hub / github.com/baidu/amis / loadClientData

Function loadClientData

packages/amis-core/src/globalVarClientHandler.ts:8–26  ·  view source on GitHub ↗
(key: string, variables: Array<GlobalVariableItem>)

Source from the content-addressed store, hash-verified

6} from './globalVar';
7
8function loadClientData(key: string, variables: Array<GlobalVariableItem>) {
9 const str = localStorage.getItem(key);
10 let data: any = {};
11
12 try {
13 data = JSON.parse(str || '{}');
14 } catch (e) {
15 console.error(`parse localstorage "${key} error"`, e);
16 }
17
18 let filterData: any = {};
19 variables.forEach(item => {
20 if (data.hasOwnProperty(item.key)) {
21 filterData[item.key] = data[item.key];
22 }
23 });
24
25 return filterData;
26}
27
28function saveClientData(
29 key: string,

Callers 2

bulkClientGetterFunction · 0.85
pageBulkClientGetterFunction · 0.85

Calls 3

forEachMethod · 0.80
parseMethod · 0.65
errorMethod · 0.45

Tested by

no test coverage detected