From 46b8940f0eb2035e4b42b6443aca9c3f0b3e4c74 Mon Sep 17 00:00:00 2001 From: panmeicheng <350012167@qq.com> Date: Wed, 28 Nov 2018 21:53:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B1=95=E7=A4=BA=E5=87=BA=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=A0=8F=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/static/ruoyi/index.js | 205 +++++++---- .../src/main/resources/templates/index.html | 328 +++++++++++++++++- 2 files changed, 462 insertions(+), 71 deletions(-) diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/index.js b/ruoyi-admin/src/main/resources/static/ruoyi/index.js index 52e96fa33..4867c6ede 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/index.js +++ b/ruoyi-admin/src/main/resources/static/ruoyi/index.js @@ -1,12 +1,12 @@ /** * 菜单处理 */ -$(function() { +$(function () { // MetsiMenu $('#side-menu').metisMenu(); //固定菜单栏 - $(function() { + $(function () { $('.sidebar-collapse').slimScroll({ height: '100%', railOpacity: 0.9, @@ -15,17 +15,17 @@ $(function() { }); // 菜单切换 - $('.navbar-minimalize').click(function() { + $('.navbar-minimalize').click(function () { $("body").toggleClass("mini-navbar"); SmoothlyMenu(); }); - $('#side-menu>li').click(function() { + $('#side-menu>li').click(function () { if ($('body').hasClass('mini-navbar')) { NavToggle(); } }); - $('#side-menu>li li a').click(function() { + $('#side-menu>li li a').click(function () { if ($(window).width() < 769) { NavToggle(); } @@ -40,14 +40,83 @@ $(function() { }); -$(window).bind("load resize", -function() { - if ($(this).width() < 769) { - $('body').addClass('mini-navbar'); - $('.navbar-static-side').fadeIn(); +function localStorageSupport() { + return "localStorage" in window && null !== window.localStorage +} + +/*主题框框相关*/ +$(document).ready(function () { + function e() { + var e = $("body > #wrapper").height() - 61; + $(".sidebard-panel").css("min-height", e + "px") + } + + $("#side-menu").metisMenu(), $(".right-sidebar-toggle").click(function () { + $("#right-sidebar").toggleClass("sidebar-open") + }), $(".sidebar-container").slimScroll({ + height: "100%", + railOpacity: .4, + wheelStep: 10 + }), $(".open-small-chat").click(function () { + $(this).children().toggleClass("fa-comments").toggleClass("fa-remove"), $(".small-chat-box").toggleClass("active") + }), $(".small-chat-box .content").slimScroll({ + height: "234px", + railOpacity: .4 + }), $(".check-link").click(function () { + var e = $(this).find("i"), a = $(this).next("span"); + return e.toggleClass("fa-check-square").toggleClass("fa-square-o"), a.toggleClass("todo-completed"), !1 + }), $(function () { + $(".sidebar-collapse").slimScroll({height: "100%", railOpacity: .9, alwaysVisible: !1}) + }), $(".navbar-minimalize").click(function () { + $("body").toggleClass("mini-navbar"), SmoothlyMenu() + }), e(), $(window).bind("load resize click scroll", function () { + $("body").hasClass("body-small") || e() + }), $(window).scroll(function () { + $(window).scrollTop() > 0 && !$("body").hasClass("fixed-nav") ? $("#right-sidebar").addClass("sidebar-top") : $("#right-sidebar").removeClass("sidebar-top") + }), $(".full-height-scroll").slimScroll({height: "100%"}), $("#side-menu>li").click(function () { + $("body").hasClass("mini-navbar") && NavToggle() + }), $("#side-menu>li li a").click(function () { + $(window).width() < 769 && NavToggle() + }), $(".nav-close").click(NavToggle), /(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent) && $("#content-main").css("overflow-y", "auto") +}) + +$(function () { + if ($("#fixednavbar").click(function () { + $("#fixednavbar").is(":checked") ? ($(".navbar-static-top").removeClass("navbar-static-top").addClass("navbar-fixed-top"), $("body").removeClass("boxed-layout"), $("body").addClass("fixed-nav"), $("#boxedlayout").prop("checked", !1), localStorageSupport && localStorage.setItem("boxedlayout", "off"), localStorageSupport && localStorage.setItem("fixednavbar", "on")) : ($(".navbar-fixed-top").removeClass("navbar-fixed-top").addClass("navbar-static-top"), $("body").removeClass("fixed-nav"), localStorageSupport && localStorage.setItem("fixednavbar", "off")) + }),$("#collapsemenu").click(function () { + $("#collapsemenu").is(":checked") ? ($("body").addClass("mini-navbar"), SmoothlyMenu(), localStorageSupport && localStorage.setItem("collapse_menu", "on")) : ($("body").removeClass("mini-navbar"), SmoothlyMenu(), localStorageSupport && localStorage.setItem("collapse_menu", "off")) + }), $("#boxedlayout").click(function () { + $("#boxedlayout").is(":checked") ? ($("body").addClass("boxed-layout"), $("#fixednavbar").prop("checked", !1), $(".navbar-fixed-top").removeClass("navbar-fixed-top").addClass("navbar-static-top"), $("body").removeClass("fixed-nav"), localStorageSupport && localStorage.setItem("fixednavbar", "off"), localStorageSupport && localStorage.setItem("boxedlayout", "on")) : ($("body").removeClass("boxed-layout"), localStorageSupport && localStorage.setItem("boxedlayout", "off")) + }), $(".s-skin-0").click(function () { + return $("body").removeClass("skin-1"), $("body").removeClass("skin-2"), $("body").removeClass("skin-3"), !1 + }), $(".s-skin-1").click(function () { + return $("body").removeClass("skin-2"), $("body").removeClass("skin-3"), $("body").addClass("skin-1"), !1 + }), $(".s-skin-3").click(function () { + return $("body").removeClass("skin-1"), $("body").removeClass("skin-2"), $("body").addClass("skin-3"), !1 + }), localStorageSupport){ + var e = localStorage.getItem("collapse_menu"), a = localStorage.getItem("fixednavbar"), + o = localStorage.getItem("boxedlayout"); + "on" == e && $("#collapsemenu").prop("checked", "checked"), "on" == a && $("#fixednavbar").prop("checked", "checked"), "on" == o && $("#boxedlayout").prop("checked", "checked") + } + if (localStorageSupport) {//第一次加载 初始化 主题设置 + var e = localStorage.getItem("collapse_menu"), a = localStorage.getItem("fixednavbar"), + o = localStorage.getItem("boxedlayout"), l = $("body"); + "on" == e && (l.hasClass("body-small") || l.addClass("mini-navbar")), + "on" == a && ($(".navbar-static-top").removeClass("navbar-static-top").addClass("navbar-fixed-top"), + l.addClass("fixed-nav")), + "on" == o && l.addClass("boxed-layout") } }); + +$(window).bind("load resize", + function () { + if ($(this).width() < 769) { + $('body').addClass('mini-navbar'); + $('.navbar-static-side').fadeIn(); + } + }); + function NavToggle() { $('.navbar-minimalize').trigger('click'); } @@ -55,16 +124,16 @@ function NavToggle() { function SmoothlyMenu() { if (!$('body').hasClass('mini-navbar')) { $('#side-menu').hide(); - setTimeout(function() { - $('#side-menu').fadeIn(500); - }, - 100); + setTimeout(function () { + $('#side-menu').fadeIn(500); + }, + 100); } else if ($('body').hasClass('fixed-sidebar')) { $('#side-menu').hide(); - setTimeout(function() { - $('#side-menu').fadeIn(500); - }, - 300); + setTimeout(function () { + $('#side-menu').fadeIn(500); + }, + 300); } else { $('#side-menu').removeAttr('style'); } @@ -73,11 +142,11 @@ function SmoothlyMenu() { /** * iframe处理 */ -$(function() { +$(function () { //计算元素集合的总宽度 function calSumWidth(elements) { var width = 0; - $(elements).each(function() { + $(elements).each(function () { width += $(this).outerWidth(true); }); return width; @@ -86,7 +155,7 @@ $(function() { //滚动到指定选项卡 function scrollToTab(element) { var marginLeftVal = calSumWidth($(element).prevAll()), - marginRightVal = calSumWidth($(element).nextAll()); + marginRightVal = calSumWidth($(element).nextAll()); // 可视区域非tab宽度 var tabOuterWidth = calSumWidth($(".content-tabs").children().not(".menuTabs")); //可视区域tab宽度 @@ -108,9 +177,9 @@ $(function() { scrollVal = marginLeftVal - $(element).prev().outerWidth(true); } $('.page-tabs-content').animate({ - marginLeft: 0 - scrollVal + 'px' - }, - "fast"); + marginLeft: 0 - scrollVal + 'px' + }, + "fast"); } //查看左侧隐藏的选项卡 @@ -141,9 +210,9 @@ $(function() { } } $('.page-tabs-content').animate({ - marginLeft: 0 - scrollVal + 'px' - }, - "fast"); + marginLeft: 0 - scrollVal + 'px' + }, + "fast"); } //查看右侧隐藏的选项卡 @@ -172,15 +241,15 @@ $(function() { scrollVal = calSumWidth($(tabElement).prevAll()); if (scrollVal > 0) { $('.page-tabs-content').animate({ - marginLeft: 0 - scrollVal + 'px' - }, - "fast"); + marginLeft: 0 - scrollVal + 'px' + }, + "fast"); } } } //通过遍历给菜单项加上data-index属性 - $(".menuItem").each(function(index) { + $(".menuItem").each(function (index) { if (!$(this).attr('data-index')) { $(this).attr('data-index', index); } @@ -189,19 +258,19 @@ $(function() { function menuItem() { // 获取标识数据 var dataUrl = $(this).attr('href'), - dataIndex = $(this).data('index'), - menuName = $.trim($(this).text()), - flag = true; + dataIndex = $(this).data('index'), + menuName = $.trim($(this).text()), + flag = true; if (dataUrl == undefined || $.trim(dataUrl).length == 0) return false; // 选项卡菜单已存在 - $('.menuTab').each(function() { + $('.menuTab').each(function () { if ($(this).data('id') == dataUrl) { if (!$(this).hasClass('active')) { $(this).addClass('active').siblings('.menuTab').removeClass('active'); scrollToTab(this); // 显示tab对应的内容区 - $('.mainContent .RuoYi_iframe').each(function() { + $('.mainContent .RuoYi_iframe').each(function () { if ($(this).data('id') == dataUrl) { $(this).show().siblings('.RuoYi_iframe').hide(); return false; @@ -220,13 +289,13 @@ $(function() { // 添加选项卡对应的iframe var str1 = ''; $('.mainContent').find('iframe.RuoYi_iframe').hide().parents('.mainContent').append(str1); - + $.modal.loading("数据加载中,请稍后..."); - + $('.mainContent iframe:visible').load(function () { - $.modal.closeLoading(); + $.modal.closeLoading(); }); - + // 添加选项卡 $('.menuTabs .page-tabs-content').append(str); scrollToTab($('.menuTab.active')); @@ -250,7 +319,7 @@ $(function() { var activeId = $(this).parents('.menuTab').next('.menuTab:eq(0)').data('id'); $(this).parents('.menuTab').next('.menuTab:eq(0)').addClass('active'); - $('.mainContent .RuoYi_iframe').each(function() { + $('.mainContent .RuoYi_iframe').each(function () { if ($(this).data('id') == activeId) { $(this).show().siblings('.RuoYi_iframe').hide(); return false; @@ -260,16 +329,16 @@ $(function() { var marginLeftVal = parseInt($('.page-tabs-content').css('margin-left')); if (marginLeftVal < 0) { $('.page-tabs-content').animate({ - marginLeft: (marginLeftVal + currentWidth) + 'px' - }, - "fast"); + marginLeft: (marginLeftVal + currentWidth) + 'px' + }, + "fast"); } // 移除当前选项卡 $(this).parents('.menuTab').remove(); // 移除tab对应的内容区 - $('.mainContent .RuoYi_iframe').each(function() { + $('.mainContent .RuoYi_iframe').each(function () { if ($(this).data('id') == closeTabId) { $(this).remove(); return false; @@ -281,7 +350,7 @@ $(function() { if ($(this).parents('.menuTab').prev('.menuTab').size()) { var activeId = $(this).parents('.menuTab').prev('.menuTab:last').data('id'); $(this).parents('.menuTab').prev('.menuTab:last').addClass('active'); - $('.mainContent .RuoYi_iframe').each(function() { + $('.mainContent .RuoYi_iframe').each(function () { if ($(this).data('id') == activeId) { $(this).show().siblings('.RuoYi_iframe').hide(); return false; @@ -292,7 +361,7 @@ $(function() { $(this).parents('.menuTab').remove(); // 移除tab对应的内容区 - $('.mainContent .RuoYi_iframe').each(function() { + $('.mainContent .RuoYi_iframe').each(function () { if ($(this).data('id') == closeTabId) { $(this).remove(); return false; @@ -306,7 +375,7 @@ $(function() { $(this).parents('.menuTab').remove(); // 移除相应tab对应的内容区 - $('.mainContent .RuoYi_iframe').each(function() { + $('.mainContent .RuoYi_iframe').each(function () { if ($(this).data('id') == closeTabId) { $(this).remove(); return false; @@ -321,18 +390,20 @@ $(function() { //关闭其他选项卡 function closeOtherTabs() { - $('.page-tabs-content').children("[data-id]").not(":first").not(".active").each(function() { + $('.page-tabs-content').children("[data-id]").not(":first").not(".active").each(function () { $('.RuoYi_iframe[data-id="' + $(this).data('id') + '"]').remove(); $(this).remove(); }); $('.page-tabs-content').css("margin-left", "0"); } + $('.tabCloseOther').on('click', closeOtherTabs); //滚动到已激活的选项卡 function showActiveTab() { scrollToTab($('.menuTab.active')); } + $('.tabShowActive').on('click', showActiveTab); // 点击选项卡菜单 @@ -340,7 +411,7 @@ $(function() { if (!$(this).hasClass('active')) { var currentId = $(this).data('id'); // 显示tab对应的内容区 - $('.mainContent .RuoYi_iframe').each(function() { + $('.mainContent .RuoYi_iframe').each(function () { if ($(this).data('id') == currentId) { $(this).show().siblings('.RuoYi_iframe').hide(); return false; @@ -356,17 +427,17 @@ $(function() { //刷新iframe function refreshTab() { - var currentId = $('.page-tabs-content').find('.active').attr('data-id'); - var target = $('.RuoYi_iframe[data-id="' + currentId + '"]'); + var currentId = $('.page-tabs-content').find('.active').attr('data-id'); + var target = $('.RuoYi_iframe[data-id="' + currentId + '"]'); var url = target.attr('src'); target.attr('src', url).ready(); } - + // 全屏显示 $('#fullScreen').on('click', function () { - $('#wrapper').fullScreen(); + $('#wrapper').fullScreen(); }); - + // 刷新按钮 $('.tabReload').on('click', refreshTab); @@ -378,43 +449,43 @@ $(function() { // 右移按扭 $('.tabRight').on('click', scrollTabRight); - + // 关闭当前 $('.tabCloseCurrent').on('click', function () { $('.page-tabs-content').find('.active i').trigger("click"); }); // 关闭全部 - $('.tabCloseAll').on('click', function() { - $('.page-tabs-content').children("[data-id]").not(":first").each(function() { + $('.tabCloseAll').on('click', function () { + $('.page-tabs-content').children("[data-id]").not(":first").each(function () { $('.RuoYi_iframe[data-id="' + $(this).data('id') + '"]').remove(); $(this).remove(); }); - $('.page-tabs-content').children("[data-id]:first").each(function() { + $('.page-tabs-content').children("[data-id]:first").each(function () { $('.RuoYi_iframe[data-id="' + $(this).data('id') + '"]').show(); $(this).addClass("active"); }); $('.page-tabs-content').css("margin-left", "0"); }); - + // tab全屏显示 $('.tabMaxCurrent').on('click', function () { $('.page-tabs-content').find('.active').trigger("dblclick"); }); - + // 关闭全屏 - $('#ax_close_max').click(function(){ - $('#content-main').toggleClass('max'); - $('#ax_close_max').hide(); + $('#ax_close_max').click(function () { + $('#content-main').toggleClass('max'); + $('#ax_close_max').hide(); }) - + // 双击选项卡全屏显示 function activeTabMax() { $('#content-main').toggleClass('max'); $('#ax_close_max').show(); } - - $(window).keydown(function(event) { + + $(window).keydown(function (event) { if (event.keyCode == 27) { $('#content-main').removeClass('max'); $('#ax_close_max').hide(); diff --git a/ruoyi-admin/src/main/resources/templates/index.html b/ruoyi-admin/src/main/resources/templates/index.html index 97948706e..986d54d61 100644 --- a/ruoyi-admin/src/main/resources/templates/index.html +++ b/ruoyi-admin/src/main/resources/templates/index.html @@ -17,6 +17,13 @@ @@ -53,7 +60,7 @@