feat: 优化返回效果;

This commit is contained in:
augushong
2025-08-21 22:56:19 +08:00
parent 5eb4d787c7
commit 9493134c56
2 changed files with 28 additions and 14 deletions

View File

@@ -1,10 +1,10 @@
(function () {
var element = layui.element;
$ = layui.$;
var miniTab = {
renderOptions:{},
renderOptions: {},
/**
* 初始化tab
* @param options
@@ -73,7 +73,7 @@
* @param isParent
*/
delete: function (tabId, isParent) {
ua.findIndexPage(function (window) {
ua.findIndexPage(function (window) {
window.layui.element.tabDelete('layuiminiTab', tabId);
});
},
@@ -131,13 +131,13 @@
// }
// });
// }
ua.findIndexPage(function (window) {
window.layui.$('.layui-tab-title li').each(function () {
var checkTabId = $(this).attr('lay-id');
if (checkTabId != null && checkTabId === tabId) {
checkTab = true;
}
@@ -184,10 +184,10 @@
* @param menuList
*/
searchMenu: function (href, menuList) {
if(!menuList){
menuList = this.renderOptions.menuList
if (!menuList) {
menuList = this.renderOptions.menuList;
}
var menu;
for (key in menuList) {
var item = menuList[key];
@@ -264,7 +264,8 @@
external = $(this).attr('data-external') || false,
target = $(this).attr('target');
if(back == 0){
if (back == 0) {
if (href.indexOf("?") === -1) {
href += '?backTagId=' + ua.getCurrentPageId();
} else {
@@ -282,8 +283,18 @@
if (tabId === null || tabId === undefined) tabId = new Date().getTime();
var checkTab = miniTab.check(tabId, true);
if (!checkTab) {
if (!title) {
title = tabId;
ua.findIndexPage(function (window) {
var menu = window.miniTab.searchMenu(tabId);
if (menu) {
title = menu.title;
}
});
}
miniTab.create({
tabId: tabId,
href: href,
@@ -294,9 +305,9 @@
}
parent.layui.element.tabChange('layuiminiTab', tabId);
parent.layer.close(loading);
if(back == 1){
if (back == 1) {
console.log(back);
miniTab.delete(ua.getCurrentPageId());
}
});
@@ -401,7 +412,7 @@
listenSwitch: function (options) {
options.filter = options.filter || null;
options.urlHashLocation = options.urlHashLocation || false;
options.listenSwichCallback = options.listenSwichCallback || function () { };
element.on('tab(' + options.filter + ')', function (data) {
var tabId = $(this).attr('lay-id');