#
Junjie
3 天以前 686fe55892de7bf8d206cddbead77a5fbdb0e091
src/main/webapp/views/login.html
@@ -88,11 +88,6 @@
<div id="login-wrapper" class="animate__animated animate__bounceInDown">
    <header>
        <h2 id="login-title" style="cursor: pointer; user-select: none;">WCS系统V3.0</h2>
        <div id="system-btns" style="display: none; margin-bottom: 20px;">
            <button class="layui-btn layui-btn-normal layui-btn-sm" id="btn-project-name">获取项目名称</button>
            <button class="layui-btn layui-btn-normal layui-btn-sm" id="btn-server-info">获取系统配置</button>
            <button class="layui-btn layui-btn-normal layui-btn-sm" id="btn-activate">一键激活</button>
        </div>
    </header>
    <div class="layui-form layadmin-user-login-body">
        <div class="layui-form-item">
@@ -103,18 +98,27 @@
            <label class="layui-icon layui-icon-password layadmin-user-login-icon"></label>
            <input id="password" class="layui-input" type="password" name="password" lay-verify="password" placeholder="密码">
        </div>
<!--        <div id="code-box" class="layui-form-item" style="">-->
<!--            <label id="code-label" class="layui-icon layui-icon-vercode layadmin-user-login-icon"></label>-->
<!--            <input id="code" class="layui-input" type="text" name="password" lay-verify="code" placeholder="验证码">-->
<!--            <img id="codeImg" title="看不清?点击换一张。">-->
<!--        </div>-->
        <!--<div class="layui-form-item">-->
            <!--<input id="rememberPwd" style="vertical-align: middle" type="checkbox" lay-filter="remPwd" lay-skin="switch" lay-text="开启|关闭" title="记住密码" checked="checked">-->
            <!--<span style="vertical-align: middle;font-size: 15px">记住密码</span>-->
        <!--</div>-->
    </div>
    <div class="layui-form-item login-submit">
        <button id="login-button" class="layui-btn layui-btn-fluid layui-btn-normal" lay-submit="" lay-filter="login">登 &nbsp  &nbsp 录</button>
    </div>
</div>
<div id="system-tools-panel" style="display: none; padding: 20px;">
    <div style="margin-bottom: 18px;">
        <div style="margin-bottom: 10px; color: #666; font-weight: 600;">推荐操作</div>
        <div style="display: flex; flex-wrap: wrap; gap: 12px;">
            <button class="layui-btn layui-btn-normal layui-btn-sm" id="btn-request-code">获取请求码</button>
            <button class="layui-btn layui-btn-normal layui-btn-sm" id="btn-activate">一键激活</button>
        </div>
        <div style="margin-top: 8px; color: #999; font-size: 12px;">优先使用“获取请求码”和“一键激活”完成许可证申请与激活。</div>
    </div>
    <div>
        <div style="margin-bottom: 10px; color: #666; font-weight: 600;">其他工具</div>
        <div style="display: flex; flex-wrap: wrap; gap: 12px;">
            <button class="layui-btn layui-btn-primary layui-btn-sm" id="btn-project-name">获取项目名称</button>
            <button class="layui-btn layui-btn-primary layui-btn-sm" id="btn-server-info">获取系统配置</button>
            <button class="layui-btn layui-btn-primary layui-btn-sm" id="btn-upload-license">录入许可证</button>
        </div>
    </div>
</div>
@@ -122,40 +126,6 @@
<script type="text/javascript" src="../static/js/jquery/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="../static/js/tools/md5.js"></script>
<script type="text/javascript">
    // // 验证码开关
    // var codeSwitch = 'Y';
    // $.ajax({
    //     url: baseUrl+"/code/switch.action",
    //     async: false,
    //     success: function (res) {
    //         if (res.data === 'N'){
    //             codeSwitch = res.data;
    //             $('#code-box').css("display", "none");
    //         }
    //     }
    // });
    // // 初始化验证码
    // initCode();
    // $('#codeImg').click(function () {
    //     initCode();
    // });
    // function initCode() {
    //     var random = Math.random();
    //     $('#codeImg').attr("src", baseUrl+"/code.action?sd="+random);
    //     setTimeout(function () {
    //         $.ajax({
    //             url: baseUrl+"/code.do",
    //             data: {sd: random},
    //             method: 'POST',
    //             async: false,
    //             success: function (code) {
    //                 sessionStorage.setItem("code", code);
    //             }
    //         });
    //     }, 100);
    // }
    layui.use(['form','layer'],function () {
        var form = layui.form,
@@ -171,8 +141,8 @@
                clearTimeout(titleClickTimer);
            }
            if (titleClickCount >= 3) {
                $('#system-btns').show();
                titleClickCount = 0;
                openSystemToolsDialog();
            } else {
                titleClickTimer = setTimeout(function() {
                    titleClickCount = 0;
@@ -180,56 +150,18 @@
            }
        });
        // 获取系统配置
        $('#btn-server-info').click(function() {
            $.ajax({
                url: baseUrl + "/license/getServerInfos",
                method: 'GET',
                success: function (res) {
                    var pretty = '';
                    try {
                        pretty = JSON.stringify(res, null, 2);
                    } catch (e) {
                        pretty = res;
                    }
                    var html = ''
                        + '<div style="padding:15px 20px 5px 20px;">'
                        +   '<div style="font-weight:600;margin-bottom:8px;">系统配置信息</div>'
                        +   '<pre id="server-info-pre" style="background:#f7f7f7;border:1px solid #e6e6e6;border-radius:6px;padding:12px;white-space:pre-wrap;word-wrap:break-word;max-height:360px;overflow:auto;">'
                        +       pretty
                        +   '</pre>'
                        +   '<div class="layui-btn-container" style="text-align:right;margin-top:6px;">'
                        +       '<button class="layui-btn layui-btn-primary" id="copy-server-info">复制</button>'
                        +   '</div>'
                        + '</div>';
                    layer.open({
                        type: 1,
                        title: '获取系统配置',
                        area: ['640px','480px'],
                        shadeClose: true,
                        content: html,
                        success: function (layero, index) {
                            layero.find('#copy-server-info').on('click', function () {
                                var text = layero.find('#server-info-pre').text();
                                if (navigator.clipboard && navigator.clipboard.writeText) {
                                    navigator.clipboard.writeText(text).then(function () {
                                        layer.msg('已复制到剪贴板');
                                    }).catch(function () {
                                        fallbackCopy(text);
                                    });
                                } else {
                                    fallbackCopy(text);
                                }
                            });
                        }
                    });
                },
                error: function () {
                    layer.msg('获取系统配置信息失败');
        function openSystemToolsDialog() {
            layer.open({
                type: 1,
                title: '系统工具',
                area: ['560px', '300px'],
                shadeClose: true,
                content: $('#system-tools-panel'),
                end: function () {
                    $('#system-tools-panel').hide();
                }
            });
            return false;
        });
        }
        function fallbackCopy(text) {
            try {
@@ -246,6 +178,123 @@
                layer.msg('复制失败');
            }
        }
        function openTextDialog(title, label, text, tip) {
            var html = ''
                + '<div style="padding:15px 20px 5px 20px;">'
                +   '<div style="font-weight:600;margin-bottom:8px;">' + label + '</div>'
                +   (tip ? '<div style="color:#999;margin-bottom:8px;">' + tip + '</div>' : '')
                +   '<textarea id="dialog-text" readonly style="width:100%;min-height:220px;background:#f7f7f7;border:1px solid #e6e6e6;border-radius:6px;padding:12px;line-height:1.6;resize:none;">'
                +       text
                +   '</textarea>'
                +   '<div class="layui-btn-container" style="text-align:right;margin-top:10px;">'
                +       '<button class="layui-btn layui-btn-primary" id="copy-dialog-text">复制</button>'
                +   '</div>'
                + '</div>';
            layer.open({
                type: 1,
                title: title,
                area: ['720px','460px'],
                shadeClose: true,
                content: html,
                success: function (layero) {
                    layero.find('#copy-dialog-text').on('click', function () {
                        var value = layero.find('#dialog-text').val();
                        if (navigator.clipboard && navigator.clipboard.writeText) {
                            navigator.clipboard.writeText(value).then(function () {
                                layer.msg('已复制到剪贴板');
                            }).catch(function () {
                                fallbackCopy(value);
                            });
                        } else {
                            fallbackCopy(value);
                        }
                    });
                }
            });
        }
        // 获取请求码
        $('#btn-request-code').click(function() {
            $.ajax({
                url: baseUrl + "/license/getRequestCode",
                method: 'GET',
                success: function (res) {
                    if (res.code === 200){
                        openTextDialog('获取请求码', '请求码', res.msg || '', '请求码中已包含项目名称,直接发给许可证服务端即可。');
                    } else {
                        layer.msg(res.msg || '获取请求码失败');
                    }
                },
                error: function () {
                    layer.msg('获取请求码失败');
                }
            });
            return false;
        });
        // 获取系统配置
        $('#btn-server-info').click(function() {
            $.ajax({
                url: baseUrl + "/license/getServerInfos",
                method: 'GET',
                success: function (res) {
                    var pretty = '';
                    try {
                        pretty = JSON.stringify(res, null, 2);
                    } catch (e) {
                        pretty = res;
                    }
                    openTextDialog('获取系统配置', '系统配置信息', pretty, '老项目仍可继续使用这份硬件信息 JSON 申请许可证。');
                },
                error: function () {
                    layer.msg('获取系统配置信息失败');
                }
            });
            return false;
        });
        // 录入许可证
        $('#btn-upload-license').click(function () {
            layer.open({
                type: 1,
                title: '录入许可证',
                area: ['760px', '420px'],
                shadeClose: true,
                content: ''
                    + '<div style="padding:15px 20px 5px 20px;">'
                    +   '<div style="font-weight:600;margin-bottom:8px;">许可证 Base64</div>'
                    +   '<div style="color:#999;margin-bottom:8px;">将许可证服务端返回的 license 字段完整粘贴到这里。</div>'
                    +   '<textarea id="license-base64-input" style="width:100%;min-height:240px;background:#fff;border:1px solid #e6e6e6;border-radius:6px;padding:12px;line-height:1.6;resize:none;"></textarea>'
                    + '</div>',
                btn: ['提交', '取消'],
                yes: function (index, layero) {
                    var license = $.trim(layero.find('#license-base64-input').val());
                    if (!license) {
                        layer.msg('许可证内容不能为空');
                        return;
                    }
                    $.ajax({
                        url: baseUrl + '/license/updateLicense',
                        method: 'POST',
                        contentType: 'application/json;charset=UTF-8',
                        data: JSON.stringify({license: license}),
                        success: function (res) {
                            if (res.code === 200) {
                                layer.close(index);
                                layer.msg('许可证更新成功');
                            } else {
                                layer.msg(res.msg || '许可证更新失败');
                            }
                        },
                        error: function () {
                            layer.msg('许可证录入失败');
                        }
                    });
                }
            });
            return false;
        });
        // 一键激活
        $('#btn-activate').click(function() {
@@ -299,15 +348,6 @@
                layer.msg("请输入密码", {offset: '150px'});
                return;
            }
            // var code = $("#code").val();
            // if (code === "" && codeSwitch === 'Y') {
            //     layer.msg("请输入验证码", {offset: '150px'});
            //     return;
            // }
            // if (sessionStorage.getItem("code").toUpperCase() !== code.toUpperCase()&&codeSwitch==='Y'){
            //     layer.msg("验证码错误", {offset: '150px'});
            //     return;
            // }
            var user = {
                mobile: mobile,
@@ -339,4 +379,4 @@
    });
</script>
<script type></script>
</html>
</html>