Forráskód Böngészése

完成登录页面和主页

reghao 5 éve
szülő
commit
2c538b8053

+ 15 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/view/controller/SysController.java

@@ -15,4 +15,19 @@ public class SysController {
     public String user() {
         return "views/sys/user/user";
     }
+
+    @GetMapping("/user/profile")
+    public String userProfile() {
+        return "views/sys/user/userProfile";
+    }
+
+    @GetMapping("/password/update")
+    public String updatePassword() {
+        return "views/sys/user/passwordUpdate";
+    }
+
+    @GetMapping("/user/profile/update")
+    public String updateProfile() {
+        return "views/sys/user/profileUpdate";
+    }
 }

+ 1 - 2
dmaster/src/main/java/cn/reghao/autodop/dmaster/view/controller/ViewController.java

@@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.*;
 @Api(tags = "视图")
 @Controller
 public class ViewController {
-    @GetMapping({"/", "/index"})
+    @GetMapping({"/"})
     public String index() {
         // templates/index.html
         return "index";
@@ -19,7 +19,6 @@ public class ViewController {
 
     @GetMapping("/layuix/views/index")
     public String index1() {
-        // templates/views/index.html
         return "views/index";
     }
 

+ 8 - 5
dmaster/src/main/resources/static/layuix/lay/modules/layuix.js

@@ -42,17 +42,20 @@ layui.extend({
         };
     };
 
-    // 初始化视图区域
+    /*
+    * 初始化视图区域
+    * 首先获取 / 页面,然后获取 layout.html 页面,最后获取 index.html 页面
+    * */
     self.initView = function (route) {
         if (!self.route.href || self.route.href === '/') {
             self.route = layui.router('#' + conf.entry);
             route = self.route
         }
         route.fileurl = route.path.join('/');
-        // config.js 文件是否有 singlePage 属性
+        // config.js 是否有 singlePage 属性
         if ($.inArray(route.fileurl, conf.singlePage) === -1) {
             var loadRenderPage = function (params) {
-                // config.js 文件是否有 viewTabs 属性
+                // config.js 是否有 viewTabs 属性
                 if (conf.viewTabs === true) {
                     view.renderTabs(route)
                 } else {
@@ -61,7 +64,7 @@ layui.extend({
             };
 
             if (view.containerBody == null) {
-                // 加载 layout 文件
+                // 渲染 layout.html
                 view.renderLayout(function () {
                     // 重新渲染导航
                     element.render('nav', 'layuix-sidebar');
@@ -69,7 +72,7 @@ layui.extend({
                     loadRenderPage()
                 })
             } else {
-                // layout文件已加载,加载视图文件
+                // layout.html 已渲染,接着渲染视图文件
                 loadRenderPage()
             }
         } else {

+ 515 - 523
dmaster/src/main/resources/static/layuix/lay/modules/view.js

@@ -1,559 +1,551 @@
-// 视图路由
-layui
-    .extend({
-        loadBar: 'lay/modules/loadBar',
-        dropdown: 'lay/modules/dropdown'
-    })
-    .define(
-        ['jquery', 'laytpl', 'element', 'form', 'loadBar', 'dropdown'],
-        function (exports) {
-            var $ = layui.jquery;
-            var laytpl = layui.laytpl;
-            var conf = layui.conf;
-            conf.viewTabs = currentUser.isTab === '1';
-            var loadBar = layui.loadBar;
-            var self = {
-                ie8:
-                    navigator.appName === 'Microsoft Internet Explorer' &&
-                    navigator.appVersion.split(';')[1].replace(/[ ]/g, '') === 'MSIE8.0',
-                container: $('#' + conf.container),
-                containerBody: null
-            };
-            self.loadBar = loadBar;
-            /**
-             * 字符串是否含有html标签的检测
-             * @param htmlStr
-             */
-            self.checkHtml = function (htmlStr) {
-                var reg = /<[^>]+>/g;
-                return reg.test(htmlStr)
-            };
-            self.parse = function (container) {
-                if (container === undefined) container = self.containerBody;
-                var template =
-                    container.get(0).tagName === 'SCRIPT'
-                        ? container
-                        : container.find('[template]');
-
-                var renderTemplate = function (template, data, callback) {
-                    laytpl(template.html()).render(data, function (html) {
-                        try {
-                            html = $(
-                                self.checkHtml(html) ? html : '<span>' + html + '</span>'
-                            )
-                        } catch (err) {
-                            html = $('<span>' + html + '</span>')
-                        }
-
-                        html.attr('is-template', true);
-                        template.after(html);
-                        if ($.isFunction(callback)) callback(html)
-                    })
-                };
+// 获取、渲染视图
+layui.extend({
+    loadBar: 'lay/modules/loadBar',
+    dropdown: 'lay/modules/dropdown'
+}).define(['jquery', 'laytpl', 'element', 'form', 'loadBar', 'dropdown'], function (exports) {
+    var $ = layui.jquery;
+    var laytpl = layui.laytpl;
+    var conf = layui.conf;
+    conf.viewTabs = currentUser.isTab === '1';
+    var loadBar = layui.loadBar;
+    var self = {
+        ie8:
+            navigator.appName === 'Microsoft Internet Explorer' &&
+            navigator.appVersion.split(';')[1].replace(/[ ]/g, '') === 'MSIE8.0',
+        container: $('#' + conf.container),
+        containerBody: null
+    };
+    self.loadBar = loadBar;
+    /**
+     * 字符串是否含有html标签的检测
+     * @param htmlStr
+     */
+    self.checkHtml = function (htmlStr) {
+        var reg = /<[^>]+>/g;
+        return reg.test(htmlStr)
+    };
+    self.parse = function (container) {
+        if (container === undefined) container = self.containerBody;
+        var template = container.get(0).tagName === 'SCRIPT' ? container : container.find('[template]');
+        var renderTemplate = function (template, data, callback) {
+            laytpl(template.html()).render(data, function (html) {
+                try {
+                    html = $(self.checkHtml(html) ? html : '<span>' + html + '</span>')
+                } catch (err) {
+                    html = $('<span>' + html + '</span>')
+                }
 
-                layui.each(template, function (index, t) {
-                    var tem = $(t);
-                    var url = tem.attr('lay-url') || '';
-                    var api = tem.attr('lay-api') || '';
-                    var type = tem.attr('lay-type') || 'get';
-                    var data = new Function('return ' + tem.attr('lay-data'))();
-                    var done = tem.attr('lay-done') || '';
-
-                    if (url || api) {
-                        //进行AJAX请求
-                        self.request({
-                            url: url,
-                            api: api,
-                            type: type,
-                            data: data,
-                            success: function (res) {
-                                templateData = data;
-                                renderTemplate(tem, res.data);
-                                if (done) new Function(done)()
-                            }
-                        })
-                    } else {
-                        renderTemplate(
-                            tem,
-                            {},
-                            self.ie8
-                                ? function (elem) {
-                                    if (elem[0] && elem[0].tagName !== 'LINK') return;
-                                    container.hide();
-                                    elem.load(function () {
-                                        container.show()
-                                    })
-                                }
-                                : null
-                        );
+                html.attr('is-template', true);
+                template.after(html);
+                if ($.isFunction(callback)) callback(html)
+            })
+        };
+
+        layui.each(template, function (index, t) {
+            var tem = $(t);
+            var url = tem.attr('lay-url') || '';
+            var api = tem.attr('lay-api') || '';
+            var type = tem.attr('lay-type') || 'get';
+            var data = new Function('return ' + tem.attr('lay-data'))();
+            var done = tem.attr('lay-done') || '';
+
+            if (url || api) {
+                //进行AJAX请求
+                self.request({
+                    url: url,
+                    api: api,
+                    type: type,
+                    data: data,
+                    success: function (res) {
+                        templateData = data;
+                        renderTemplate(tem, res.data);
                         if (done) new Function(done)()
                     }
                 })
-            };
-            self.loading = function (elem) {
-                elem.append(
-                    (this.elemLoad = $(
-                        '<i class="layui-anim layui-anim-rotate layui-anim-loop layui-icon layui-icon-loading layuix-loading"></i>'
-                    ))
-                )
-            };
-            self.loadend = function () {
-                this.elemLoad && this.elemLoad.remove()
-            };
-
-            self.setTitle = function (title) {
-                $(document).attr({title: title + ' - ' + conf.name})
-            };
-            self.clear = function () {
-                self.containerBody.html('')
-            };
-
-            self.modal = {};
-
-            self.modal.base = function (msg, params) {
-                params = params || {};
-                params.titleIcoColor = params.titleIcoColor || '#5a8bff';
-                params.titleIco = params.titleIco || 'exclaimination';
-                params.title = params.title || [
-                    '<i class="layui-icon layui-icon-' +
-                    params.titleIco +
-                    '" style="font-size:12px;background:' +
-                    params.titleIcoColor +
-                    ';display:inline-block;position:relative;top:-2px;height:21px;line-height:21px;text-align:center;width:21px;color:#fff;border-radius:50%;margin-right:12px;"></i>' +
-                    params.titleValue,
-                    'background:#fff;border:none;font-weight:bold;font-size:16px;color:#08132b;padding-top:20px;height:36px;line-height:46px;padding-bottom:0;'
-                ];
-                params = $.extend(
-                    {
-                        skin: 'layui-layer-admin-modal layuix-alert',
-                        area: [$(window).width() <= 750 ? '60%' : '400px'],
-                        closeBtn: 0,
-                        shadeClose: false
-                    },
-                    params
-                );
-                layer.alert(msg, params);
-            };
-
-            self.notify = function (title, msg, yes, params) {
-                params = params || {};
-                params.titleIco = 'exclaimination';
-                params.titleIcoColor = '#ffc107';
-                params.titleValue = title;
-                params.shadeClose = false;
-                params = $.extend({
-                    btn: ['确定']
-                    , yes: function (index, layero) {
-                        yes && (yes)();
-                        layer.close(index);
+            } else {
+                renderTemplate(
+                        tem,
+                        {},
+                        self.ie8
+                            ? function (elem) {
+                                if (elem[0] && elem[0].tagName !== 'LINK') return;
+                                container.hide();
+                                elem.load(function () {
+                                    container.show()
+                                })
+                            }
+                            : null
+                    );
+                    if (done) new Function(done)()
+                }
+            })
+        };
+        self.loading = function (elem) {
+            elem.append(
+                (this.elemLoad = $(
+                    '<i class="layui-anim layui-anim-rotate layui-anim-loop layui-icon layui-icon-loading layuix-loading"></i>'
+                ))
+            )
+        };
+        self.loadend = function () {
+            this.elemLoad && this.elemLoad.remove()
+        };
+
+        self.setTitle = function (title) {
+            $(document).attr({title: title + ' - ' + conf.name})
+        };
+        self.clear = function () {
+            self.containerBody.html('')
+        };
+
+        self.modal = {};
+
+        self.modal.base = function (msg, params) {
+            params = params || {};
+            params.titleIcoColor = params.titleIcoColor || '#5a8bff';
+            params.titleIco = params.titleIco || 'exclaimination';
+            params.title = params.title || [
+                '<i class="layui-icon layui-icon-' +
+                params.titleIco +
+                '" style="font-size:12px;background:' +
+                params.titleIcoColor +
+                ';display:inline-block;position:relative;top:-2px;height:21px;line-height:21px;text-align:center;width:21px;color:#fff;border-radius:50%;margin-right:12px;"></i>' +
+                params.titleValue,
+                'background:#fff;border:none;font-weight:bold;font-size:16px;color:#08132b;padding-top:20px;height:36px;line-height:46px;padding-bottom:0;'
+            ];
+            params = $.extend(
+                {
+                    skin: 'layui-layer-admin-modal layuix-alert',
+                    area: [$(window).width() <= 750 ? '60%' : '400px'],
+                    closeBtn: 0,
+                    shadeClose: false
+                },
+                params
+            );
+            layer.alert(msg, params);
+        };
+
+        self.notify = function (title, msg, yes, params) {
+            params = params || {};
+            params.titleIco = 'exclaimination';
+            params.titleIcoColor = '#ffc107';
+            params.titleValue = title;
+            params.shadeClose = false;
+            params = $.extend({
+                btn: ['确定']
+                , yes: function (index, layero) {
+                    yes && (yes)();
+                    layer.close(index);
+                }
+            }, params);
+            self.modal.base(msg, params);
+        };
+
+        // 从服务端获取 html 文件
+        self.loadHtml = function (url, callback) {
+            url = url || conf.entry;
+            loadBar.start();
+            var queryIndex = url.indexOf('?');
+            if (queryIndex !== -1) url = url.slice(0, queryIndex);
+
+            //console.log((url.indexOf(conf.base) === 0 ? '' : conf.views) + url + conf.engine + '?v=' + conf.v)
+            $.ajax({
+                url:
+                    (url.indexOf(conf.base) === 0 ? '' : conf.views) +
+                    url +
+                    conf.engine +
+                    '?v=' +
+                    conf.v,
+                type: 'get',
+                data: {
+                    'invalid_ie_cache': new Date().getTime()
+                },
+                dataType: 'html',
+                success: function (r) {
+                    var result;
+                    try {
+                        result = JSON.parse(r);
+                    } catch (e) {
+                        result = {'code': 'err'};
                     }
-                }, params);
-                self.modal.base(msg, params);
-            };
-
-            self.loadHtml = function (url, callback) {
-                url = url || conf.entry;
-                loadBar.start();
-                var queryIndex = url.indexOf('?');
-                if (queryIndex !== -1) url = url.slice(0, queryIndex);
-
-                console.log((url.indexOf(conf.base) === 0 ? '' : conf.views) + url + conf.engine + '?v=' + conf.v)
-                $.ajax({
-                    url:
-                        (url.indexOf(conf.base) === 0 ? '' : conf.views) +
-                        url +
-                        conf.engine +
-                        '?v=' +
-                        conf.v,
-                    type: 'get',
-                    data: {
-                        'invalid_ie_cache': new Date().getTime()
-                    },
-                    dataType: 'html',
-                    success: function (r) {
-                        var result;
-                        try {
-                            result = JSON.parse(r);
-                        } catch (e) {
-                            result = {'code': 'err'};
-                        }
-                        if (result.code === 401) {
-                            self.notify('登录失效', '登录已失效,请重新登录', function () {
-                                window.location.reload();
-                                window.location.hash = '';
-                            });
-                            loadBar.finish();
-                            return;
+                    if (result.code === 401) {
+                        self.notify('登录失效', '登录已失效,请重新登录', function () {
+                            window.location.reload();
+                            window.location.hash = '';
+                        });
+                        loadBar.finish();
+                        return;
+                    }
+                    if (result.code === 403) {
+                        self.tab.change('/403');
+                        loadBar.finish();
+                        return;
+                    }
+                    if (result.code === 404) {
+                        self.tab.change('/404');
+                        loadBar.finish();
+                        return;
+                    }
+                    if (result.code === 500) {
+                        self.tab.change('/500');
+                        loadBar.finish();
+                        return;
+                    }
+                    callback({html: r, url: url});
+                    loadBar.finish()
+                },
+                error: function (res) {
+                    if (res.status === 404) {
+                        self.tab.change('/404');
+                    }
+                    if (res.status === 403) {
+                        self.tab.change('/403');
+                    }
+                    if (res.status === 500) {
+                        self.tab.change('/500');
+                    }
+                    self.log(
+                        '请求视图文件异常\n文件路径:' + url + '\n状态:' + res.status
+                    );
+                    loadBar.error();
+                }
+            })
+        };
+
+        self.tab = {
+            isInit: false,
+            data: [],
+            tabMenuTplId: 'TPL-app-tabsmenu',
+            minLeft: null,
+            maxLeft: null,
+            wrap: '.layuix-tabs-wrap',
+            menu: '.layuix-tabs-menu',
+            next: '.layuix-tabs-next',
+            prev: '.layuix-tabs-prev',
+            step: 200,
+            init: function () {
+                var tab = this;
+                var btnCls = tab.wrap + ' .layuix-tabs-btn';
+
+                layui.dropdown.render({
+                    elem: '.layuix-tabs-down',
+                    click: function (name) {
+                        if (name === 'all') {
+                            tab.delAll();
                         }
-                        if (result.code === 403) {
-                            self.tab.change('/403');
-                            loadBar.finish();
-                            return;
+                        if (name === 'other') {
+                            tab.delOther();
                         }
-                        if (result.code === 404) {
-                            self.tab.change('/404');
-                            loadBar.finish();
-                            return;
+                        if (name === 'current') {
+                            tab.del(layui.layuix.route.fileurl);
                         }
-                        if (result.code === 500) {
-                            self.tab.change('/500');
-                            loadBar.finish();
-                            return;
+                        if (name === 'refresh') {
+                            tab.refresh();
                         }
-                        callback({html: r, url: url});
-                        loadBar.finish()
                     },
-                    error: function (res) {
-                        if (res.status === 404) {
-                            self.tab.change('/404');
-                        }
-                        if (res.status === 403) {
-                            self.tab.change('/403');
-                        }
-                        if (res.status === 500) {
-                            self.tab.change('/500');
-                        }
-                        self.log(
-                            '请求视图文件异常\n文件路径:' + url + '\n状态:' + res.status
-                        );
-                        loadBar.error();
-                    }
-                })
-            };
-
-            self.tab = {
-                isInit: false,
-                data: [],
-                tabMenuTplId: 'TPL-app-tabsmenu',
-                minLeft: null,
-                maxLeft: null,
-                wrap: '.layuix-tabs-wrap',
-                menu: '.layuix-tabs-menu',
-                next: '.layuix-tabs-next',
-                prev: '.layuix-tabs-prev',
-                step: 200,
-                init: function () {
-                    var tab = this;
-                    var btnCls = tab.wrap + ' .layuix-tabs-btn';
-
-                    layui.dropdown.render({
-                        elem: '.layuix-tabs-down',
-                        click: function (name) {
-                            if (name === 'all') {
-                                tab.delAll();
-                            }
-                            if (name === 'other') {
-                                tab.delOther();
-                            }
-                            if (name === 'current') {
-                                tab.del(layui.layuix.route.fileurl);
-                            }
-                            if (name === 'refresh') {
-                                tab.refresh();
-                            }
+                    options: [
+                        {
+                            name: 'current',
+                            title: '关闭当前选项卡'
                         },
-                        options: [
-                            {
-                                name: 'current',
-                                title: '关闭当前选项卡'
-                            },
-                            {
-                                name: 'other',
-                                title: '关闭其他选项卡'
-                            },
-                            {
-                                name: 'all',
-                                title: '关闭所有选项卡'
-                            },
-                            {
-                                name: 'refresh',
-                                title: '刷新当前选项卡'
-                            }
-                        ]
-                    });
+                        {
+                            name: 'other',
+                            title: '关闭其他选项卡'
+                        },
+                        {
+                            name: 'all',
+                            title: '关闭所有选项卡'
+                        },
+                        {
+                            name: 'refresh',
+                            title: '刷新当前选项卡'
+                        }
+                    ]
+                });
 
-                    $(document).on('click', btnCls, function (e) {
-                        var url = $(this).attr('lay-url');
-                        if ($(e.target).hasClass('layuix-tabs-close')) {
-                            tab.del(url)
-                        } else {
-                            var type = $(this).attr('data-type');
-                            if (type === 'page') {
-                                tab.change(tab.has(url))
-                            } else if (type === 'prev' || type === 'next') {
-                                tab.menuElem = $(tab.menu);
-                                var menu = tab.menuElem;
-                                tab.minLeft = tab.minLeft || parseInt(menu.css('left'));
-                                tab.maxLeft = tab.maxLeft || $(tab.next).offset().left;
-
-                                var left = 0;
-                                if (type === 'prev') {
-                                    left = parseInt(menu.css('left')) + tab.step;
-                                    if (left >= tab.minLeft) left = tab.minLeft
-                                } else {
-                                    left = parseInt(menu.css('left')) - tab.step;
-                                    var last = menu.find('li:last');
-                                    if (last.offset().left + last.width() < tab.maxLeft) return
-                                }
-                                menu.css('left', left)
+                $(document).on('click', btnCls, function (e) {
+                    var url = $(this).attr('lay-url');
+                    if ($(e.target).hasClass('layuix-tabs-close')) {
+                        tab.del(url)
+                    } else {
+                        var type = $(this).attr('data-type');
+                        if (type === 'page') {
+                            tab.change(tab.has(url))
+                        } else if (type === 'prev' || type === 'next') {
+                            tab.menuElem = $(tab.menu);
+                            var menu = tab.menuElem;
+                            tab.minLeft = tab.minLeft || parseInt(menu.css('left'));
+                            tab.maxLeft = tab.maxLeft || $(tab.next).offset().left;
+
+                            var left = 0;
+                            if (type === 'prev') {
+                                left = parseInt(menu.css('left')) + tab.step;
+                                if (left >= tab.minLeft) left = tab.minLeft
+                            } else {
+                                left = parseInt(menu.css('left')) - tab.step;
+                                var last = menu.find('li:last');
+                                if (last.offset().left + last.width() < tab.maxLeft) return
                             }
+                            menu.css('left', left)
                         }
-                    });
-
-                    $('.layuix-tabs-hidden').addClass('layui-show');
-                    this.isInit = true
-                },
-                has: function (url) {
-                    var exists = false;
-                    layui.each(this.data, function (i, data) {
-                        if (data.fileurl === url) return (exists = data)
-                    });
-                    return exists
-                },
-                delAll: function (type) {
-                    var tab = this;
-                    var menuBtnClas = tab.menu + ' .layuix-tabs-btn';
-                    $(menuBtnClas).each(function () {
+                    }
+                });
+
+                $('.layuix-tabs-hidden').addClass('layui-show');
+                this.isInit = true
+            },
+            has: function (url) {
+                var exists = false;
+                layui.each(this.data, function (i, data) {
+                    if (data.fileurl === url) return (exists = data)
+                });
+                return exists
+            },
+            delAll: function (type) {
+                var tab = this;
+                var menuBtnClas = tab.menu + ' .layuix-tabs-btn';
+                $(menuBtnClas).each(function () {
+                    var url = $(this).attr('lay-url');
+                    if (url === conf.entry) return true;
+                    tab.del(url)
+                })
+            },
+            delOther: function () {
+                var tab = this;
+                var menuBtnClas = tab.menu + ' .layuix-tabs-btn';
+                $(menuBtnClas + '.layuix-tabs-active')
+                    .siblings()
+                    .each(function () {
                         var url = $(this).attr('lay-url');
-                        if (url === conf.entry) return true;
                         tab.del(url)
                     })
-                },
-                delOther: function () {
-                    var tab = this;
-                    var menuBtnClas = tab.menu + ' .layuix-tabs-btn';
-                    $(menuBtnClas + '.layuix-tabs-active')
-                        .siblings()
-                        .each(function () {
-                            var url = $(this).attr('lay-url');
-                            tab.del(url)
-                        })
-                },
-                del: function (url, backgroundDel) {
-                    var tab = this;
-                    if (tab.data.length <= 1 && backgroundDel === undefined) return;
-                    layui.each(tab.data, function (i, data) {
-                        if (data.fileurl === url) {
-                            tab.data.splice(i, 1);
-                            return true
-                        }
-                    });
+            },
+            del: function (url, backgroundDel) {
+                var tab = this;
+                if (tab.data.length <= 1 && backgroundDel === undefined) return;
+                layui.each(tab.data, function (i, data) {
+                    if (data.fileurl === url) {
+                        tab.data.splice(i, 1);
+                        return true
+                    }
+                });
 
-                    var lay = '[lay-url="' + url + '"]';
-                    var thisBody = $(
-                        '#' + conf.containerBody + ' > .layuix-tabs-item' + lay
-                    );
-                    var thisMenu = $(this.menu).find(lay);
-                    thisMenu.remove();
-                    thisBody.remove();
+                var lay = '[lay-url="' + url + '"]';
+                var thisBody = $(
+                    '#' + conf.containerBody + ' > .layuix-tabs-item' + lay
+                );
+                var thisMenu = $(this.menu).find(lay);
+                thisMenu.remove();
+                thisBody.remove();
 
-                    if (backgroundDel === undefined) {
-                        if (thisMenu.hasClass('layuix-tabs-active')) {
-                            $(this.menu + ' li:last').click()
-                        }
-                    }
-                },
-                refresh: function (url) {
-                    url = url || layui.layuix.route.fileurl;
-                    if (this.has(url)) {
-                        this.del(url, true);
-                        self.renderTabs(url)
-                    }
-                },
-                clear: function () {
-                    this.data = [];
-                    this.isInit = false;
-                    $(document).off('click', this.wrap + ' .layuix-tabs-btn')
-                },
-                change: function (route, callback) {
-                    console.log('调用 change')
-                    if (typeof route == 'string') {
-                        route = layui.router('#' + route);
-                        //route.fileurl = '/' + route.path.join('/')
-                        route.fileurl = route.path.join('/')
+                if (backgroundDel === undefined) {
+                    if (thisMenu.hasClass('layuix-tabs-active')) {
+                        $(this.menu + ' li:last').click()
                     }
-                    console.log(route)
-                    console.log(route.fileurl)
-                    console.log('-------------------------')
-                    var fileurl = route.fileurl;
-                    var tab = this;
-                    if (tab.isInit === false) tab.init();
-
-                    var changeView = function (lay) {
-                        $('#' + conf.containerBody + ' > .layuix-tabs-item' + lay)
-                            .show()
-                            .siblings()
-                            .hide()
-                    };
-
-                    var lay = '[lay-url="' + fileurl + '"]';
-
-                    var activeCls = 'layuix-tabs-active';
-
-                    var existsTab = tab.has(fileurl);
-                    if (existsTab) {
-                        var menu = $(this.menu);
-                        var currentMenu = menu.find(lay);
-
-                        if (existsTab.href !== route.href) {
-                            tab.del(existsTab.fileurl, true);
-                            tab.change(route);
-                            return false
-                            //tab.del(route.fileurl)
-                        }
-                        currentMenu
-                            .addClass(activeCls)
-                            .siblings()
-                            .removeClass(activeCls);
+                }
+            },
+            refresh: function (url) {
+                url = url || layui.layuix.route.fileurl;
+                if (this.has(url)) {
+                    this.del(url, true);
+                    self.renderTabs(url)
+                }
+            },
+            clear: function () {
+                this.data = [];
+                this.isInit = false;
+                $(document).off('click', this.wrap + ' .layuix-tabs-btn')
+            },
+            change: function (route, callback) {
+                console.log('调用 change')
+                if (typeof route == 'string') {
+                    route = layui.router('#' + route);
+                    //route.fileurl = '/' + route.path.join('/')
+                    route.fileurl = route.path.join('/')
+                }
+                console.log(route)
+                console.log(route.fileurl)
+                console.log('-------------------------')
+                var fileurl = route.fileurl;
+                var tab = this;
+                if (tab.isInit === false) tab.init();
+
+                var changeView = function (lay) {
+                    $('#' + conf.containerBody + ' > .layuix-tabs-item' + lay)
+                        .show()
+                        .siblings()
+                        .hide()
+                };
 
-                        changeView(lay);
+                var lay = '[lay-url="' + fileurl + '"]';
 
-                        this.minLeft = this.minLeft || parseInt(menu.css('left'));
+                var activeCls = 'layuix-tabs-active';
 
-                        var offsetLeft = currentMenu.offset().left;
-                        if (offsetLeft - this.minLeft - $(this.next).width() < 0) {
-                            $(this.prev).click()
-                        } else if (offsetLeft - this.minLeft > menu.width() * 0.5) {
-                            $(this.next).click()
-                        }
-                        $(document).scrollTop(-100);
+                var existsTab = tab.has(fileurl);
+                if (existsTab) {
+                    var menu = $(this.menu);
+                    var currentMenu = menu.find(lay);
 
-                        layui.layuix.navigate(route.href)
-                    } else {
-                        console.log('获取 html 文件 -> ' + fileurl)
-                        self.loadHtml(fileurl, function (res) {
-                            var htmlElem = $(
-                                "<div><div class='layuix-tabs-item' lay-url='" +
-                                fileurl +
-                                "'>" +
-                                res.html +
-                                '</div></div>'
-                            );
-                            var params = self.fillHtml(fileurl, htmlElem, 'prepend');
-                            route.title = params.title;
-                            tab.data.push(route);
-                            layui.layuix.render(tab.tabMenuTplId);
-
-                            var currentMenu = $(tab.menu + ' ' + lay);
-                            currentMenu.addClass(activeCls);
-
-                            changeView(lay);
-
-                            if ($.isFunction(callback)) callback(params)
-                        })
+                    if (existsTab.href !== route.href) {
+                        tab.del(existsTab.fileurl, true);
+                        tab.change(route);
+                        return false
+                        //tab.del(route.fileurl)
                     }
-                    layui.layuix.sidebarFocus(route.href);
-                    return false
-                },
-                onChange: function () {
-                }
-            };
+                    currentMenu
+                        .addClass(activeCls)
+                        .siblings()
+                        .removeClass(activeCls);
 
-            self.fillHtml = function (url, htmlElem, modeName) {
-                var fluid = htmlElem.find('.layui-fluid[lay-title]');
-                var title = '';
-                if (fluid.length > 0) {
-                    title = fluid.attr('lay-title');
-                    // self.setTitle(title)
-                }
+                    changeView(lay);
 
-                var container = self.containerBody || self.container;
-                container[modeName](htmlElem.html());
-                if (modeName === 'prepend') {
-                    self.parse(container.children('[lay-url="' + url + '"]'))
-                } else {
-                    self.parse(container)
-                }
-                return {title: title, url: url, htmlElem: htmlElem}
-            };
+                    this.minLeft = this.minLeft || parseInt(menu.css('left'));
 
-            //解析普通文件
-            self.render = function (fileurl, callback) {
-                self.loadHtml(fileurl, function (res) {
-                    var htmlElem = $('<div>' + res.html + '</div>');
-                    var params = self.fillHtml(res.url, htmlElem, 'html');
-                    if ($.isFunction(callback)) callback(params)
-                })
-            };
-            // 渲染 tab
-            self.renderTabs = function (route, callback) {
-                var tab = self.tab;
-                tab.change(route, callback)
-            };
+                    var offsetLeft = currentMenu.offset().left;
+                    if (offsetLeft - this.minLeft - $(this.next).width() < 0) {
+                        $(this.prev).click()
+                    } else if (offsetLeft - this.minLeft > menu.width() * 0.5) {
+                        $(this.next).click()
+                    }
+                    $(document).scrollTop(-100);
 
-            // 渲染 layout 文件
-            self.renderLayout = function (callback, url) {
-                if (url === undefined) url = 'layout';
-                self.containerBody = null;
+                    layui.layuix.navigate(route.href)
+                } else {
+                    self.loadHtml(fileurl, function (res) {
+                        var htmlElem = $(
+                            "<div><div class='layuix-tabs-item' lay-url='" +
+                            fileurl +
+                            "'>" +
+                            res.html +
+                            '</div></div>'
+                        );
+                        var params = self.fillHtml(fileurl, htmlElem, 'prepend');
+                        route.title = params.title;
+                        tab.data.push(route);
+                        layui.layuix.render(tab.tabMenuTplId);
 
-                self.render(url, function (res) {
-                    self.containerBody = $('#' + conf.containerBody);
-                    if (conf.viewTabs === true) {
-                        self.containerBody.addClass('layuix-tabs-body')
-                    }
-                    layui.layuix.appBody = self.containerBody;
-                    if ($.isFunction(callback)) callback()
-                })
-            };
-            // 加载单页面
-            self.renderSinglePage = function (fileurl, callback) {
-                self.renderLayout(function () {
-                    self.containerBody = null;
-                    if ($.isFunction(callback)) callback()
-                }, fileurl)
-            };
-            self.log = function (msg, type) {
-                if (conf.debug === false) return;
-                if (type === undefined) type = 'error';
-                console.error(msg)
-            };
-            self.createRequestParams = function (params) {
-                var success = params.success;
-                var error = params.error;
-
-                if (params.api) {
-                    if (!layui.api[params.api]) {
-                        self.log('请求错误 api.' + params.api + ' 不存在');
-                        return
-                    }
-                    params.url = conf.requestUrl + layui.api[params.api]
-                } else if (params.url) {
-                    params.url = conf.requestUrl + params.url
-                }
+                        var currentMenu = $(tab.menu + ' ' + lay);
+                        currentMenu.addClass(activeCls);
 
-                var defaultParams = {
-                    timeout: 5000,
-                    type: 'get',
-                    dataType: 'json',
-                    headers: conf.requestHeaders || {},
-                    success: function (res) {
-                        if ($.isFunction(success)) success(res)
-                    },
-                    error: function (res) {
-                        if (res.status === conf.logoutHttpCode) {
-                            // do nothing
-                        } else {
-                            layer.msg('请检查您的网络连接');
-                            self.log('请检查您的网络连接,错误信息:' + JSON.stringify(res))
-                        }
+                        changeView(lay);
 
-                        if ($.isFunction(error)) error(res)
+                        if ($.isFunction(callback)) callback(params)
+                    })
+                }
+                layui.layuix.sidebarFocus(route.href);
+                return false
+            },
+            onChange: function () {
+            }
+        };
+
+        self.fillHtml = function (url, htmlElem, modeName) {
+            var fluid = htmlElem.find('.layui-fluid[lay-title]');
+            var title = '';
+            if (fluid.length > 0) {
+                title = fluid.attr('lay-title');
+                // self.setTitle(title)
+            }
+
+            var container = self.containerBody || self.container;
+            container[modeName](htmlElem.html());
+            if (modeName === 'prepend') {
+                self.parse(container.children('[lay-url="' + url + '"]'))
+            } else {
+                self.parse(container)
+            }
+            return {title: title, url: url, htmlElem: htmlElem}
+        };
+
+        // 渲染 html 页面
+        self.render = function (fileurl, callback) {
+            self.loadHtml(fileurl, function (res) {
+                var htmlElem = $('<div>' + res.html + '</div>');
+                var params = self.fillHtml(res.url, htmlElem, 'html');
+                if ($.isFunction(callback)) callback(params)
+            })
+        };
+
+        // 渲染 tab
+        self.renderTabs = function (route, callback) {
+            var tab = self.tab;
+            tab.change(route, callback)
+        };
+
+        // 渲染 layout.html
+        self.renderLayout = function (callback, url) {
+            if (url === undefined) url = 'layout';
+            self.containerBody = null;
+
+            self.render(url, function (res) {
+                // 设置 containerBody
+                self.containerBody = $('#' + conf.containerBody);
+                if (conf.viewTabs === true) {
+                    self.containerBody.addClass('layuix-tabs-body')
+                }
+                layui.layuix.appBody = self.containerBody;
+                if ($.isFunction(callback)) callback()
+            })
+        };
+        // 加载单页面
+        self.renderSinglePage = function (fileurl, callback) {
+            self.renderLayout(function () {
+                self.containerBody = null;
+                if ($.isFunction(callback)) callback()
+            }, fileurl)
+        };
+        self.log = function (msg, type) {
+            if (conf.debug === false) return;
+            if (type === undefined) type = 'error';
+            console.error(msg)
+        };
+        self.createRequestParams = function (params) {
+            var success = params.success;
+            var error = params.error;
+
+            if (params.api) {
+                if (!layui.api[params.api]) {
+                    self.log('请求错误 api.' + params.api + ' 不存在');
+                    return
+                }
+                params.url = conf.requestUrl + layui.api[params.api]
+            } else if (params.url) {
+                params.url = conf.requestUrl + params.url
+            }
+
+            var defaultParams = {
+                timeout: 5000,
+                type: 'get',
+                dataType: 'json',
+                headers: conf.requestHeaders || {},
+                success: function (res) {
+                    if ($.isFunction(success)) success(res)
+                },
+                error: function (res) {
+                    if (res.status === conf.logoutHttpCode) {
+                        // do nothing
+                    } else {
+                        layer.msg('请检查您的网络连接');
+                        self.log('请检查您的网络连接,错误信息:' + JSON.stringify(res))
                     }
-                };
 
-                if (self.ie8) {
-                    if (conf.debug) $.support.cors = true;
-                    defaultParams.cache = false
+                    if ($.isFunction(error)) error(res)
                 }
-                delete params.success;
-                delete params.error;
-
-                return $.extend(defaultParams, params)
-            };
-            self.request = function (params) {
-                params = self.createRequestParams(params);
-                $.ajax(params)
             };
-            exports('view', self)
-        }
-    );
+
+            if (self.ie8) {
+                if (conf.debug) $.support.cors = true;
+                defaultParams.cache = false
+            }
+            delete params.success;
+            delete params.error;
+
+            return $.extend(defaultParams, params)
+        };
+        self.request = function (params) {
+            params = self.createRequestParams(params);
+            $.ajax(params)
+        };
+        exports('view', self)
+    }
+);

+ 11 - 4
dmaster/src/main/resources/templates/login.html

@@ -19,15 +19,11 @@
         <div class="layui-container">
             <div class="layui-row">
                 <div class="layui-col-xs12 layui-col-lg4 layui-col-lg-offset4 layuix-tc">
-                    <!--<div class="layui-logo"><span><b>运维自动化系统</b></span></div>-->
                     <div class="layui-logo"><b>运维自动化系统</b></div>
                 </div>
                 <div class="layui-col-xs12 layui-col-lg4 layui-col-lg-offset4" id="login-div">
                     <div class="layui-form" lay-filter="login-form">
                         <div class="layui-anim layui-anim-upbit">
-                            <ul class="login-type-tab">
-                                <li class="active">系统登录</li>
-                            </ul>
                             <div class="normal-login-form">
                                 <div class="layui-form-item">
                                     <label class="layui-icon label-icon layui-icon-username"></label>
@@ -66,6 +62,9 @@
                             <div class="layui-form-item layuix-tr">
                                 <a id="regist-href">注册账号</a>
                             </div>
+                            <div class="layui-form-item layuix-tr">
+                                <a id="forget-href">忘记密码?</a>
+                            </div>
                         </div>
                     </div>
                 </div>
@@ -124,6 +123,7 @@
             type = 'login',
             $loginDiv = $view.find('#login-div'),
             $registDiv = $view.find('#regist-div');
+            $forget = $view.find('#forget-div');
 
         form.verify(validate);
         form.render();
@@ -186,6 +186,13 @@
             $registDiv.show();
         });
 
+        $view.find('#forget-href').on('click', function () {
+            resetForm();
+            type = 'forget';
+            $loginDiv.hide();
+            forget.show();
+        });
+
         $view.find('#login-href').on('click', function () {
             resetForm();
             type = 'login';

+ 1 - 2
dmaster/src/main/resources/templates/views/layout.html

@@ -83,8 +83,7 @@
                         if (child.icon) {
                             title = '<i class="layui-icon '+child.icon+'"></i>' + child.title
                         }
-                        html += '
-                        <dd><a style="padding-left:' + left + 'px" target="'+(child.target||'')+'"
+                        html += '<dd><a style="padding-left:' + left + 'px" target="'+(child.target||'')+'"
                                lay-href="'+ (child.href||'') +'">' + title + '</a>';
                             if(child.childs) html += __createSlidebar(child.childs,index+1);
                             html += '</dd>';