'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _typeof2 = require('babel-runtime/helpers/typeof');

var _typeof3 = _interopRequireDefault(_typeof2);

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var LocalStorage = function () {
  function LocalStorage(key) {
    (0, _classCallCheck3['default'])(this, LocalStorage);

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

  (0, _createClass3['default'])(LocalStorage, [{
    key: 'setValue',
    value: function setValue(value) {
      if ((typeof value === 'undefined' ? 'undefined' : (0, _typeof3['default'])(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;
}();

exports['default'] = LocalStorage;