提交 | 用户 | 时间
|
a57dc2
|
1 |
const DRAWING_ITEMS = 'drawingItems' |
W |
2 |
const DRAWING_ITEMS_VERSION = '1.2' |
|
3 |
const DRAWING_ITEMS_VERSION_KEY = 'DRAWING_ITEMS_VERSION' |
|
4 |
const DRAWING_ID = 'idGlobal' |
|
5 |
const TREE_NODE_ID = 'treeNodeId' |
|
6 |
const FORM_CONF = 'formConf' |
|
7 |
|
|
8 |
export function getDrawingList() { |
|
9 |
// 加入缓存版本的概念,保证缓存数据与程序匹配 |
|
10 |
const version = localStorage.getItem(DRAWING_ITEMS_VERSION_KEY) |
|
11 |
if (version !== DRAWING_ITEMS_VERSION) { |
|
12 |
localStorage.setItem(DRAWING_ITEMS_VERSION_KEY, DRAWING_ITEMS_VERSION) |
|
13 |
saveDrawingList([]) |
|
14 |
return null |
|
15 |
} |
|
16 |
|
|
17 |
const str = localStorage.getItem(DRAWING_ITEMS) |
|
18 |
if (str) return JSON.parse(str) |
|
19 |
return null |
|
20 |
} |
|
21 |
|
|
22 |
export function saveDrawingList(list) { |
|
23 |
localStorage.setItem(DRAWING_ITEMS, JSON.stringify(list)) |
|
24 |
} |
|
25 |
|
|
26 |
export function getIdGlobal() { |
|
27 |
const str = localStorage.getItem(DRAWING_ID) |
|
28 |
if (str) return parseInt(str, 10) |
|
29 |
return 100 |
|
30 |
} |
|
31 |
|
|
32 |
export function saveIdGlobal(id) { |
|
33 |
localStorage.setItem(DRAWING_ID, `${id}`) |
|
34 |
} |
|
35 |
|
|
36 |
export function getTreeNodeId() { |
|
37 |
const str = localStorage.getItem(TREE_NODE_ID) |
|
38 |
if (str) return parseInt(str, 10) |
|
39 |
return 100 |
|
40 |
} |
|
41 |
|
|
42 |
export function saveTreeNodeId(id) { |
|
43 |
localStorage.setItem(TREE_NODE_ID, `${id}`) |
|
44 |
} |
|
45 |
|
|
46 |
export function getFormConf() { |
|
47 |
const str = localStorage.getItem(FORM_CONF) |
|
48 |
if (str) return JSON.parse(str) |
|
49 |
return null |
|
50 |
} |
|
51 |
|
|
52 |
export function saveFormConf(obj) { |
|
53 |
localStorage.setItem(FORM_CONF, JSON.stringify(obj)) |
|
54 |
} |