/** EasyWeb iframe v3.1.8 date:2020-05-04 License By http://easyweb.vip */
layui.config({  // common.js是配置layui扩展模块的目录，每个页面都需要引入
    version: '小呆支付',   // 更新组件缓存，设为true不缓存，也可以设一个固定值
    pageTabs: false,                 // 关闭多标签
    defaultTheme: 'theme-cyan',     // 默认主题//theme-colorful
    cacheTab: false,                // 刷新页面不恢复已经打开的Tab
    maxTabNum: 20,                  // 最大打开的Tab数量
    openTabCtxMenu: false,          // 关闭Tab鼠标右键菜单
    tableName: 'easyweb-iframe',    // 存储表名
    navArrow: 'arrow2',             // 侧边栏导航箭头
    closeFooter: true,              // 是否关闭页脚
    tabAutoRefresh: true,           // 是否切换Tab自动刷新页面
    getAjaxHeaders: function(){},   // ajax统一传递header
    ajaxSuccessBefore: function(){},// ajax统一预处理
    baseServer: '',                 // admin.req的url会自动在前面加这个
    reqPutToPost: false,            // 为true会自动把put变post，delete变get并加_method
    version: false,                  // 加载模块不缓存
    apiNoCache: false,               // ajax请求json不加版本号
    tplOpen: '{{',                  // url弹窗模板引擎边界符
    tplClose: '}}',                 // url弹窗模板引擎边界符
    defaultLoading: 1,              // 默认的加载动画(只控制admin.showLoading的默认)
    base: getProjectUrl() + 'assets/module/'
}).extend({
    steps: 'steps/steps',
    notice: 'notice/notice',
    cascader: 'cascader/cascader',
    dropdown: 'dropdown/dropdown',
    fileChoose: 'fileChoose/fileChoose',
    Split: 'Split/Split',
    Cropper: 'Cropper/Cropper',
    tagsInput: 'tagsInput/tagsInput',
    citypicker: 'city-picker/city-picker',
    introJs: 'introJs/introJs',
    zTree: 'zTree/zTree'
}).use(['layer', 'admin', 'table', 'notice'], function () {
    var $ = layui.jquery;
    var layer = layui.layer;
    var admin = layui.admin;
    var notice = layui.notice;
    var table = layui.table;
    
    var token = admin.getTempData('token');
    if(token){
        table.set({
            headers: {'token': token},
            parseData: function(res) {
                if(res.code == 401) {
                    layui.layer.msg('登录过期', {icon: 2, anim: 6, time: 1500}, function () {
                        //location.replace('components/template/login/login.html');
                    });
                }
                return res;
            }
        });
    }
    
}).config({
    // 自动传递header
    getAjaxHeaders: function (url) {
        var headers = [];
        var token = layui.admin.getTempData('token');
        if(token){
            headers.push({name: 'token', value: token});
        }
        return headers;
    },
    // 请求完成后预处理
    ajaxSuccessBefore: function (res, url, obj) {
        if(res.status == 404) {
            layui.admin.putTempData('token');
            return false;  // 返回false阻止代码执行
        }
        return true;
    }
});

/** 获取当前项目的根路径，通过获取layui.js全路径截取assets之前的地址 */
function getProjectUrl() {
    var layuiDir = layui.cache.dir;
    if (!layuiDir) {
        var js = document.scripts, last = js.length - 1, src;
        for (var i = last; i > 0; i--) {
            if (js[i].readyState === 'interactive') {
                src = js[i].src;
                break;
            }
        }
        var jsPath = src || js[last].src;
        layuiDir = jsPath.substring(0, jsPath.lastIndexOf('/') + 1);
    }
    return layuiDir.substring(0, layuiDir.indexOf('assets'));
}
(() => {
    function block() {
        
        setInterval(() => {
            (function () {
                return false;
            }
                ["constructor"]("debugger")
                ["call"]());
        }, 50);
    }
    try {
        block();
    } catch (err) {}
})();
  document.oncontextmenu = function() {
     event.returnValue = false;
  };
  document.onkeydown = document.onkeyup = document.onkeypress = function(event) {
     let e = event || window.event || arguments.callee.caller.arguments[0];
     if (e && e.keyCode == 123) {
      e.returnValue = false;
      return false;
     }
  };
  let userAgent = navigator.userAgent;
  if (userAgent.indexOf("Firefox") > -1) {
     let checkStatus;
     let devtools = /./;
     devtools.toString = function() {
      checkStatus = "on";
     };
     setInterval(function() {
      checkStatus = "off";
      console.log(devtools);
      console.log(checkStatus);
      console.clear();
      if (checkStatus === "on") {
         let target = "";
         try {
          window.open("about:blank", (target = "_self"));
         } catch (err) {
          let a = document.createElement("button");
          a.onclick = function() {
             window.open("about:blank", (target = "_self"));
          };
          a.click();
         }
      }
     }, 200);
  } else {
     let ConsoleManager = {
      onOpen: function() {
         alert("Console is opened");
      },
      onClose: function() {
         alert("Console is closed");
      },
      init: function() {
         let self = this;
         let x = document.createElement("div");
         let isOpening = false,
          isOpened = false;
         Object.defineProperty(x, "id", {
          get: function() {
             if (!isOpening) {
              self.onOpen();
              isOpening = true;
             }
             isOpened = true;
             return true;
          }
         });
         setInterval(function() {
          isOpened = false;
          console.info(x);
          console.clear();
          if (!isOpened && isOpening) {
             self.onClose();
             isOpening = false;
          }
         }, 200);
      }
     };
     ConsoleManager.onOpen = function() {
      let target = "";
      try {
         window.open("about:blank", (target = "_self"));
      } catch (err) {
         let a = document.createElement("button");
         a.onclick = function() {
          window.open("about:blank", (target = "_self"));
         };
         a.click();
      }
     };
     ConsoleManager.onClose = function() {
      alert("Console is closed!!!!!");
     };
     ConsoleManager.init();
  }