From a2075c651fb5d4b623968ee69a769a06730e572c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dotnet=E7=88=B1=E5=A5=BD=E8=80=85?= Date: Fri, 25 Aug 2023 10:10:10 +0000 Subject: [PATCH 1/7] =?UTF-8?q?update=20index.html.=201=20=E4=BD=BF?= =?UTF-8?q?=E7=94=A8json=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=202=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=A7=BB=E5=8A=A8=E7=AB=AF=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E7=A7=BB=20=E5=8A=A8=20=E7=AB=AF=20=E4=BE=BF=20=E6=8D=B7=20?= =?UTF-8?q?=E6=93=8D=20=E4=BD=9C=20a=20=E6=A0=87=E7=AD=BE=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9href=E4=B8=BA=20JavaScript:;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dotnet爱好者 --- index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 89009d7..16ea190 100644 --- a/index.html +++ b/index.html @@ -79,7 +79,7 @@
- +
@@ -91,7 +91,7 @@ var admin = layui.admin; var popup = layui.popup; - admin.setConfigurationPath("config/pear.config.yml"); + admin.setConfigurationPath("config/pear.config.json"); admin.render(); @@ -109,4 +109,4 @@ }) - + \ No newline at end of file -- Gitee From 826797bfd377b8e89d378146a1fde9acb7e845a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dotnet=E7=88=B1=E5=A5=BD=E8=80=85?= Date: Fri, 25 Aug 2023 10:12:01 +0000 Subject: [PATCH 2/7] =?UTF-8?q?update=20component/pear/module/admin.js.=20?= =?UTF-8?q?=E5=A5=BD=E5=83=8F=E5=95=A5=E4=B9=9F=E6=B2=A1=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dotnet爱好者 --- component/pear/module/admin.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/component/pear/module/admin.js b/component/pear/module/admin.js index 7c8d821..b060280 100644 --- a/component/pear/module/admin.js +++ b/component/pear/module/admin.js @@ -51,7 +51,9 @@ layui.define(['jquery', 'tools', 'element', 'yaml', 'form', 'tabPage', 'menu', ' } }); } else { - resolve(yaml.load(this.configurationPath)); + let json = yaml.load(this.configurationPath); + console.log(json) + resolve(json); } }) } -- Gitee From 9d82188499215f0256dcf499fa93c6b7cceb59c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dotnet=E7=88=B1=E5=A5=BD=E8=80=85?= Date: Fri, 25 Aug 2023 10:14:06 +0000 Subject: [PATCH 3/7] =?UTF-8?q?update=20component/pear/module/tabPage.js.?= =?UTF-8?q?=20=E5=85=BC=E5=AE=B9=20url=20hash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dotnet爱好者 --- component/pear/module/tabPage.js | 212 +++++++++++++++++-------------- 1 file changed, 116 insertions(+), 96 deletions(-) diff --git a/component/pear/module/tabPage.js b/component/pear/module/tabPage.js index c6b6c5f..aa723d2 100644 --- a/component/pear/module/tabPage.js +++ b/component/pear/module/tabPage.js @@ -56,7 +56,8 @@ layui.define(['jquery', 'element', 'dropdown'], function (exports) { rollPage("right", option); }) element.init(); - + handlerTabChange(option.elem); + handlerHasChange(option.elem); $("#" + option.elem).width(opt.width); $("#" + option.elem).height(opt.height); $("#" + option.elem).css({ @@ -120,7 +121,7 @@ layui.define(['jquery', 'element', 'dropdown'], function (exports) { } }) - + //tab页关闭功能内容菜单 $("body .layui-tab[lay-filter='" + option.elem + "'] .layui-tab-title").on("contextmenu", "li", function (e) { var top = e.clientY; @@ -183,8 +184,11 @@ layui.define(['jquery', 'element', 'dropdown'], function (exports) { var elem = this.option.elem; element.on('tab(' + this.option.elem + ')', function (data) { var id = $("#" + elem + " .layui-tab-title .layui-this").attr("lay-id"); + location.hash = id; sessionStorage.setItem(option.elem + "-pear-tab-page-data-current", id); callback(id); + + console.log(data.index); // 得到当前 tab 项的所在下标 }); } @@ -265,46 +269,6 @@ layui.define(['jquery', 'element', 'dropdown'], function (exports) { var title = ` ${opt.title} `; - - if ($(".layui-tab[lay-filter='" + this.option.elem + "'] .layui-tab-title li[lay-id]").length <= - 0) { - - var that = this; - - if (opt.type === "_iframe") { - - element.tabAdd(this.option.elem, { - id: opt.id, - title: title, - content: `` - }); - - } else { - - $.ajax({ - url: opt.url, - type: 'get', - dataType: 'html', - async: false, - success: function (data) { - element.tabAdd(that.option.elem, { - id: opt.id, - title: title, - content: `
${data}
`, - }); - }, - error: function (xhr, textstatus, thrown) { - return layer.msg('Status:' + xhr.status + ',' + xhr.statusText + ',请稍后再试!'); - } - }); - } - - tabData.push(opt); - sessionStorage.setItem(that.option.elem + "-pear-tab-page-data", JSON.stringify(tabData)); - sessionStorage.setItem(that.option.elem + "-pear-tab-page-data-current", opt.id); - - } else { - var isData = false; $.each($(".layui-tab[lay-filter='" + this.option.elem + "'] .layui-tab-title li[lay-id]"), function () { @@ -313,52 +277,31 @@ layui.define(['jquery', 'element', 'dropdown'], function (exports) { } }) - if (isData == false) { + if (isData == false) { - if (this.option.tabMax != false) { - if ($(".layui-tab[lay-filter='" + this.option.elem + "'] .layui-tab-title li[lay-id]") - .length >= this.option.tabMax) { - layer.msg("最多打开" + this.option.tabMax + "个标签页", { - icon: 2, - time: 1000, - shift: 6 - }); - return false; - } - } - - var that = this; - if (opt.type === "_iframe") { - element.tabAdd(this.option.elem, { - id: opt.id, - title: title, - content: `` - }); - } else { - $.ajax({ - url: opt.url, - type: 'get', - dataType: 'html', - async: false, - success: function (data) { - element.tabAdd(that.option.elem, { - id: opt.id, - title: title, - content: `
${data}
`, - }); - }, - error: function (xhr, textstatus, thrown) { - return layer.msg('Status:' + xhr.status + ',' + xhr.statusText + ',请稍后再试!'); - } + if (this.option.tabMax != false) { + if ($(".layui-tab[lay-filter='" + this.option.elem + "'] .layui-tab-title li[lay-id]") + .length >= this.option.tabMax) { + layer.msg("最多打开" + this.option.tabMax + "个标签页", { + icon: 2, + time: 1000, + shift: 6 }); + return false; } - tabData.push(opt); - sessionStorage.setItem(that.option.elem + "-pear-tab-page-data", JSON.stringify(tabData)); - sessionStorage.setItem(that.option.elem + "-pear-tab-page-data-current", opt.id); } + + var that = this; + addLayuiTab(this.option.elem, title, opt); + tabData.push(opt); + sessionStorage.setItem(that.option.elem + "-pear-tab-page-data", JSON.stringify(tabData)); + sessionStorage.setItem(that.option.elem + "-pear-tab-page-data-current", opt.id); } - element.tabChange(this.option.elem, opt.id); + + //element.tabChange(this.option.elem, opt.id); sessionStorage.setItem(this.option.elem + "-pear-tab-page-data-current", opt.id); + + } // 刷 新 指 定 的 选 项 卡 @@ -448,7 +391,9 @@ layui.define(['jquery', 'element', 'dropdown'], function (exports) { } /** - * @since Pear Admin 4.0 + * 创建tab组件 返回tab 组件的 html字符串(一个div) + * @param {any} option + * @returns */ function createTab(option) { @@ -493,19 +438,9 @@ layui.define(['jquery', 'element', 'dropdown'], function (exports) { content += `
` } else { - - $.ajax({ - url: item.url, - type: 'get', - dataType: 'html', - async: false, - success: function (data) { - content += `
${data}
`; - }, - error: function (xhr) { - return layer.msg('Status:' + xhr.status + ',' + xhr.statusText + ',请稍后再试!'); - } - }); + $getHtml(item.url,data=> + content += `
${data}
` + ); } index++; @@ -521,7 +456,57 @@ layui.define(['jquery', 'element', 'dropdown'], function (exports) { tab += '' return tab; } + /** + * 添加tab页 用的Layui的tab页组件 + * 如果opt.type=='_iframe' 则不用Layui tab而是 直接插入一个iframe + * @param {any} filter + * @param {any} title + * @param {any} opt + */ + function addLayuiTab(filter, title, opt) { + if (opt.type === "_iframe") { + + element.tabAdd(filter, { + id: opt.id, + title: title, + content: `` + }); + } else { + $getHtml(opt.url, data => element.tabAdd(filter, { + id: opt.id, + pageUrl: opt.url, + title: title, + content: `
${data}
`, + })); + } + } + /** + * jq ajax get方式获取html页面 + * @param {any} url + * @param { function (HTMLElement)} callBack + */ + function $getHtml(url, callBack) { + $.ajax({ + url: url, + type: 'get', + dataType: 'html', + async: false, + success: function (data) { + if (typeof (callBack) === 'function') { + callBack(data) + } + }, + error: function (xhr, textstatus, thrown) { + return layer.msg('Status:' + xhr.status + ',' + xhr.statusText + ',请稍后再试!'); + } + }); + } + /** + * 滚动tab页头 + * @param {any} d + * @param {any} option + */ function rollPage(d, option) { var $tabTitle = $('#' + option.elem + ' .layui-tab-title'); var left = $tabTitle.scrollLeft(); @@ -535,7 +520,42 @@ layui.define(['jquery', 'element', 'dropdown'], function (exports) { }, 200); } } + /** + * tab切换事件处理函数 + * @param {any} filter + */ + function handlerTabChange(filter) { + // tab 切换事件 + element.on('tab('+filter+')', function (data) { + console.log(this); // 当前 tab 标题所在的原始 DOM 元素 + console.log(data.index); // 得到当前 tab 项的所在下标 + console.log(data.elem); // 得到当前的 tab 容器 + }); + } + /** + * url hash变更事件处理 + * @param {any} filter + */ + function handlerHasChange(filter) { + locationHashChanged(); + window.onhashchange = locationHashChanged; + function locationHashChanged() { + let hash = location.hash; + if (hash) { + let layid = hash.replace('#', ''); + if ($("ul.layui-tab-title [lay-id=" + filter + "]").length > 0) { + // 切换 + element.tabChange(filter, layid); + } else { + //如果没打开的话 还要打开这个页面 + //菜单中是否有 + if (false) { + } + } + } + } + } function closeEvent(option) { $(".layui-tab[lay-filter='" + option.elem + "']").on("click", ".layui-tab-close", function () { var layid = $(this).parent().attr("lay-id"); -- Gitee From e52b2c751f05d84a4a8a0ac4f85769f12f371e98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dotnet=E7=88=B1=E5=A5=BD=E8=80=85?= Date: Fri, 25 Aug 2023 10:15:16 +0000 Subject: [PATCH 4/7] add view/grid.html. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dotnet爱好者 --- view/grid.html | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 view/grid.html diff --git a/view/grid.html b/view/grid.html new file mode 100644 index 0000000..16d5d6f --- /dev/null +++ b/view/grid.html @@ -0,0 +1,54 @@ +
+
+
基础使用
+
+
+
+
+
+
+
+
+
+
+
+
+
栅格偏移
+
+
+
+
+
+
+
+
+
+
+
+
自适应性
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + \ No newline at end of file -- Gitee From 7a0e4e39bd091e2f19ef6dbb8b87bfbd5b8c03e7 Mon Sep 17 00:00:00 2001 From: dotnetFans Date: Sat, 26 Aug 2023 14:19:38 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E5=92=8Chash=E5=9C=B0=E5=9D=80=E8=81=94=E5=8A=A8=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0table=20=E8=A1=A8=E6=A0=BC=E7=BB=84=E4=BB=B6=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/data/menu.json | 17 ++- api/table.json | 127 ++++++++++++++++++++++ component/pear/module/admin.js | 5 +- component/pear/module/tabPage.js | 154 +++++++++++++------------- config/pear.config.json | 2 +- index.html | 4 +- view/component/table.html | 181 +++++++++++++++++++++++++++++++ view/component/toast.html | 2 +- view/grid.html | 54 --------- 9 files changed, 406 insertions(+), 140 deletions(-) create mode 100644 api/table.json create mode 100644 view/component/table.html delete mode 100644 view/grid.html diff --git a/admin/data/menu.json b/admin/data/menu.json index a1576ce..4ab5db1 100644 --- a/admin/data/menu.json +++ b/admin/data/menu.json @@ -23,6 +23,21 @@ } ] }, + { + "id":"dataTable", + "title":"表格", + "type":0, + "children":[ + { + "id":"table1", + "title": "常用列表", + "icon": "layui-icon layui-icon-face-smile", + "type": 1, + "openType": "_component", + "href": "view/component/table.html" + } + ] + }, { "id": 2, "title": "扩展组件", @@ -147,7 +162,7 @@ }, { "id": "deep", - "title": "深度测试", + "title": "菜单深度测试", "icon": "layui-icon layui-icon-auz", "type": 0, "href": "", diff --git a/api/table.json b/api/table.json new file mode 100644 index 0000000..7bda61b --- /dev/null +++ b/api/table.json @@ -0,0 +1,127 @@ +{ + "code": 0, + "msg": "", + "count": 1000, + "data": [ + { + "id": 10000, + "username": "user-0", + "sex": "女", + "city": "城市-0", + "sign": "签名-0", + "experience": 255, + "logins": 24, + "wealth": 82830700, + "classify": "作家", + "score": 57 + }, + { + "id": 10001, + "username": "user-1", + "sex": "男", + "city": "城市-1", + "sign": "签名-1", + "experience": 884, + "logins": 58, + "wealth": 64928690, + "classify": "词人", + "score": 27 + }, + { + "id": 10002, + "username": "user-2", + "sex": "女", + "city": "城市-2", + "sign": "签名-2", + "experience": 650, + "logins": 77, + "wealth": 6298078, + "classify": "酱油", + "score": 31 + }, + { + "id": 10003, + "username": "user-3", + "sex": "女", + "city": "城市-3", + "sign": "签名-3", + "experience": 362, + "logins": 157, + "wealth": 37117017, + "classify": "诗人", + "score": 68 + }, + { + "id": 10004, + "username": "user-4", + "sex": "男", + "city": "城市-4", + "sign": "签名-4", + "experience": 807, + "logins": 51, + "wealth": 76263262, + "classify": "作家", + "score": 6 + }, + { + "id": 10005, + "username": "user-5", + "sex": "女", + "city": "城市-5", + "sign": "签名-5", + "experience": 173, + "logins": 68, + "wealth": 60344147, + "classify": "作家", + "score": 87 + }, + { + "id": 10006, + "username": "user-6", + "sex": "女", + "city": "城市-6", + "sign": "签名-6", + "experience": 982, + "logins": 37, + "wealth": 57768166, + "classify": "作家", + "score": 34 + }, + { + "id": 10007, + "username": "user-7", + "sex": "男", + "city": "城市-7", + "sign": "签名-7", + "experience": 727, + "logins": 150, + "wealth": 82030578, + "classify": "作家", + "score": 28 + }, + { + "id": 10008, + "username": "user-8", + "sex": "男", + "city": "城市-8", + "sign": "签名-8", + "experience": 951, + "logins": 133, + "wealth": 16503371, + "classify": "词人", + "score": 14 + }, + { + "id": 10009, + "username": "user-9", + "sex": "女", + "city": "城市-9", + "sign": "签名-9", + "experience": 484, + "logins": 25, + "wealth": 86801934, + "classify": "词人", + "score": 75 + } + ] +} \ No newline at end of file diff --git a/component/pear/module/admin.js b/component/pear/module/admin.js index b060280..57d007a 100644 --- a/component/pear/module/admin.js +++ b/component/pear/module/admin.js @@ -116,6 +116,7 @@ layui.define(['jquery', 'tools', 'element', 'yaml', 'form', 'tabPage', 'menu', ' pearAdmin.messageCenterRender(configuration); pearAdmin.themeRender(configuration); pearAdmin.keepLoad(configuration); + } /** @@ -223,6 +224,7 @@ layui.define(['jquery', 'tools', 'element', 'yaml', 'form', 'tabPage', 'menu', ' setTimeout(function () { sideMenu.selectItem(id); bodyTab.positionTab(); + bodyTab.handlerHash(); }, 500) } } @@ -246,12 +248,11 @@ layui.define(['jquery', 'tools', 'element', 'yaml', 'form', 'tabPage', 'menu', ' type: data.menuOpenType, url: data.menuUrl, icon: data.menuIcon, - close: true + close: true }); } compatible(); }) - } else { bodyFrame = page.render({ diff --git a/component/pear/module/tabPage.js b/component/pear/module/tabPage.js index aa723d2..6f86ac4 100644 --- a/component/pear/module/tabPage.js +++ b/component/pear/module/tabPage.js @@ -55,9 +55,7 @@ layui.define(['jquery', 'element', 'dropdown'], function (exports) { $(".layui-tab[lay-filter='" + option.elem + "'] .layui-tab-next").click(function () { rollPage("right", option); }) - element.init(); - handlerTabChange(option.elem); - handlerHasChange(option.elem); + element.render("tab",option.elem); $("#" + option.elem).width(opt.width); $("#" + option.elem).height(opt.height); $("#" + option.elem).css({ @@ -181,14 +179,12 @@ layui.define(['jquery', 'element', 'dropdown'], function (exports) { tabPage.prototype.click = function (callback) { var option = this.option; - var elem = this.option.elem; - element.on('tab(' + this.option.elem + ')', function (data) { - var id = $("#" + elem + " .layui-tab-title .layui-this").attr("lay-id"); - location.hash = id; + element.on('tab(' + option.elem + ')', function (data) { + let tab= $(this); + let id = tab.attr("lay-id"); + location.hash = tab.attr("lay-pageurl")||''; sessionStorage.setItem(option.elem + "-pear-tab-page-data-current", id); callback(id); - - console.log(data.index); // 得到当前 tab 项的所在下标 }); } @@ -229,8 +225,7 @@ layui.define(['jquery', 'element', 'dropdown'], function (exports) { } // 根据过滤 filter 标识, 删除其他选项卡 tabPage.prototype.delOtherTabByElem = function (elem, callback) { - var currentId = $(".layui-tab[lay-filter='" + elem + "'] .layui-tab-title .layui-this").attr( - "lay-id"); + var currentId = $(".layui-tab[lay-filter='" + elem + "'] .layui-tab-title .layui-this").attr("lay-id"); var tabtitle = $(".layui-tab[lay-filter='" + elem + "'] .layui-tab-title li"); $.each(tabtitle, function (i) { if ($(this).attr("lay-id") != currentId) { @@ -243,8 +238,7 @@ layui.define(['jquery', 'element', 'dropdown'], function (exports) { // 根据过滤 filter 标识, 删除全部选项卡 tabPage.prototype.delAllTabByElem = function (elem, callback) { - var currentId = $(".layui-tab[lay-filter='" + elem + "'] .layui-tab-title .layui-this").attr( - "lay-id"); + //var currentId = $(".layui-tab[lay-filter='" + elem + "'] .layui-tab-title .layui-this").attr("lay-id"); var tabtitle = $(".layui-tab[lay-filter='" + elem + "'] .layui-tab-title li"); $.each(tabtitle, function (i) { if ($(this).find("span").is(".able-close")) { @@ -269,13 +263,13 @@ layui.define(['jquery', 'element', 'dropdown'], function (exports) { var title = ` ${opt.title} `; - var isData = false; - $.each($(".layui-tab[lay-filter='" + this.option.elem + "'] .layui-tab-title li[lay-id]"), - function () { - if ($(this).attr("lay-id") == opt.id) { - isData = true; - } - }) + var isData = false; + $.each($(".layui-tab[lay-filter='" + this.option.elem + "'] .layui-tab-title li[lay-id]"), + function () { + if ($(this).attr("lay-id") == opt.id) { + isData = true; + } + }) if (isData == false) { @@ -293,15 +287,15 @@ layui.define(['jquery', 'element', 'dropdown'], function (exports) { var that = this; addLayuiTab(this.option.elem, title, opt); - tabData.push(opt); + tabData.push(opt); sessionStorage.setItem(that.option.elem + "-pear-tab-page-data", JSON.stringify(tabData)); sessionStorage.setItem(that.option.elem + "-pear-tab-page-data-current", opt.id); } - //element.tabChange(this.option.elem, opt.id); + element.tabChange(this.option.elem, opt.id); sessionStorage.setItem(this.option.elem + "-pear-tab-page-data-current", opt.id); - + } // 刷 新 指 定 的 选 项 卡 @@ -317,10 +311,10 @@ layui.define(['jquery', 'element', 'dropdown'], function (exports) { }); } - if($iframe.attr("type") === "_iframe") { + if ($iframe.attr("type") === "_iframe") { $iframe.attr("src", $iframe.attr("src")); - $iframe.on("load", function() { - $iframeLoad.fadeOut(1000, function() { + $iframe.on("load", function () { + $iframeLoad.fadeOut(1000, function () { $iframeLoad.remove(); }); }) @@ -344,6 +338,39 @@ layui.define(['jquery', 'element', 'dropdown'], function (exports) { } } + /** + * 根据url hash 地址 匹配tab + */ + tabPage.prototype.handlerHash= function () { + //window.onhashchange = locationHashChanged; + let _this = this; + let hash = location.hash; + if (!hash) {return;} + let pageUrl = hash.replace("#", ""); + let tabElement = $("ul.layui-tab-title [lay-pageurl='" + pageUrl + "']"); + if (tabElement.length > 0) { + let layid = tabElement.attr("lay-id"); + if (!tabElement.hasClass("layui-this")) { + element.tabChange(option.elem, layid); // 切换tab + } + } else { + //如果没打开的话 还要打开这个页面 + //菜单中是否有 + let menu = $('ul[lay-filter="sideMenu"] li a[menu-url="' + pageUrl + '"]'); + if (menu.length > 0) { + _this.addTabOnly({ + id: menu.attr("menu-id"), + title: menu.attr("menu-title"), + url:pageUrl, + close: true, + }); + } else { + // 404? + console.log(404); + } + } + } + function tabDelete(elem, id, callback, option) { var tabTitle = $(".layui-tab[lay-filter='" + elem + "']").find(".layui-tab-title"); var removeTab = tabTitle.find("li[lay-id='" + id + "']"); @@ -364,16 +391,20 @@ layui.define(['jquery', 'element', 'dropdown'], function (exports) { } var currId; + var currPageurl; if (nextNode.length) { nextNode.addClass("layui-this"); currId = nextNode.attr("lay-id"); + currPageurl = nextNode.attr("lay-pageurl"); $("#" + elem + " [id='" + currId + "']").parent().addClass("layui-show"); } else { var prevNode = removeTab.prev("li"); prevNode.addClass("layui-this"); currId = prevNode.attr("lay-id"); + currPageurl = prevNode.attr("lay-pageurl"); $("#" + elem + " [id='" + currId + "']").parent().addClass("layui-show"); } + location.hash=currPageurl??""; callback(currId); tabData = JSON.parse(sessionStorage.getItem(elem + "-pear-tab-page-data")); tabDataCurrent = sessionStorage.getItem(elem + "-pear-tab-page-data-current"); @@ -423,7 +454,7 @@ layui.define(['jquery', 'element', 'dropdown'], function (exports) { var index = 0; $.each(option.data, function (i, item) { - var titleItem = `
  • + var titleItem = `
  • ${item.title} @@ -438,9 +469,9 @@ layui.define(['jquery', 'element', 'dropdown'], function (exports) { content += `
    ` } else { - $getHtml(item.url,data=> - content += `
    ${data}
    ` - ); + $getHtml(item.url, data => + content += `
    ${data}
    ` + ); } index++; @@ -464,22 +495,22 @@ layui.define(['jquery', 'element', 'dropdown'], function (exports) { * @param {any} opt */ function addLayuiTab(filter, title, opt) { - if (opt.type === "_iframe") { + if (opt.type === "_iframe") { - element.tabAdd(filter, { - id: opt.id, - title: title, - content: `` - }); + element.tabAdd(filter, { + id: opt.id, + title: title, + content: `` + }); - } else { - $getHtml(opt.url, data => element.tabAdd(filter, { - id: opt.id, - pageUrl: opt.url, - title: title, - content: `
    ${data}
    `, - })); - } + } else { + $getHtml(opt.url, data => element.tabAdd(filter, { + id: opt.id, + pageUrl: opt.url, + title: title, + content: `
    ${data}
    `, + })); + } } /** * jq ajax get方式获取html页面 @@ -520,42 +551,7 @@ layui.define(['jquery', 'element', 'dropdown'], function (exports) { }, 200); } } - /** - * tab切换事件处理函数 - * @param {any} filter - */ - function handlerTabChange(filter) { - // tab 切换事件 - element.on('tab('+filter+')', function (data) { - console.log(this); // 当前 tab 标题所在的原始 DOM 元素 - console.log(data.index); // 得到当前 tab 项的所在下标 - console.log(data.elem); // 得到当前的 tab 容器 - }); - } - /** - * url hash变更事件处理 - * @param {any} filter - */ - function handlerHasChange(filter) { - locationHashChanged(); - window.onhashchange = locationHashChanged; - function locationHashChanged() { - let hash = location.hash; - if (hash) { - let layid = hash.replace('#', ''); - if ($("ul.layui-tab-title [lay-id=" + filter + "]").length > 0) { - // 切换 - element.tabChange(filter, layid); - } else { - //如果没打开的话 还要打开这个页面 - //菜单中是否有 - if (false) { - } - } - } - } - } function closeEvent(option) { $(".layui-tab[lay-filter='" + option.elem + "']").on("click", ".layui-tab-close", function () { var layid = $(this).parent().attr("lay-id"); diff --git a/config/pear.config.json b/config/pear.config.json index b1dba56..bf51cbd 100644 --- a/config/pear.config.json +++ b/config/pear.config.json @@ -21,7 +21,7 @@ "max": "30", "index": { "id": "10", - "href": "view/console/console1.html", + "href": "view/console/index.html", "title": "首页" } }, diff --git a/index.html b/index.html index 16ea190..1d86840 100644 --- a/index.html +++ b/index.html @@ -25,8 +25,8 @@
      -
    • -
    • +
    • +
    diff --git a/view/component/table.html b/view/component/table.html new file mode 100644 index 0000000..f30b6b4 --- /dev/null +++ b/view/component/table.html @@ -0,0 +1,181 @@ + + + + + layui + + + + + + + +
    +
    + +
    + 搜索信息 +
    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    +
    +
    +
    + + + +
    + + + +
    +
    + + + + \ No newline at end of file diff --git a/view/component/toast.html b/view/component/toast.html index c959a70..bbbf781 100644 --- a/view/component/toast.html +++ b/view/component/toast.html @@ -38,7 +38,7 @@