From 1a37e5aab5761cfc5601a662c9476442772e3e03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B1=E7=9C=A0=E4=BB=AA=E5=BC=8F?= <854085467@qq.com> Date: Fri, 18 Dec 2020 00:24:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/css/admin.css | 13 +------- component/pear/modules/admin.js | 16 +-------- component/pear/modules/menu.js | 59 +++++++++++++++++---------------- config/pear.config.yml | 2 +- 4 files changed, 33 insertions(+), 57 deletions(-) diff --git a/admin/css/admin.css b/admin/css/admin.css index 3102ff5..f1ebf2f 100644 --- a/admin/css/admin.css +++ b/admin/css/admin.css @@ -17,23 +17,13 @@ border-bottom: 1px solid whitesmoke; } -/**适应移动端小型设备调整begin*/ - .pear-admin .layui-header .layui-nav { - padding: 0px; - } - - .pear-admin .layui-header .layui-nav .layui-nav-item a { - padding: 0 10px; - } - /*end*/ - .pear-admin .layui-header .layui-nav-img { width: 30px; height: 30px; } .pear-admin .layui-layout-control { - left: 80px; + left: 120px; position: absolute; } @@ -170,7 +160,6 @@ .collaspe { display: none !important; } - .pear-collasped-pe { display: inline-block !important; } diff --git a/component/pear/modules/admin.js b/component/pear/modules/admin.js index 083697f..106624b 100644 --- a/component/pear/modules/admin.js +++ b/component/pear/modules/admin.js @@ -290,7 +290,7 @@ layui.define(['table', 'jquery', 'element', 'yaml','form', 'tab', 'menu', 'frame layer.open({ type: 1, offset: 'r', - area: screen() < 2 ? ['93%', '100%'] : ['340px', '100%'], + area: ['340px', '100%'], title: false, shade: 0.1, closeBtn: 0, @@ -431,19 +431,5 @@ layui.define(['table', 'jquery', 'element', 'yaml','form', 'tab', 'menu', 'frame }); } - //获取当前窗口的宽度 - function screen() { - var width = $(window).width(); - if (width > 1200) { - return 3; //大屏幕 - } else if (width > 992) { - return 2; //中屏幕 - } else if (width > 768) { - return 1; //小屏幕 - } else { - return 0; //超小屏幕 - } - } - exports('admin', pearAdmin); }) diff --git a/component/pear/modules/menu.js b/component/pear/modules/menu.js index c909f9c..526ae49 100644 --- a/component/pear/modules/menu.js +++ b/component/pear/modules/menu.js @@ -358,41 +358,42 @@ layui.define(['table', 'jquery', 'element'], function(exports) { /** 二 级 悬 浮 菜 单*/ function isHoverMenu(b, option) { if (b) { - $("#" + option.elem + ".pear-nav-mini .layui-nav-item,#" + option.elem + ".pear-nav-mini dd").hover(function() { - $(this).children(".layui-nav-child").addClass("layui-nav-hover"); - var top = $(this).offset().top + 5; - var y = window.document.body.clientHeight; + $("#" + option.elem + ".pear-nav-mini .layui-nav-item,#" + option.elem + ".pear-nav-mini dd").hover(function(e) { + e.stopPropagation(); + var _this = $(this); + _this.siblings().find(".layui-nav-child") + .removeClass("layui-nav-hover").css({ + left: 0, + top: 0 + }); + _this.children(".layui-nav-child").addClass("layui-nav-hover"); + _this.closest('.layui-nav-item').data('time') && clearTimeout(_this.closest('.layui-nav-item').data('time')); var height = $(window).height(); - var topLength = $(this).offset().top; - var thisHeight = $(this).children(".layui-nav-child").height(); + var topLength = _this.offset().top; + var thisHeight = _this.children(".layui-nav-child").height(); if ((thisHeight + topLength) > height) { topLength = height - thisHeight - 10; } - if (!$(this).is(".layui-nav-item")) { - var left = $(this).offset().left + $(this).width() + 3; - $(this).children(".layui-nav-child").offset({ - left: left - }); - } else { - var left = $(this).offset().left + 63; - $(this).children(".layui-nav-child").offset({ - left: left - }); + var left = _this.offset().left + 60; + if (!_this.hasClass("layui-nav-item")) { + left = _this.offset().left + _this.width(); } - $(this).children(".layui-nav-child").offset({ - top: topLength + _this.children(".layui-nav-child").offset({ + top: topLength, + left: left + 3 }); - }, function() { - var that = $(this); - setTimeout(function() { - that.children(".layui-nav-child").removeClass("layui-nav-hover"); - that.children(".layui-nav-child").css({ - left: '0px' - }); - that.children(".layui-nav-child").css({ - top: '0px' - }); - }, 10); + }, function(e) { + e.stopPropagation(); + var _this = $(this); + _this.closest('.layui-nav-item').data('time', setTimeout(function() { + _this.closest('.layui-nav-item') + .find(".layui-nav-child") + .removeClass("layui-nav-hover") + .css({ + left: 0, + top: 0 + }); + }, 50)); }) } else { $("#" + option.elem + " .layui-nav-item").off('mouseenter').unbind('mouseleave'); diff --git a/config/pear.config.yml b/config/pear.config.yml index 7980c8f..e37dc15 100644 --- a/config/pear.config.yml +++ b/config/pear.config.yml @@ -12,7 +12,7 @@ menu: ## 是否同时只打开一个菜单目录 accordion: true ## 是否开启多系统菜单模式 - control: false + control: true ## 默认选中的菜单项 select: "10" ## 是否开启异步菜单,false 时 data 属性设置为菜单数据,false 时为 json 文件或后端接口