From d303d57f48a4be34ca6ff7f811a77818b72b7433 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Wed, 24 Jun 2020 22:23:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EisLinkage=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E9=A1=B5=E7=AD=BE=E4=B8=8E=E8=8F=9C=E5=8D=95=E8=81=94=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/static/ruoyi/index.js | 9 ++++++--- .../src/main/resources/templates/index.html | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/index.js b/ruoyi-admin/src/main/resources/static/ruoyi/index.js index ca8c00c4..e7fad173 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/index.js +++ b/ruoyi-admin/src/main/resources/static/ruoyi/index.js @@ -239,9 +239,12 @@ $(function() { dataIndex = $(this).data('index'), menuName = $.trim($(this).text()), flag = true; - $(".nav ul li, .nav li").removeClass("selected"); - $(this).parent("li").addClass("selected"); - setIframeUrl($(this).attr("href")); + + if (!$('a[href$="' + dataUrl + '"]').hasClass("noactive")) { + $(".nav ul li, .nav li").removeClass("selected"); + $(this).parent("li").addClass("selected"); + } + setIframeUrl(dataUrl); if (dataUrl == undefined || $.trim(dataUrl).length == 0) return false; // 选项卡菜单已存在 diff --git a/ruoyi-admin/src/main/resources/templates/index.html b/ruoyi-admin/src/main/resources/templates/index.html index dfe5242d..8fcaa7a9 100644 --- a/ruoyi-admin/src/main/resources/templates/index.html +++ b/ruoyi-admin/src/main/resources/templates/index.html @@ -258,6 +258,8 @@ var skin = storage.get("skin"); var mode = "history"; // 历史访问路径缓存 var historyPath = storage.get("historyPath"); +// 是否页签与菜单联动 +var isLinkage = true; // 本地主题优先,未设置取系统配置 if($.common.isNotEmpty(skin)){ @@ -305,6 +307,19 @@ $(function() { applyPath(url); } } + if(isLinkage) { + $(".menuTabs").on("click", ".menuTab", function() { + var dataId = $(this).attr("data-id"); + var $dataObj = $('a[href$="' + decodeURI(dataId) + '"]'); + if (!$dataObj.hasClass("noactive")) { + $('.nav ul').removeClass("in"); + $dataObj.parents("ul").addClass("in") + $dataObj.parents("li").addClass("active").siblings().removeClass("active").find('li').removeClass("active"); + $dataObj.parents("ul").css('height', 'auto').height(); + $('a[href$="' + decodeURI(dataId) + '"]').click(); + } + }) + } });