修改menu请求方式

v1.0
bobi 2019-05-18 19:45:12 +08:00
parent 79c45ee16d
commit e81a4370ad
4 changed files with 331 additions and 220 deletions

View File

@ -2,241 +2,281 @@
"status": 1000, "status": 1000,
"msg": "操作成功", "msg": "操作成功",
"data": [ "data": [
{
"title": "图表管理",
"icon": "",
"href": "",
"spread": false,
"children": [
{
"title": "地图",
"fontFamily": "my-icon",
"icon": "my-iconditu",
"spread": false,
"children": [
{
"title": "中国地图",
"icon": "",
"href": "pages/echarts/mapchina2.html",
"spread": false
},
{
"title": "地区地图",
"icon": "",
"href": "pages/echarts/mapchina.html",
"spread": false
}
]
},
{
"title": "数据图",
"fontFamily": "my-icon",
"icon": "my-icontubiao",
"spread": false,
"children": [
{
"title": "统计图",
"icon": "",
"href": "pages/echarts/map1.html",
"spread": false
},
{
"title": "折线图",
"icon": "",
"href": "pages/echarts/map2.html",
"spread": false
},
{
"title": "馅饼图",
"icon": "",
"href": "pages/echarts/map4.html",
"spread": false
},
{
"title": "圆形图",
"icon": "",
"href": "pages/echarts/map5.html",
"spread": false
},
{
"title": "指数图",
"icon": "",
"href": "pages/echarts/map6.html",
"spread": false
}
]
}
]
},
{
"title": "框架使用说明",
"fontFamily": "ok-icon",
"icon": "",
"spread": false,
"children": [
{
"title": "插件目录",
"href": "pages/help/plugDirectory.html",
"spread": false
},
{
"title": "内部添加导航",
"href": "pages/help/navOperate.html",
"spread": false
},
{
"title": "导航的图标",
"href": "pages/help/navIcon.html",
"spread": false
},
{
"title": "导航的参数",
"href": "pages/help/navParameter.html",
"spread": false
}
]
},
{
"title": "第三方js库",
"icon": "",
"children": [
{
"title": "二维码",
"href": "pages/tripartite/qrcode.html"
}
]
},
{ {
"title": "会员管理", "title": "会员管理",
"icon": "", "path": "",
"href": "", "font": "iconfont",
"spread": false, "icon": "",
"spread": true,
"children": [ "children": [
{ {
"title": "用户列表", "title": "用户列表",
"fontFamily": "layui-icon", "path": "pages/user/user.html",
"icon": "", "font": "iconfont",
"href": "pages/user/user.html", "icon": "",
"spread": false "spread": false
}, },
{ {
"title": "角色列表", "title": "角色列表",
"icon": "", "path": "pages/role/role.html",
"href": "pages/role/role.html", "font": "iconfont",
"icon": "",
"spread": false "spread": false
}, },
{ {
"title": "权限列表", "title": "权限列表",
"icon": "", "path": "pages/permission/permission.html",
"href": "pages/permission/permission.html", "font": "iconfont",
"icon": "",
"spread": false "spread": false
} }
] ]
}, },
{ {
"title": "新闻管理", "title": "新闻管理",
"icon": "", "path": "",
"href": "", "font": "iconfont",
"icon": "",
"spread": false, "spread": false,
"children": [ "children": [
{ {
"title": "文章列表", "title": "新闻列表",
"fontFamily": "layui-icon", "path": "pages/article/article.html",
"icon": "", "font": "iconfont",
"href": "pages/article/article.html", "icon": "",
"spread": false "spread": false
} }
] ]
}, },
{ {
"title": "多级导航", "title": "留言管理",
"fontFamily": "ok-icon", "path": "",
"icon": "ok-iconnavigation-2", "font": "iconfont",
"icon": "",
"spread": false, "spread": false,
"children": [ "children": [
{ {
"title": "二级导航", "title": "留言列表",
"href": "", "path": "pages/message/message.html",
"spread": false, "font": "iconfont",
"children": [ "icon": "",
{ "spread": false
"title": "三级导航1", }
"fontFamily": "ok-icon", ]
"icon": "ok-iconairplay", },
"href": "pages/home.html", {
"spread": false "title": "下载中心",
}, "path": "",
{ "font": "iconfont",
"title": "三级导航2", "icon": "",
"href": "", "spread": false,
"spread": false, "children": [
"children": [ {
{ "title": "下载列表",
"title": "四级导航1", "path": "pages/download/download.html",
"href": "", "font": "iconfont",
"spread": false "icon": "",
}, "spread": false
{ }
"title": "四级导航2", ]
"href": "", },
"spread": false, {
"children": [ "title": "友情链接",
{ "path": "",
"title": "五级导航", "font": "iconfont",
"fontFamily": "ok-icon", "icon": "",
"icon": "&#xe971", "spread": false,
"href": "", "children": [
"spread": false {
}, "title": "链接列表",
{ "path": "pages/link/link.html",
"title": "五级导航", "font": "iconfont",
"href": "", "icon": "",
"spread": false "spread": false
}, }
{ ]
"title": "登录", },
"icon": "", {
"href": "pages/login.html", "title": "产品管理",
"spread": false, "path": "",
"target": "_blank" "font": "iconfont",
} "icon": "",
] "spread": false,
} "children": [
] {
} "title": "产品列表",
] "path": "pages/product/product.html",
"font": "iconfont",
"icon": "",
"spread": false
}
]
},
{
"title": "图表页面",
"path": "",
"font": "layui-icon",
"icon": "",
"spread": false,
"children": [
{
"title": "柱状图",
"path": "pages/map/map1.html",
"font": "iconfont",
"icon": "",
"spread": false
},
{
"title": "折线图",
"path": "pages/map/map2.html",
"font": "iconfont",
"icon": "",
"spread": false
},
{
"title": "折线堆叠图",
"path": "pages/map/map3.html",
"font": "iconfont",
"icon": "",
"spread": false
},
{
"title": "饼图",
"path": "pages/map/map4.html",
"font": "iconfont",
"icon": "",
"spread": false
},
{
"title": "环形图",
"path": "pages/map/map5.html",
"font": "iconfont",
"icon": "",
"spread": false
},
{
"title": "散布图",
"path": "pages/map/map6.html",
"font": "iconfont",
"icon": "",
"spread": false
} }
] ]
}, },
{ {
"title": "系统管理", "title": "系统管理",
"icon": "", "path": "",
"href": "", "font": "layui-icon",
"icon": "",
"spread": false, "spread": false,
"children": [ "children": [
{ {
"title": "登录", "title": "网站配置",
"icon": "", "path": "pages/system/system-setting.html",
"href": "pages/login.html", "font": "iconfont",
"spread": false, "icon": "",
"target": "_blank" "spread": false
},
{
"title": "系统日志",
"path": "pages/system/system-log.html",
"font": "iconfont",
"icon": "",
"spread": false
},
{
"title": "屏蔽词",
"path": "pages/system/system-shield.html",
"font": "iconfont",
"icon": "",
"spread": false
}
]
},
{
"title": "框架使用",
"path": "",
"font": "iconfont",
"icon": "",
"spread": false,
"children": [
{
"title": "okTab使用",
"path": "pages/use/use-okTab.html",
"font": "iconfont",
"icon": "",
"spread": false
},
{
"title": "okLayer使用",
"path": "pages/use/use-okLayer.html",
"font": "iconfont",
"icon": "",
"spread": false
},
{
"title": "okUtils使用",
"path": "pages/use/use-okUtils.html",
"font": "iconfont",
"icon": "",
"spread": false
},
{
"title": "Layui图标",
"path": "https://www.layui.com/doc/element/icon.html",
"font": "iconfont",
"icon": "",
"spread": false
},
{
"title": "Iconfont图标",
"path": "font/demo_index.html",
"font": "iconfont",
"icon": "",
"spread": false
}
]
},
{
"title": "其他页面",
"path": "",
"font": "iconfont",
"icon": "",
"spread": false,
"children": [
{
"title": "登陆页面",
"path": "pages/use/use-okTab.html",
"font": "iconfont",
"icon": "",
"spread": false
}, },
{ {
"title": "403页面", "title": "403页面",
"icon": "", "path": "pages/use/use-okLayer.html",
"href": "pages/common/403.html", "font": "iconfont",
"icon": "",
"spread": false "spread": false
}, },
{ {
"title": "404页面", "title": "404页面",
"icon": "", "path": "pages/use/use-okUtils.html",
"href": "pages/common/404.html", "font": "iconfont",
"icon": "",
"spread": false "spread": false
}, },
{ {
"title": "500页面", "title": "500页面",
"icon": "", "path": "https://www.layui.com/doc/element/icon.html",
"href": "pages/common/500.html", "font": "iconfont",
"icon": "",
"spread": false
},
{
"title": "捐赠列表",
"path": "font/demo_index.html",
"font": "iconfont",
"icon": "",
"spread": false "spread": false
} }
] ]

View File

@ -45,6 +45,7 @@
<div class="layui-side layui-bg-black"> <div class="layui-side layui-bg-black">
<div class="layui-side-scroll"> <div class="layui-side-scroll">
<ul class="layui-nav layui-nav-tree" lay-shrink="all" lay-filter="navFilter"> <ul class="layui-nav layui-nav-tree" lay-shrink="all" lay-filter="navFilter">
<!-- 停用
<li class="layui-nav-item layui-nav-itemed"> <li class="layui-nav-item layui-nav-itemed">
<a href="javascript:;"> <a href="javascript:;">
<i class="iconfont icon-huiyuan"></i> 会员管理 <i class="iconfont icon-huiyuan"></i> 会员管理
@ -142,6 +143,7 @@
<dd><a href="javascript:;" path="pages/other/donate.html"><i class="iconfont icon-juanzeng"></i> 捐赠列表</a></dd> <dd><a href="javascript:;" path="pages/other/donate.html"><i class="iconfont icon-juanzeng"></i> 捐赠列表</a></dd>
</dl> </dl>
</li> </li>
-->
</ul> </ul>
</div> </div>
</div> </div>

View File

@ -34,46 +34,78 @@ layui.config({
} }
}); });
// TODO 加载左侧菜单 // TODO 无限级菜单
// okUtils.ajax("data/menu.json", "get").done(function (response) { okUtils.ajax("data/menu.json", "get").done(function (response) {
// var html = ""; var html = "";
// for (var i = 0; i < response.length; i++) { for (var i = 0; i < response.length; i++) {
// var d = response[i]; var d = response[i];
// html += "<li class='layui-nav-item'>" html += liHtml(d);
// html += "<a href='javascript:;'>" html += "<a href='javascript:;'>"
// html += "<i class='iconfont icon-huiyuan'></i> " + response[i].title; html += iconHtml(d) + " " + response[i].title;
// html += "</a>" html += "</a>"
// if (d.children != undefined && d.children.length > 0) { var children = d.children;
// html += "<dl class='layui-nav-child'>" if (children != undefined && children.length > 0) {
// for (var j = 0; j < d.children.length; j++) { html += "<dl class='layui-nav-child'>"
// html += "<dd><a href='javascript:;' path='pages/user/user.html' tab-id='1-1'><i class='iconfont icon-dianliyonghuzongshu'></i> " + d.children[j].title + "</a></dd>"; for (var j = 0; j < children.length; j++) {
// } html += "<dd><a href='javascript:;' path='" + children[j].path + "'>" + iconHtml(children[j]) + " " + children[j].title + "</a></dd>";
// html += "</dl>" }
// } html += "</dl>"
// html += "</li>"; }
// } html += "</li>";
// $(".layui-nav-tree").html(html); }
// element.render("nav"); $(".layui-nav-tree").html(html);
// }).fail(function (error) { element.render("nav");
// console.log(error) }).fail(function (error) {
// }); console.log(error)
});
function iconHtml(obj) {
var html = "";
if (obj.icon) {
if (obj.font == "iconfont") {
html += "<i class='iconfont'>" + obj.icon + "</i>";
} else if (obj.font == "layui-icon") {
html += "<i class='layui-icon'> " + obj.icon + "</i>";
} else {
html += "<i class='iconfont'>" + obj.icon + "</i>";
}
} else {
console.warn(obj.title, "icon未定义");
}
return html;
}
function liHtml(obj) {
var html = "";
if (obj.spread) {
html += "<li class='layui-nav-item layui-nav-itemed'>";
} else {
html += "<li class='layui-nav-item'>";
}
return html;
}
/** /**
* 监听导航菜单的点击 * 监听导航菜单的点击
*/ */
// element.on("nav(navFilter)", function (elem) { element.on("nav(navFilter)", function (elem) {
// var path = elem.context.attributes.path; var attrNum = elem.context.attributes.length;
// var tabId = elem.context.attributes["tab-id"]; if (attrNum == 2) {
// var text = elem.context.innerText; // var title = elem.context.innerHTML;
// console.log(path, tabId, text) var title = elem.context.innerText;
// }); title = title.substring(title.indexOf(" "), title.length);
var path = elem.context.attributes.path.textContent;
$(".layui-nav-child").find("dd").click(function () { okTab.add(title, path)
var title = $(this).text(); }
var path = $(this).children("a").attr("path");
okTab.add(title, path)
}); });
// 停用
// $(".layui-nav-child").find("dd").click(function () {
// var title = $(this).text();
// var path = $(this).children("a").attr("path");
// okTab.add(title, path)
// });
/** /**
* 修改copyright结束时间 * 修改copyright结束时间
*/ */

37
pages/use/demo.html Normal file
View File

@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>demo</title>
</head>
<body>
<script>
/**
*
* @param obj
* @returns {boolean}
*/
function isEmpty(obj) {
if (obj) {
return true;
}
// if (obj && typeof obj === "string") {
// return true;
// }
// if (obj && typeof obj === "number") {
// return true;
// }
return false;
}
console.log(isEmpty());
console.log(isEmpty(null));
console.log(isEmpty(""));
console.log(isEmpty(undefined));
console.log(isEmpty("hello"));
console.log(isEmpty(10));
console.log(isEmpty(true));
console.log(isEmpty(false));
</script>
</body>
</html>