import _typeof from 'babel-runtime/helpers/typeof';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _createClass from 'babel-runtime/helpers/createClass';

var LocalStorage = function () {
  function LocalStorage(key) {
    _classCallCheck(this, LocalStorage);

    this.key = key;
    if (!window || !window.localStorage) {
      console.error('window.localStorage不存在');
    }
  }

  _createClass(LocalStorage, [{
    key: 'setValue',
    value: function setValue(value) {
      if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') {
        window.localStorage.setItem(this.key, JSON.stringify(value));
      } else {
        window.localStorage.setItem(this.key, value);
      }
    }
  }, {
    key: 'getValue',
    value: function getValue() {
      return window.localStorage.getItem(this.key);
    }
  }, {
    key: 'clearValue',
    value: function clearValue() {
      window.localStorage.removeItem(this.key);
    }
  }]);

  return LocalStorage;
}();

export default LocalStorage;