forked from topfullstack/adminify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelper.js
More file actions
44 lines (40 loc) · 816 Bytes
/
Copy pathhelper.js
File metadata and controls
44 lines (40 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import Vue from 'vue'
import inflector from 'i'
const storage = window.localStorage
let helper = {}
/**
* string processor
*/
helper.i = inflector()
/**
* localStorage
*/
helper.ls = {
set (key, value) {
value = JSON.stringify(value)
storage.setItem(key, value)
},
get (key, defaultValue) {
let value = storage.getItem(key, value)
if (value === null || value === 'undefined' || value === '') {
value = defaultValue
} else {
value = JSON.parse(value)
}
return value
}
}
/**
* a wrapper for helper.ls
*/
helper.store = (key, value) => {
if (arguments.length < 2) {
return helper.ls.get(key)
} else {
return helper.ls.set(key, value)
}
}
Vue.directive('back', (el, binding) => {
el.onclick = () => window.history.go(-1)
})
export default helper