当前页层级结构
parent
c95b699e13
commit
93854b6082
|
|
@ -99,7 +99,7 @@ layui.define(['table', 'jquery', 'element', 'form', 'pearTab', 'pearMenu', 'pear
|
||||||
// 选 项 卡 初 始 API 文 档
|
// 选 项 卡 初 始 API 文 档
|
||||||
bodyFrame = pearFrame.render({
|
bodyFrame = pearFrame.render({
|
||||||
elem: 'content',
|
elem: 'content',
|
||||||
title: '首 页',
|
title: '工作空间 / 首页',
|
||||||
url: option.index,
|
url: option.index,
|
||||||
width: '100%',
|
width: '100%',
|
||||||
height: '100%'
|
height: '100%'
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,12 @@ 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("切换") },
|
change: opt.change ? opt.change : function() {
|
||||||
done:opt.done ? opt.done: function(){ console.log("菜单渲染成功");}
|
console.log("切换")
|
||||||
|
},
|
||||||
|
done: opt.done ? opt.done : function() {
|
||||||
|
console.log("菜单渲染成功");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -63,12 +67,45 @@ layui.define(['table', 'jquery', 'element'], function (exports) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
$("#" + _this.option.elem + " .site-demo-active").parent().click(function() {
|
$("#" + _this.option.elem + " .site-demo-active").parent().click(function() {
|
||||||
var dom = $(this).children(".site-demo-active");
|
var dom = $(this).children(".site-demo-active");
|
||||||
var data = {menuId:dom.attr("menu-id"),menuTitle:dom.attr("menu-title"),menuIcon:dom.attr("menu-icon"),menuUrl:dom.attr("menu-url")};
|
var data = {
|
||||||
|
menuId: dom.attr("menu-id"),
|
||||||
|
menuTitle: dom.attr("menu-title"),
|
||||||
|
menuIcon: dom.attr("menu-icon"),
|
||||||
|
menuUrl: dom.attr("menu-url")
|
||||||
|
};
|
||||||
|
|
||||||
|
var doms = hash(dom);
|
||||||
|
|
||||||
|
if (doms.text() != '') {
|
||||||
|
data['menuTitle'] = doms.find("span").text() + " / " + data['menuTitle'];
|
||||||
|
|
||||||
|
}
|
||||||
|
var domss = hash(doms);
|
||||||
|
|
||||||
|
if (domss.text() != '') {
|
||||||
|
|
||||||
|
data['menuTitle'] = domss.find("span").text() + " / " + data['menuTitle'];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
var domsss = hash(domss);
|
||||||
|
|
||||||
|
if (domsss.text() != '') {
|
||||||
|
|
||||||
|
data['menuTitle'] = domsss.find("span").text() + " / " + data['menuTitle'];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
clickEvent(dom, data);
|
clickEvent(dom, data);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hash(dom) {
|
||||||
|
|
||||||
|
return dom.parent().parent().prev();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
pearMenu.prototype.skin = function(skin) {
|
pearMenu.prototype.skin = function(skin) {
|
||||||
|
|
||||||
|
|
@ -85,11 +122,16 @@ layui.define(['table', 'jquery', 'element'], function (exports) {
|
||||||
|
|
||||||
if (this.option.control != false) {
|
if (this.option.control != false) {
|
||||||
|
|
||||||
$("#"+this.option.elem+" a[menu-id='"+pearId+"']").parents(".layui-side-scroll ").find("ul").css({display:"none"});
|
$("#" + this.option.elem + " a[menu-id='" + pearId + "']").parents(".layui-side-scroll ").find("ul").css({
|
||||||
|
display: "none"
|
||||||
|
});
|
||||||
|
|
||||||
$("#"+this.option.elem+" a[menu-id='"+pearId+"']").parents(".layui-side-scroll ").find(".layui-this").removeClass("layui-this");
|
$("#" + this.option.elem + " a[menu-id='" + pearId + "']").parents(".layui-side-scroll ").find(".layui-this").removeClass(
|
||||||
|
"layui-this");
|
||||||
|
|
||||||
$("#"+this.option.elem+" a[menu-id='"+pearId+"']").parents("ul").css({display:"block"});
|
$("#" + this.option.elem + " a[menu-id='" + pearId + "']").parents("ul").css({
|
||||||
|
display: "block"
|
||||||
|
});
|
||||||
|
|
||||||
var controlId = $("#" + this.option.elem + " a[menu-id='" + pearId + "']").parents("ul").attr("pear-id");
|
var controlId = $("#" + this.option.elem + " a[menu-id='" + pearId + "']").parents("ul").attr("pear-id");
|
||||||
|
|
||||||
|
|
@ -102,9 +144,11 @@ layui.define(['table', 'jquery', 'element'], function (exports) {
|
||||||
// 根 据 菜 单 Id 选 中 菜 单 项 目
|
// 根 据 菜 单 Id 选 中 菜 单 项 目
|
||||||
|
|
||||||
|
|
||||||
$("#"+this.option.elem+" a[menu-id='"+pearId+"']").parents(".pear-nav-tree").find(".layui-nav-itemed").removeClass("layui-nav-itemed");
|
$("#" + this.option.elem + " a[menu-id='" + pearId + "']").parents(".pear-nav-tree").find(".layui-nav-itemed").removeClass(
|
||||||
|
"layui-nav-itemed");
|
||||||
|
|
||||||
$("#"+this.option.elem+" a[menu-id='"+pearId+"']").parents(".pear-nav-tree").find(".layui-this").removeClass("layui-this");
|
$("#" + this.option.elem + " a[menu-id='" + pearId + "']").parents(".pear-nav-tree").find(".layui-this").removeClass(
|
||||||
|
"layui-this");
|
||||||
|
|
||||||
// 通 过 动 画 打 开 当 前 菜 单 项 layui-nav-child
|
// 通 过 动 画 打 开 当 前 菜 单 项 layui-nav-child
|
||||||
|
|
||||||
|
|
@ -176,7 +220,8 @@ layui.define(['table', 'jquery', 'element'], function (exports) {
|
||||||
|
|
||||||
function createMenu(option) {
|
function createMenu(option) {
|
||||||
// 声 明 头 部
|
// 声 明 头 部
|
||||||
var menuHtml = '<ul lay-filter="'+option.elem+'" class="layui-nav arrow pear-menu layui-nav-tree pear-nav-tree">'
|
var menuHtml = '<ul lay-filter="' + option.elem +
|
||||||
|
'" class="layui-nav arrow pear-menu layui-nav-tree pear-nav-tree">'
|
||||||
// 开 启 同 步 操 作
|
// 开 启 同 步 操 作
|
||||||
$.each(option.data, function(i, item) {
|
$.each(option.data, function(i, item) {
|
||||||
// 创 建 每 一 个 菜 单 项
|
// 创 建 每 一 个 菜 单 项
|
||||||
|
|
@ -201,11 +246,13 @@ layui.define(['table', 'jquery', 'element'], function (exports) {
|
||||||
// 判 断 菜 单 类 型 0 是 不可跳转的目录 1 是 可 点 击 跳 转 的 菜 单
|
// 判 断 菜 单 类 型 0 是 不可跳转的目录 1 是 可 点 击 跳 转 的 菜 单
|
||||||
if (item.type == 0) {
|
if (item.type == 0) {
|
||||||
// 创 建 目 录 结 构
|
// 创 建 目 录 结 构
|
||||||
content += '<a href="javascript:;" menu-type="'+item.type+'" menu-id="'+item.id+'" href="'+ href +'" '+ target +'><i class="' + item.icon + '"></i><span>' + item.title +
|
content += '<a href="javascript:;" menu-type="' + item.type + '" menu-id="' + item.id + '" href="' + href +
|
||||||
|
'" ' + target + '><i class="' + item.icon + '"></i><span>' + item.title +
|
||||||
'</span></a>';
|
'</span></a>';
|
||||||
} else if (item.type == 1) {
|
} else if (item.type == 1) {
|
||||||
// 创 建 菜 单 结 构
|
// 创 建 菜 单 结 构
|
||||||
content += '<a class="'+calss+'" menu-type="'+item.type+'" menu-url="' + item.href + '" menu-id="' + item.id +
|
content += '<a class="' + calss + '" menu-type="' + item.type + '" menu-url="' + item.href + '" menu-id="' +
|
||||||
|
item.id +
|
||||||
'" menu-title="' + item.title + '" href="' + href + '" ' + target + '><i class="' + item.icon +
|
'" menu-title="' + item.title + '" href="' + href + '" ' + target + '><i class="' + item.icon +
|
||||||
'"></i><span>' + item.title + '</span></a>';
|
'"></i><span>' + item.title + '</span></a>';
|
||||||
}
|
}
|
||||||
|
|
@ -243,16 +290,20 @@ layui.define(['table', 'jquery', 'element'], function (exports) {
|
||||||
|
|
||||||
if (index === option.defaultMenu) {
|
if (index === option.defaultMenu) {
|
||||||
|
|
||||||
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>';
|
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-href="'+item.href+'" pear-title="'+item.title+'" 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">';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -280,11 +331,13 @@ layui.define(['table', 'jquery', 'element'], function (exports) {
|
||||||
// 判 断 菜 单 类 型 0 是 不可跳转的目录 1 是 可 点 击 跳 转 的 菜 单
|
// 判 断 菜 单 类 型 0 是 不可跳转的目录 1 是 可 点 击 跳 转 的 菜 单
|
||||||
if (note.type == 0) {
|
if (note.type == 0) {
|
||||||
// 创 建 目 录 结 构
|
// 创 建 目 录 结 构
|
||||||
content += '<a href="'+href+'" '+ target +' menu-type="'+note.type+'" menu-id="'+note.id+'" ><i class="' + note.icon + '"></i><span>' + note.title +
|
content += '<a href="' + href + '" ' + target + ' menu-type="' + note.type + '" menu-id="' + note.id +
|
||||||
|
'" ><i class="' + note.icon + '"></i><span>' + note.title +
|
||||||
'</span></a>';
|
'</span></a>';
|
||||||
} else if (note.type == 1) {
|
} else if (note.type == 1) {
|
||||||
// 创 建 菜 单 结 构
|
// 创 建 菜 单 结 构
|
||||||
content += '<a '+ target +' class="'+calss+'" menu-type="'+note.type+'" menu-url="' + note.href + '" menu-id="' + note.id +
|
content += '<a ' + target + ' class="' + calss + '" menu-type="' + note.type + '" menu-url="' + note.href +
|
||||||
|
'" menu-id="' + note.id +
|
||||||
'" menu-title="' + note.title + '" href="' + href + '"><i class="' + note.icon +
|
'" menu-title="' + note.title + '" href="' + href + '"><i class="' + note.icon +
|
||||||
'"></i><span>' + note.title + '</span></a>';
|
'"></i><span>' + note.title + '</span></a>';
|
||||||
}
|
}
|
||||||
|
|
@ -311,9 +364,13 @@ layui.define(['table', 'jquery', 'element'], function (exports) {
|
||||||
|
|
||||||
$("#" + option.control + " .pear-nav-control").on("click", "li", function() {
|
$("#" + option.control + " .pear-nav-control").on("click", "li", function() {
|
||||||
|
|
||||||
$("#"+option.elem).find(".pear-nav-tree").css({display:'none'});
|
$("#" + option.elem).find(".pear-nav-tree").css({
|
||||||
|
display: 'none'
|
||||||
|
});
|
||||||
|
|
||||||
$("#"+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"))
|
option.change($(this).attr("pear-id"), $(this).attr("pear-title"), $(this).attr("pear-href"))
|
||||||
})
|
})
|
||||||
|
|
@ -353,10 +410,13 @@ layui.define(['table', 'jquery', 'element'], function (exports) {
|
||||||
// 判 断 子 项 类 型
|
// 判 断 子 项 类 型
|
||||||
if (note.type == 0) {
|
if (note.type == 0) {
|
||||||
// 创 建 目 录 结 构
|
// 创 建 目 录 结 构
|
||||||
content += '<a '+ target +' href="'+href+'" menu-type="'+note.type+'" menu-id="'+note.id+'"><i class="' + note.icon + '"></i><span>' + note.title + '</span></a>';
|
content += '<a ' + target + ' href="' + href + '" menu-type="' + note.type + '" menu-id="' + note.id +
|
||||||
|
'"><i class="' + note.icon + '"></i><span>' + note.title + '</span></a>';
|
||||||
} else if (note.type == 1) {
|
} else if (note.type == 1) {
|
||||||
// 创 建 菜 单 结 构
|
// 创 建 菜 单 结 构
|
||||||
content += '<a '+ target +' class="'+calss+'" menu-type="'+note.type+'" menu-url="' + note.href + '" menu-id="' + note.id +'" menu-title="' + note.title + '" menu-icon="' + note.icon + '" href="'+href+'" ><i class="' + note.icon +'"></i><span>' + note.title + '</span></a>';
|
content += '<a ' + target + ' class="' + calss + '" menu-type="' + note.type + '" menu-url="' + note.href +
|
||||||
|
'" menu-id="' + note.id + '" menu-title="' + note.title + '" menu-icon="' + note.icon + '" href="' + href +
|
||||||
|
'" ><i class="' + note.icon + '"></i><span>' + note.title + '</span></a>';
|
||||||
}
|
}
|
||||||
// 加 载 子 项 目 录
|
// 加 载 子 项 目 录
|
||||||
content += loadchild(note);
|
content += loadchild(note);
|
||||||
|
|
@ -440,15 +500,21 @@ layui.define(['table', 'jquery', 'element'], function (exports) {
|
||||||
|
|
||||||
var left = $(this).offset().left + 132;
|
var left = $(this).offset().left + 132;
|
||||||
|
|
||||||
$(this).children(".layui-nav-child").offset({left:left});
|
$(this).children(".layui-nav-child").offset({
|
||||||
|
left: left
|
||||||
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
var left = $(this).offset().left + 62;
|
var left = $(this).offset().left + 62;
|
||||||
|
|
||||||
$(this).children(".layui-nav-child").offset({left:left});
|
$(this).children(".layui-nav-child").offset({
|
||||||
|
left: left
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
$(this).children(".layui-nav-child").offset({top:top});
|
$(this).children(".layui-nav-child").offset({
|
||||||
|
top: top
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -458,9 +524,13 @@ layui.define(['table', 'jquery', 'element'], function (exports) {
|
||||||
|
|
||||||
//判断当前是dd,还是 layui-nav-item
|
//判断当前是dd,还是 layui-nav-item
|
||||||
|
|
||||||
$(this).children(".layui-nav-child").css({left: '0px'});
|
$(this).children(".layui-nav-child").css({
|
||||||
|
left: '0px'
|
||||||
|
});
|
||||||
|
|
||||||
$(this).children(".layui-nav-child").css({top: '0px'});
|
$(this).children(".layui-nav-child").css({
|
||||||
|
top: '0px'
|
||||||
|
});
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
$("#" + option.elem + " .layui-nav-item").off('mouseenter').unbind('mouseleave');
|
$("#" + option.elem + " .layui-nav-item").off('mouseenter').unbind('mouseleave');
|
||||||
|
|
|
||||||
|
|
@ -71,18 +71,11 @@
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
keepLoad: 1200, // 主 页 加 载 过 度 时 长 可为 false
|
keepLoad: 1200, // 主 页 加 载 过 度 时 长 可为 false
|
||||||
muiltTab: true, // 是 否 开 启 多 标 签 页 true 开启 false 关闭
|
muiltTab: false, // 是 否 开 启 多 标 签 页 true 开启 false 关闭
|
||||||
control: false, // 是 否 开 启 多 系 统 菜 单 true 开启 false 关闭
|
control: false, // 是 否 开 启 多 系 统 菜 单 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() {
|
|
||||||
/** 框架初始化 */
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pearAdmin.render(config);
|
pearAdmin.render(config);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue