diff --git a/data/menu.json b/data/menu.json index b5148e6..7949099 100644 --- a/data/menu.json +++ b/data/menu.json @@ -2,241 +2,281 @@ "status": 1000, "msg": "操作成功", "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": "会员管理", - "icon": "", - "href": "", - "spread": false, + "path": "", + "font": "iconfont", + "icon": "", + "spread": true, "children": [ { "title": "用户列表", - "fontFamily": "layui-icon", - "icon": "", - "href": "pages/user/user.html", + "path": "pages/user/user.html", + "font": "iconfont", + "icon": "", "spread": false }, { "title": "角色列表", - "icon": "", - "href": "pages/role/role.html", + "path": "pages/role/role.html", + "font": "iconfont", + "icon": "", "spread": false }, { "title": "权限列表", - "icon": "", - "href": "pages/permission/permission.html", + "path": "pages/permission/permission.html", + "font": "iconfont", + "icon": "", "spread": false } ] }, { "title": "新闻管理", - "icon": "", - "href": "", + "path": "", + "font": "iconfont", + "icon": "", "spread": false, "children": [ { - "title": "文章列表", - "fontFamily": "layui-icon", - "icon": "", - "href": "pages/article/article.html", + "title": "新闻列表", + "path": "pages/article/article.html", + "font": "iconfont", + "icon": "", "spread": false } ] }, { - "title": "多级导航", - "fontFamily": "ok-icon", - "icon": "ok-iconnavigation-2", + "title": "留言管理", + "path": "", + "font": "iconfont", + "icon": "", "spread": false, "children": [ { - "title": "二级导航", - "href": "", - "spread": false, - "children": [ - { - "title": "三级导航1", - "fontFamily": "ok-icon", - "icon": "ok-iconairplay", - "href": "pages/home.html", - "spread": false - }, - { - "title": "三级导航2", - "href": "", - "spread": false, - "children": [ - { - "title": "四级导航1", - "href": "", - "spread": false - }, - { - "title": "四级导航2", - "href": "", - "spread": false, - "children": [ - { - "title": "五级导航", - "fontFamily": "ok-icon", - "icon": "", - "href": "", - "spread": false - }, - { - "title": "五级导航", - "href": "", - "spread": false - }, - { - "title": "登录", - "icon": "", - "href": "pages/login.html", - "spread": false, - "target": "_blank" - } - ] - } - ] - } - ] + "title": "留言列表", + "path": "pages/message/message.html", + "font": "iconfont", + "icon": "", + "spread": false + } + ] + }, + { + "title": "下载中心", + "path": "", + "font": "iconfont", + "icon": "", + "spread": false, + "children": [ + { + "title": "下载列表", + "path": "pages/download/download.html", + "font": "iconfont", + "icon": "", + "spread": false + } + ] + }, + { + "title": "友情链接", + "path": "", + "font": "iconfont", + "icon": "", + "spread": false, + "children": [ + { + "title": "链接列表", + "path": "pages/link/link.html", + "font": "iconfont", + "icon": "", + "spread": false + } + ] + }, + { + "title": "产品管理", + "path": "", + "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": "系统管理", - "icon": "", - "href": "", + "path": "", + "font": "layui-icon", + "icon": "", "spread": false, "children": [ { - "title": "登录", - "icon": "", - "href": "pages/login.html", - "spread": false, - "target": "_blank" + "title": "网站配置", + "path": "pages/system/system-setting.html", + "font": "iconfont", + "icon": "", + "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页面", - "icon": "", - "href": "pages/common/403.html", + "path": "pages/use/use-okLayer.html", + "font": "iconfont", + "icon": "", "spread": false }, { "title": "404页面", - "icon": "", - "href": "pages/common/404.html", + "path": "pages/use/use-okUtils.html", + "font": "iconfont", + "icon": "", "spread": false }, { "title": "500页面", - "icon": "", - "href": "pages/common/500.html", + "path": "https://www.layui.com/doc/element/icon.html", + "font": "iconfont", + "icon": "", + "spread": false + }, + { + "title": "捐赠列表", + "path": "font/demo_index.html", + "font": "iconfont", + "icon": "", "spread": false } ] diff --git a/index.html b/index.html index 31474c1..2e50b5c 100644 --- a/index.html +++ b/index.html @@ -45,6 +45,7 @@
diff --git a/js/okadmin.js b/js/okadmin.js index 3b351fa..14ff3a9 100644 --- a/js/okadmin.js +++ b/js/okadmin.js @@ -34,46 +34,78 @@ layui.config({ } }); - // TODO 加载左侧菜单 !!!!!!!!!!!! - // okUtils.ajax("data/menu.json", "get").done(function (response) { - // var html = ""; - // for (var i = 0; i < response.length; i++) { - // var d = response[i]; - // html += "
  • " - // html += "" - // html += " " + response[i].title; - // html += "" - // if (d.children != undefined && d.children.length > 0) { - // html += "
    " - // for (var j = 0; j < d.children.length; j++) { - // html += "
    " + d.children[j].title + "
    "; - // } - // html += "
    " - // } - // html += "
  • "; - // } - // $(".layui-nav-tree").html(html); - // element.render("nav"); - // }).fail(function (error) { - // console.log(error) - // }); + // TODO 无限级菜单 + okUtils.ajax("data/menu.json", "get").done(function (response) { + var html = ""; + for (var i = 0; i < response.length; i++) { + var d = response[i]; + html += liHtml(d); + html += "" + html += iconHtml(d) + " " + response[i].title; + html += "" + var children = d.children; + if (children != undefined && children.length > 0) { + html += "
    " + for (var j = 0; j < children.length; j++) { + html += "
    " + iconHtml(children[j]) + " " + children[j].title + "
    "; + } + html += "
    " + } + html += ""; + } + $(".layui-nav-tree").html(html); + element.render("nav"); + }).fail(function (error) { + console.log(error) + }); + + function iconHtml(obj) { + var html = ""; + if (obj.icon) { + if (obj.font == "iconfont") { + html += "" + obj.icon + ""; + } else if (obj.font == "layui-icon") { + html += " " + obj.icon + ""; + } else { + html += "" + obj.icon + ""; + } + } else { + console.warn(obj.title, "icon未定义"); + } + return html; + } + + function liHtml(obj) { + var html = ""; + if (obj.spread) { + html += "
  • "; + } else { + html += "
  • "; + } + return html; + } /** * 监听导航菜单的点击 */ - // element.on("nav(navFilter)", function (elem) { - // var path = elem.context.attributes.path; - // var tabId = elem.context.attributes["tab-id"]; - // var text = elem.context.innerText; - // console.log(path, tabId, text) - // }); - - $(".layui-nav-child").find("dd").click(function () { - var title = $(this).text(); - var path = $(this).children("a").attr("path"); - okTab.add(title, path) + element.on("nav(navFilter)", function (elem) { + var attrNum = elem.context.attributes.length; + if (attrNum == 2) { + // var title = elem.context.innerHTML; + var title = elem.context.innerText; + title = title.substring(title.indexOf(" "), title.length); + var path = elem.context.attributes.path.textContent; + 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结束时间 */ diff --git a/pages/use/demo.html b/pages/use/demo.html new file mode 100644 index 0000000..22a252a --- /dev/null +++ b/pages/use/demo.html @@ -0,0 +1,37 @@ + + + + + demo + + + + +