顶部菜单切换事件
parent
1e66f6067a
commit
976bf86401
|
|
@ -39,7 +39,8 @@ layui.define(['table', 'jquery', 'element', 'form', 'pearTab', 'pearMenu', 'pear
|
||||||
defaultOpen: 0, //默认打开菜单
|
defaultOpen: 0, //默认打开菜单
|
||||||
accordion: true,
|
accordion: true,
|
||||||
url: option.data, //数据地址
|
url: option.data, //数据地址
|
||||||
parseData: false //请求后是否进行数据解析 函数
|
parseData: false, //请求后是否进行数据解析 函数
|
||||||
|
change: option.change
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -88,7 +89,7 @@ layui.define(['table', 'jquery', 'element', 'form', 'pearTab', 'pearMenu', 'pear
|
||||||
url: data.menuUrl,
|
url: data.menuUrl,
|
||||||
icon: data.menuIcon,
|
icon: data.menuIcon,
|
||||||
close: true
|
close: true
|
||||||
},300);
|
}, 300);
|
||||||
|
|
||||||
compatible();
|
compatible();
|
||||||
})
|
})
|
||||||
|
|
@ -110,7 +111,7 @@ layui.define(['table', 'jquery', 'element', 'form', 'pearTab', 'pearMenu', 'pear
|
||||||
|
|
||||||
sideMenu.click(function(dom, data) {
|
sideMenu.click(function(dom, data) {
|
||||||
|
|
||||||
compatible();
|
compatible();
|
||||||
bodyFrame.changePage(data.menuUrl, data.menuTitle, true);
|
bodyFrame.changePage(data.menuUrl, data.menuTitle, true);
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
@ -121,12 +122,12 @@ layui.define(['table', 'jquery', 'element', 'form', 'pearTab', 'pearMenu', 'pear
|
||||||
this.keepLoad = function(option) {
|
this.keepLoad = function(option) {
|
||||||
// 关 闭 加 载 层
|
// 关 闭 加 载 层
|
||||||
compatible();
|
compatible();
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
|
||||||
$(".preloader").fadeOut(option.done);
|
$(".preloader").fadeOut(option.done);
|
||||||
|
|
||||||
// 设 置 关 闭 时 间
|
// 设 置 关 闭 时 间
|
||||||
}, option.keepLoad)
|
}, option.keepLoad)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -140,19 +141,19 @@ layui.define(['table', 'jquery', 'element', 'form', 'pearTab', 'pearMenu', 'pear
|
||||||
style +=
|
style +=
|
||||||
'.light-theme .pear-nav-tree .layui-this a:hover,.light-theme .pear-nav-tree .layui-this,.light-theme .pear-nav-tree .layui-this a,.pear-nav-tree .layui-this a,.pear-nav-tree .layui-this{background-color: ' +
|
'.light-theme .pear-nav-tree .layui-this a:hover,.light-theme .pear-nav-tree .layui-this,.light-theme .pear-nav-tree .layui-this a,.pear-nav-tree .layui-this a,.pear-nav-tree .layui-this{background-color: ' +
|
||||||
color + '!important;}';
|
color + '!important;}';
|
||||||
|
|
||||||
// 自定义 Logo 标题演示
|
// 自定义 Logo 标题演示
|
||||||
style+=
|
style +=
|
||||||
'.pear-admin .layui-logo .title{color:'+
|
'.pear-admin .layui-logo .title{color:' +
|
||||||
color+'!important;}';
|
color + '!important;}';
|
||||||
|
|
||||||
// 自 定 义 标 签 配 色
|
// 自 定 义 标 签 配 色
|
||||||
style += '.pear-frame-title .dot,.pear-tab .layui-this .pear-tab-active{background-color: ' + color +
|
style += '.pear-frame-title .dot,.pear-tab .layui-this .pear-tab-active{background-color: ' + color +
|
||||||
'!important;}';
|
'!important;}';
|
||||||
|
|
||||||
// 自 定 义 快 捷 菜 单
|
// 自 定 义 快 捷 菜 单
|
||||||
style += '.bottom-nav li a:hover{background-color:'+
|
style += '.bottom-nav li a:hover{background-color:' +
|
||||||
color +'!important;}';
|
color + '!important;}';
|
||||||
|
|
||||||
// 自 定 义 顶 部 配 色
|
// 自 定 义 顶 部 配 色
|
||||||
style += '.pear-admin .layui-header .layui-nav .layui-nav-bar{background-color: ' + color + '!important;}'
|
style += '.pear-admin .layui-header .layui-nav .layui-nav-bar{background-color: ' + color + '!important;}'
|
||||||
|
|
@ -169,7 +170,7 @@ layui.define(['table', 'jquery', 'element', 'form', 'pearTab', 'pearMenu', 'pear
|
||||||
|
|
||||||
// 自 定 义 滚 动 条 样 式
|
// 自 定 义 滚 动 条 样 式
|
||||||
|
|
||||||
localStorage.setItem("theme-color", color);
|
localStorage.setItem("theme-color", color);
|
||||||
|
|
||||||
if ($("iframe").contents().find("#customTheme").length > 0) {
|
if ($("iframe").contents().find("#customTheme").length > 0) {
|
||||||
|
|
||||||
|
|
@ -179,7 +180,7 @@ layui.define(['table', 'jquery', 'element', 'form', 'pearTab', 'pearMenu', 'pear
|
||||||
|
|
||||||
|
|
||||||
var theme = "<style>";
|
var theme = "<style>";
|
||||||
|
|
||||||
theme += '</style>';
|
theme += '</style>';
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -189,11 +190,8 @@ layui.define(['table', 'jquery', 'element', 'form', 'pearTab', 'pearMenu', 'pear
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.themeRender = function(option) {
|
this.themeRender = function(option) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var color = localStorage.getItem("theme-color");
|
var color = localStorage.getItem("theme-color");
|
||||||
|
|
||||||
var menu = localStorage.getItem("theme-menu");
|
var menu = localStorage.getItem("theme-menu");
|
||||||
|
|
@ -245,9 +243,9 @@ layui.define(['table', 'jquery', 'element', 'form', 'pearTab', 'pearMenu', 'pear
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function compatible(){
|
function compatible() {
|
||||||
if ($(window).width() <= 768) {
|
if ($(window).width() <= 768) {
|
||||||
sideMenu.collaspe();
|
sideMenu.collaspe();
|
||||||
if ($(".pear-admin").is(".pear-mini")) {
|
if ($(".pear-admin").is(".pear-mini")) {
|
||||||
$(".pear-admin").removeClass("pear-mini");
|
$(".pear-admin").removeClass("pear-mini");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ layui.define(['table', 'jquery', 'element'], function (exports) {
|
||||||
height:opt.height,
|
height:opt.height,
|
||||||
theme:opt.theme,
|
theme:opt.theme,
|
||||||
data:opt.data ? opt.data:[],
|
data:opt.data ? opt.data:[],
|
||||||
|
change: opt.change ? opt.change:function(){console.log("切换") },
|
||||||
done:opt.done ? opt.done: function(){ console.log("菜单渲染成功");}
|
done:opt.done ? opt.done: function(){ console.log("菜单渲染成功");}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -242,14 +243,14 @@ layui.define(['table', 'jquery', 'element'], function (exports) {
|
||||||
|
|
||||||
if(index === option.defaultMenu){
|
if(index === option.defaultMenu){
|
||||||
|
|
||||||
controlItem = '<li pear-id="'+item.id+'" class="layui-this layui-nav-item"><a href="#">'+item.title+'</a></li>';
|
controlItem = '<li pear-href="'+item.href+'" pear-title="'+item.title+'" pear-id="'+item.id+'" class="layui-this layui-nav-item"><a href="#">'+item.title+'</a></li>';
|
||||||
|
|
||||||
menuItem = '<ul pear-id="'+item.id+'" lay-filter="'+option.elem+'" class="layui-nav arrow layui-nav-tree pear-nav-tree">';
|
menuItem = '<ul pear-id="'+item.id+'" lay-filter="'+option.elem+'" class="layui-nav arrow layui-nav-tree pear-nav-tree">';
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
|
|
||||||
controlItem = '<li pear-id="'+item.id+'" class="layui-nav-item"><a href="#">'+item.title+'</a></li>';
|
controlItem = '<li pear-href="'+item.href+'" pear-title="'+item.title+'" pear-id="'+item.id+'" class="layui-nav-item"><a href="#">'+item.title+'</a></li>';
|
||||||
|
|
||||||
menuItem = '<ul style="display:none" pear-id="'+item.id+'" lay-filter="'+option.elem+'" class="layui-nav arrow layui-nav-tree pear-nav-tree">';
|
menuItem = '<ul style="display:none" pear-id="'+item.id+'" lay-filter="'+option.elem+'" class="layui-nav arrow layui-nav-tree pear-nav-tree">';
|
||||||
|
|
||||||
|
|
@ -314,12 +315,9 @@ layui.define(['table', 'jquery', 'element'], function (exports) {
|
||||||
|
|
||||||
$("#"+option.elem).find(".pear-nav-tree[pear-id='"+$(this).attr("pear-id")+"']").css({display:'block'});
|
$("#"+option.elem).find(".pear-nav-tree[pear-id='"+$(this).attr("pear-id")+"']").css({display:'block'});
|
||||||
|
|
||||||
|
option.change($(this).attr("pear-id"),$(this).attr("pear-title"),$(this).attr("pear-href"))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 加载子菜单 (递归)*/
|
/** 加载子菜单 (递归)*/
|
||||||
|
|
|
||||||
|
|
@ -72,10 +72,14 @@
|
||||||
var config = {
|
var config = {
|
||||||
keepLoad: 1200, // 主 页 加 载 过 度 时 长 可为 false
|
keepLoad: 1200, // 主 页 加 载 过 度 时 长 可为 false
|
||||||
muiltTab: true, // 是 否 开 启 多 标 签 页 true 开启 false 关闭
|
muiltTab: true, // 是 否 开 启 多 标 签 页 true 开启 false 关闭
|
||||||
control: false, // 是 否 开 启 多 系 统 菜 单 true 开启 false 关闭
|
control: true, // 是 否 开 启 多 系 统 菜 单 true 开启 false 关闭
|
||||||
theme: "dark-theme", // 默 认 主 题 样 式 dark-theme 默认主题 light-theme 亮主题
|
theme: "dark-theme", // 默 认 主 题 样 式 dark-theme 默认主题 light-theme 亮主题
|
||||||
index: 'view/console/console1.html', // 默 认 加 载 主 页
|
index: 'view/console/console1.html', // 默 认 加 载 主 页
|
||||||
data: 'admin/data/menu.json', // 菜 单 数 据 加 载 地 址
|
data: 'admin/data/menu.json', // 菜 单 数 据 加 载 地 址
|
||||||
|
change: function(id,title,href){
|
||||||
|
|
||||||
|
// 顶部菜单切换事件
|
||||||
|
},
|
||||||
done: function() {
|
done: function() {
|
||||||
/** 框架初始化 */
|
/** 框架初始化 */
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue