Fix tab Right-click menu opens multiple times
parent
f8f0cf8925
commit
1d868f2e98
|
|
@ -1,4 +1,4 @@
|
||||||
layui.define(['table', 'jquery', 'element', 'yaml', 'form', 'tab', 'menu', 'frame', 'theme','convert'],
|
layui.define(['table', 'jquery', 'element', 'yaml', 'form', 'tab', 'menu', 'frame', 'theme', 'convert'],
|
||||||
function(exports) {
|
function(exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -16,8 +16,8 @@ layui.define(['table', 'jquery', 'element', 'yaml', 'form', 'tab', 'menu', 'fram
|
||||||
let sideMenu;
|
let sideMenu;
|
||||||
let bodyTab;
|
let bodyTab;
|
||||||
let config;
|
let config;
|
||||||
let logout = function(){};
|
let logout = function() {};
|
||||||
|
|
||||||
const body = $('body');
|
const body = $('body');
|
||||||
|
|
||||||
const pearAdmin = new function() {
|
const pearAdmin = new function() {
|
||||||
|
|
@ -33,14 +33,14 @@ layui.define(['table', 'jquery', 'element', 'yaml', 'form', 'tab', 'menu', 'fram
|
||||||
this.setConfigType = function(type) {
|
this.setConfigType = function(type) {
|
||||||
configType = type;
|
configType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setAvatar = function(url,username){
|
this.setAvatar = function(url, username) {
|
||||||
var image = new Image();
|
var image = new Image();
|
||||||
image.src = "admin/images/avatar.jpg";
|
image.src = "admin/images/avatar.jpg";
|
||||||
image.onload = function(){
|
image.onload = function() {
|
||||||
$(".layui-nav-img").attr("src", convert.imageToBase64(image));
|
$(".layui-nav-img").attr("src", convert.imageToBase64(image));
|
||||||
}
|
}
|
||||||
$(".layui-nav-img").parent().append(username);
|
$(".layui-nav-img").parent().append(username);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.render = function(initConfig) {
|
this.render = function(initConfig) {
|
||||||
|
|
@ -158,7 +158,7 @@ layui.define(['table', 'jquery', 'element', 'yaml', 'form', 'tab', 'menu', 'fram
|
||||||
icon: data.menuIcon,
|
icon: data.menuIcon,
|
||||||
close: true
|
close: true
|
||||||
}, 300);
|
}, 300);
|
||||||
|
|
||||||
compatible();
|
compatible();
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
@ -212,9 +212,9 @@ layui.define(['table', 'jquery', 'element', 'yaml', 'form', 'tab', 'menu', 'fram
|
||||||
pearAdmin.removeClass("dark-theme");
|
pearAdmin.removeClass("dark-theme");
|
||||||
pearAdmin.addClass(theme);
|
pearAdmin.addClass(theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logout = function(callback){
|
this.logout = function(callback) {
|
||||||
|
|
||||||
logout = callback;
|
logout = callback;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -234,17 +234,17 @@ layui.define(['table', 'jquery', 'element', 'yaml', 'form', 'tab', 'menu', 'fram
|
||||||
admin.addClass("pear-mini");
|
admin.addClass("pear-mini");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
body.on("click",".logout",function(){
|
body.on("click", ".logout", function() {
|
||||||
// 回调
|
// 回调
|
||||||
var result = logout();
|
var result = logout();
|
||||||
|
|
||||||
if(result){
|
if (result) {
|
||||||
// 清空缓存
|
// 清空缓存
|
||||||
bodyTab.clear();
|
bodyTab.clear();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
body.on("click", ".collaspe,.pear-cover", function() {
|
body.on("click", ".collaspe,.pear-cover", function() {
|
||||||
collaspe();
|
collaspe();
|
||||||
});
|
});
|
||||||
|
|
@ -458,5 +458,6 @@ layui.define(['table', 'jquery', 'element', 'yaml', 'form', 'tab', 'menu', 'fram
|
||||||
res("返回值");
|
res("返回值");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
exports('admin', pearAdmin);
|
exports('admin', pearAdmin);
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,8 @@ layui.define(['jquery', 'element'], function(exports) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var lastIndex;
|
||||||
var tab = createTab(option);
|
var tab = createTab(option);
|
||||||
$("#" + option.elem).html(tab);
|
$("#" + option.elem).html(tab);
|
||||||
$(".layui-tab[lay-filter='" + option.elem + "'] .layui-tab-prev").click(function() {
|
$(".layui-tab[lay-filter='" + option.elem + "'] .layui-tab-prev").click(function() {
|
||||||
|
|
@ -73,7 +75,7 @@ layui.define(['jquery', 'element'], function(exports) {
|
||||||
var currentId = $(this).attr("lay-id");
|
var currentId = $(this).attr("lay-id");
|
||||||
|
|
||||||
var menu = "<ul><li class='item' id='" + option.elem + "closeThis'>关闭当前</li><li class='item' id='" + option.elem +
|
var menu = "<ul><li class='item' id='" + option.elem + "closeThis'>关闭当前</li><li class='item' id='" + option.elem +
|
||||||
"closeOther'>关闭其他</li><li class='item' id='" + option.elem + "closeAll'>关闭所有</li></ul>"
|
"closeOther'>关闭其他</li><li class='item' id='" + option.elem + "closeAll'>关闭所有</li></ul>";
|
||||||
|
|
||||||
// 初始化
|
// 初始化
|
||||||
layer.open({
|
layer.open({
|
||||||
|
|
@ -87,8 +89,9 @@ layui.define(['jquery', 'element'], function(exports) {
|
||||||
offset: [top, left],
|
offset: [top, left],
|
||||||
content: menu, //iframe的url,
|
content: menu, //iframe的url,
|
||||||
success: function(layero, index) {
|
success: function(layero, index) {
|
||||||
|
layer.close(lastIndex);
|
||||||
|
lastIndex = index;
|
||||||
menuEvent(option,index);
|
menuEvent(option,index);
|
||||||
console.log("初始化")
|
|
||||||
var timer;
|
var timer;
|
||||||
$(layero).on('mouseout', function() {
|
$(layero).on('mouseout', function() {
|
||||||
timer = setTimeout(function() {
|
timer = setTimeout(function() {
|
||||||
|
|
@ -99,6 +102,12 @@ layui.define(['jquery', 'element'], function(exports) {
|
||||||
$(layero).on('mouseover', function() {
|
$(layero).on('mouseover', function() {
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 清除 item 右击
|
||||||
|
$(layero).on('contextmenu',function(){
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue