parent
d248395ba8
commit
f8f0cf8925
|
|
@ -80,6 +80,7 @@ layui.define(['table', 'jquery', 'element', 'yaml', 'form', 'tab', 'menu', 'fram
|
|||
async: param.menu.async !== undefined ? param.menu.async : true,
|
||||
theme: "dark-theme",
|
||||
height: '100%',
|
||||
method: param.menu.method,
|
||||
control: param.menu.control ? 'control' : false, // control
|
||||
defaultMenu: 0,
|
||||
accordion: param.menu.accordion,
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ layui.define(['table', 'jquery', 'element'], function(exports) {
|
|||
async: opt.async,
|
||||
parseData: opt.parseData,
|
||||
url: opt.url,
|
||||
method: opt.method ? opt.method : "GET",
|
||||
defaultOpen: opt.defaultOpen,
|
||||
defaultSelect: opt.defaultSelect,
|
||||
control: opt.control,
|
||||
|
|
@ -28,10 +29,17 @@ layui.define(['table', 'jquery', 'element'], function(exports) {
|
|||
done: opt.done ? opt.done : function() {}
|
||||
}
|
||||
if (option.async) {
|
||||
getData(option.url).then(function(data) {
|
||||
option.data = data;
|
||||
renderMenu(option);
|
||||
});
|
||||
if (option.method === "GET") {
|
||||
getData(option.url).then(function(data) {
|
||||
option.data = data;
|
||||
renderMenu(option);
|
||||
});
|
||||
} else {
|
||||
postData(option.url).then(function(data) {
|
||||
option.data = data;
|
||||
renderMenu(option);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
//renderMenu中需要调用done事件,done事件中需要menu对象,但是此时还未返回menu对象,做个延时提前返回对象
|
||||
window.setTimeout(function() {
|
||||
|
|
@ -66,11 +74,11 @@ layui.define(['table', 'jquery', 'element'], function(exports) {
|
|||
data['menuPath'] = domsss.find("span").text() + " / " + data['menuPath'];
|
||||
}
|
||||
if ($("#" + _this.option.elem).is(".pear-nav-mini")) {
|
||||
if(_this.option.accordion){
|
||||
activeMenus = $(this).parent().parent().parent().children("a");
|
||||
}else{
|
||||
activeMenus.push($(this).parent().parent().parent().children("a"));
|
||||
}
|
||||
if (_this.option.accordion) {
|
||||
activeMenus = $(this).parent().parent().parent().children("a");
|
||||
} else {
|
||||
activeMenus.push($(this).parent().parent().parent().children("a"));
|
||||
}
|
||||
}
|
||||
clickEvent(dom, data);
|
||||
})
|
||||
|
|
@ -147,6 +155,14 @@ layui.define(['table', 'jquery', 'element'], function(exports) {
|
|||
return defer.promise();
|
||||
}
|
||||
|
||||
function postData(url) {
|
||||
var defer = $.Deferred();
|
||||
$.post(url + "?fresh=" + Math.random(), function(result) {
|
||||
defer.resolve(result)
|
||||
});
|
||||
return defer.promise();
|
||||
}
|
||||
|
||||
function renderMenu(option) {
|
||||
if (option.parseData != false) {
|
||||
option.parseData(option.data);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ logo:
|
|||
menu:
|
||||
## 菜单数据来源
|
||||
data: "admin/data/menu.json"
|
||||
## 菜单接口的请求方式 GET / POST
|
||||
method: "GET"
|
||||
## 是否同时只打开一个菜单目录
|
||||
accordion: true
|
||||
## 是否开启多系统菜单模式
|
||||
|
|
|
|||
Loading…
Reference in New Issue