'use strict';

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

var vConsole_config = require('../config.js');

function getCurrentState() {
  var value = window.sessionStorage.getItem(vConsole_config.V_CONSOLE_NO_DELAY.KEY);
  if (value === vConsole_config.V_CONSOLE_NO_DELAY.VALUE) {
    return '已去掉延迟';
  }
  return '默认';
}
function initLoadDelayPlugin() {
  var plugin = new VConsole.VConsolePlugin('loadDelay', 'vConsole加载延迟');
  var html = "<div class=\"".concat(vConsole_config.V_CONSOLE_DOM.WRAP, "\">\n  <div class=\"").concat(vConsole_config.V_CONSOLE_DOM.LINE, "\">\u5F53\u524D\u72B6\u6001\uFF1A").concat(getCurrentState(), "</div>\n    </div>");
  plugin.on('renderTab', function (callback) {
    callback(html);
  });
  var btnList = [];
  btnList.push({
    name: '去除延迟',
    global: false,
    onClick: function onClick() {
      sessionStorage.setItem(vConsole_config.V_CONSOLE_NO_DELAY.KEY, vConsole_config.V_CONSOLE_NO_DELAY.VALUE);
      console.log('已设置去除延迟，即将刷新页面......');
      setTimeout(function () {
        location.reload();
      }, 1000);
    }
  });
  btnList.push({
    name: '恢复延迟',
    global: false,
    onClick: function onClick() {
      sessionStorage.removeItem(vConsole_config.V_CONSOLE_NO_DELAY.KEY);
      console.log('已设置恢复延迟，即将刷新页面......');
      setTimeout(function () {
        location.reload();
      }, 1000);
    }
  });
  btnList.push({
    name: '刷新页面',
    global: false,
    onClick: function onClick() {
      window.location.reload();
    }
  });
  plugin.on('addTool', function (callback) {
    callback(btnList);
  });
  return plugin;
}

exports.initLoadDelayPlugin = initLoadDelayPlugin;
