mock storge

This commit is contained in:
zuiidea
2016-12-13 09:31:29 +08:00
parent ef61551341
commit ad0050ee54
4 changed files with 20 additions and 39 deletions
+2
View File
@@ -2,6 +2,7 @@ import config from './config'
import menu from './menu'
import request from './request'
import classnames from 'classnames'
import mockStorge from './mockStorge'
import {color} from './theme'
require('./mock.js')
@@ -23,4 +24,5 @@ module.exports = {
request,
color,
classnames,
mockStorge,
}
+11
View File
@@ -0,0 +1,11 @@
const Mock = require('mockjs')
const Watch = require("watchjs")
export default function mockStorge(name, defaultValue) {
let key = 'antdAdmin' + name
global[key] = localStorage.getItem(key)
? JSON.parse(localStorage.getItem(key))
: defaultValue
!localStorage.getItem(key)&&localStorage.setItem(key, JSON.stringify(global[key]))
}