!function (win, doc) {
  var d = doc.documentElement;
  function change() {
    d.style.fontSize = d.clientWidth / 10 + 'px';
  }
  win.addEventListener('resize', change, false);
  change();
}(window, document);
layui.use(["layer", "element"], function () {
  var $ = layui.$,
    layer = layui.layer,
    element = layui.element; $(".main-tree .left-menu").on("click", function (e) {
      e.stopPropagation();
      var src = $(this).attr("lay-href");
      var title = $(this).attr("lay-title");
      $('.left-menu').removeClass("layui-this");
      $(this).addClass("layui-this");
      iframeToHref(src);
    });
  $(".left-fold-box").on("click", function (e) {
    e.stopPropagation();
    $(".left-side").hide();
    $(".layui-body").addClass("left-0").removeClass("left-230");
    var iframe = document.getElementById('iframe');
    var innerDoc = (iframe.contentDocument)
      ? iframe.contentDocument
      : iframe.contentWindow.document;
    innerDoc.querySelector("#rightFold > .logo").classList.remove('display-none');
    innerDoc.querySelector("#rightFold > .unfold").classList.remove('display-none');
  });
  $(".right-fold-box .back-url").on("click", function () {
    if ($(this).attr("lay-href")) {
      iframeToHref($(this).attr("lay-href"));
    }
  });
  // 子菜单展开收缩
  $(".menu-box").on('click', ".open-icon", function (e) {
    e.stopPropagation();
    $(this).removeClass('open-icon');
    $(this).addClass('close-icon');
    $(this).parent().siblings().addClass("display-none");
  });
  $(".menu-box").on('click', ".close-icon", function (e) {
    e.stopPropagation();
    $(this).removeClass('close-icon');
    $(this).addClass('open-icon');
    $(this).parent().siblings().removeClass("display-none");
  });

  var leftMenuChange = function () {
    var iframe = document.getElementById('iframe');
    var innerDoc = (iframe.contentDocument)
      ? iframe.contentDocument
      : iframe.contentWindow.document;
    innerDoc.querySelector("#rightFold > .logo").classList.add('display-none');
    innerDoc.querySelector("#rightFold > .unfold").classList.add('display-none');
    $(".layui-body").addClass("left-230").removeClass("left-0");
    $(".left-side").show();
  }
  var rightMenuChange = function () {
    var iframe = document.getElementById('iframe');
    var innerDoc = (iframe.contentDocument)
      ? iframe.contentDocument
      : iframe.contentWindow.document;
    innerDoc.querySelector("#rightFold > .logo").classList.remove('display-none');
    innerDoc.querySelector("#rightFold > .unfold").classList.remove('display-none');
    $(".layui-body").removeClass("left-230").addClass("left-0");
    $(".left-side").hide();
  }
  var iframeToHref = function (url) {
    var iframe = document.getElementById("iframe");
    iframe.src = url;
  };
  var routerPush = function ({ url, breadcrumb }) {
    iframeToHref(url);
  };

  window.routerPush = routerPush;
  window.leftMenuChange = leftMenuChange;
  window.rightMenuChange = rightMenuChange;
});
