From d6cc4ce6698e7828c595e8ea5d02b82f35b3edb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AC=91=E7=AC=91?= Date: Mon, 20 Nov 2023 22:35:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20layui=E4=B8=BB=E9=A2=98=E6=94=AF?= =?UTF-8?q?=E6=8C=81url=E4=B8=AD#=E5=8F=B7=E5=90=8E=E9=9D=A2=E7=9A=84?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=E4=BD=9C=E4=B8=BA=E4=B8=80=E4=B8=AA=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E9=A1=B5=E6=89=93=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wwwroot/Content/layui/layui_main_cube.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/NewLife.CubeNC/wwwroot/Content/layui/layui_main_cube.js b/NewLife.CubeNC/wwwroot/Content/layui/layui_main_cube.js index b81bcabc..7d52c317 100644 --- a/NewLife.CubeNC/wwwroot/Content/layui/layui_main_cube.js +++ b/NewLife.CubeNC/wwwroot/Content/layui/layui_main_cube.js @@ -55,6 +55,9 @@ layui.use(['element_cube', 'layer', 'util'], function () { var title = othis.data('title'); cubeAddTab(url, title); + + // 将链接记录到url的hash,下次打开该链接将自动打开该标签页 + location.hash = url; } }); @@ -113,4 +116,20 @@ layui.use(['element_cube', 'layer', 'util'], function () { return false; }; + + // 判断url是否存在hash,自动打开该标签页 + if (location.hash && location.hash.startsWith('#/')) { + const url = location.hash.replace('#', ''); + const eleA = $(`.layui-nav .layui-nav-item dd a[data-url="${url}"]`) + if (eleA) { + // 点击对应菜单 + eleA.click() + // 菜单对应父级 + const eleLi = eleA.parents('.layui-nav-item') + // 关闭其他打开菜单 + eleLi.siblings('.layui-nav-itemed').find('>a').click() + // 展开父级菜单 + if (!eleLi.hasClass('layui-nav-itemed')) eleLi.find('>a').click() + } + } }); \ No newline at end of file