diff --git a/component/pear/module/admin.js b/component/pear/module/admin.js index cd50953..3e1e788 100644 --- a/component/pear/module/admin.js +++ b/component/pear/module/admin.js @@ -41,7 +41,7 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'], control: option.control ? 'control' : false, // control defaultMenu: 1, defaultOpen: 0, //默认打开菜单 - accordion: true, + accordion: option.accordion, url: option.data, //数据地址 parseData: false, //请求后是否进行数据解析 函数 change: option.change @@ -147,10 +147,27 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'], } this.themeRender = function(option) { + + if(option.allowCustom == false){ + $(".setting").remove(); + } var colorId = localStorage.getItem("theme-color"); var menu = localStorage.getItem("theme-menu"); + var color = getColorById(colorId); + + if(menu=="null"){ + menu = option.defaultMenu; + }else{ + + if(option.allowCustom == false){ + menu = option.defaultMenu; + } + } + + localStorage.setItem("theme-color",color.id); + localStorage.setItem("theme-menu",menu); - this.colorSet(getColorById(colorId).color); + this.colorSet(color.color); this.menuSkin(menu); } @@ -315,7 +332,7 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'], '
' + '' + ''; - + bgColorHtml += '
  • ' + '' + @@ -350,7 +367,7 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'], var color = localStorage.getItem("theme-color"); var menu = localStorage.getItem("theme-menu"); - + if (color != "null") { $(".select-color-item").removeClass("layui-icon") .removeClass("layui-icon-ok"); @@ -358,13 +375,13 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'], $("*[color-id='" + color + "']").addClass("layui-icon") .addClass("layui-icon-ok"); } - - if (menu!="null"){ + + if (menu != "null") { $("*[data-select-bgcolor]").removeClass("layui-this"); - - $("[data-select-bgcolor='"+menu+"']").addClass("layui-this"); + + $("[data-select-bgcolor='" + menu + "']").addClass("layui-this"); } - + $('#layui-layer-shade' + index).click(function() { var $layero = $('#layui-layer' + index); $layero.animate({ @@ -383,7 +400,7 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'], $.ajaxSettings.async = false; var data = null; - $.get("setting.json", function(result) { + $.getJSON("setting.json", function(result) { data = result; }); @@ -402,7 +419,6 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'], }); $('body').on('click', '.select-color-item', function() { - $(".select-color-item").removeClass("layui-icon").removeClass("layui-icon-ok"); $(this).addClass("layui-icon").addClass("layui-icon-ok"); var colorId = $(".select-color-item.layui-icon-ok").attr("color-id"); @@ -411,25 +427,30 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'], pearAdmin.colorSet(color.color); }); - - function getThemeById(id) { - var theme; - $.each(getData().theme, function(i, value) { - if (value.id == id) { - theme = value; - } - }) - return theme; - } - function getColorById(id) { var color; - $.each(getData().colors, function(i, value) { + + var flag = false; + + var data = getData(); + + $.each(data.colors, function(i, value) { if (value.id == id) { color = value; + flag = true; } }) + + if(flag==false || data.allowCustom == false){ + + $.each(data.colors, function(i, value) { + + if (value.id == data.defaultColor) { + color = value; + } + }) + } return color; } @@ -452,13 +473,9 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'], var colors = ""; $.each(getData().colors, function(i, value) { - - colors += ""; + colors += ""; }) - - return "
    主题色
    " + - colors + "
    " + return "
    主题色
    " + colors + "
    " } diff --git a/component/pear/module/menu.js b/component/pear/module/menu.js index 3d92550..54a6792 100644 --- a/component/pear/module/menu.js +++ b/component/pear/module/menu.js @@ -139,9 +139,10 @@ layui.define(['table', 'jquery', 'element'], function(exports) { // 根 据 菜 单 Id 选 中 菜 单 项 目 - - $("#" + this.option.elem + " a[menu-id='" + pearId + "']").parents(".pear-nav-tree").find(".layui-nav-itemed").removeClass( - "layui-nav-itemed"); + if (this.option.accordion == true) { + $("#" + 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"); diff --git a/index.html b/index.html index 03af751..d035fe6 100644 --- a/index.html +++ b/index.html @@ -26,7 +26,7 @@
  • - + 就眠仪式 diff --git a/setting.json b/setting.json index d6a03ee..fab6b42 100644 --- a/setting.json +++ b/setting.json @@ -5,12 +5,16 @@ "control": false, "index": "view/console/console1.html", "indexTitle": "首页", + "accordion": true, "data": "admin/data/menu.json", "select": "0", "logoTitle": "Pear Admin", "logoImage": "admin/images/logo.png", - "themeColor": "1", - "colors": [{ + "defaultColor": "2", + "defaultMenu": "dark-theme", + "allowCustom": true, + "colors": [ + { "id": "1", "color": "#FF5722" }, @@ -29,7 +33,8 @@ "color": "darkgray" } ], - "links": [{ + "links": [ + { "icon": "layui-icon layui-icon-auz", "title": "官方网站", "href": "http://www.pearadmin.com" diff --git a/view/console/console1.html b/view/console/console1.html index ecf989a..f03a271 100644 --- a/view/console/console1.html +++ b/view/console/console1.html @@ -253,31 +253,31 @@ echarts = layui.echarts; count.up("value1", { - time: 5000, - num: 4540.34, + time: 4000, + num: 440.34, bit: 2, - regulator: 100 + regulator: 50 }) count.up("value2", { - time: 5000, - num: 2436.30, + time: 4000, + num: 236.30, bit: 2, - regulator: 100 + regulator: 50 }) count.up("value3", { - time: 5000, - num: 6314.43, + time: 4000, + num: 634.43, bit: 2, - regulator: 100 + regulator: 50 }) count.up("value4", { - time: 5000, + time: 4000, bit: 2, - num: 3743.23, - regulator: 100 + num: 373.23, + regulator: 50 }) var echartsRecords = echarts.init(document.getElementById('echarts-records'), 'walden'); diff --git a/view/console/console2.html b/view/console/console2.html index 6ffa25a..6ed82b9 100644 --- a/view/console/console2.html +++ b/view/console/console2.html @@ -133,7 +133,7 @@