| | |
| | | <!-- <li class="layui-nav-item" lay-unselect>--> |
| | | <!-- <a ew-event="note" title="便签"><i class="layui-icon layui-icon-note"></i></a>--> |
| | | <!-- </li>--> |
| | | <li class="layui-nav-item" lay-unselect id="fakeShow" |
| | | style="display: none;user-select: none;margin-right: 10px;"> |
| | | <div style="color: red;" id="fakeShowText">仿真模拟运行中</div> |
| | | </li> |
| | | <li class="layui-nav-item" lay-unselect id="licenseShow" style="display: none;user-select: none;"> |
| | | <div style="color: red;">临时许可证有效期:<span id="licenseDays">29</span>天</div> |
| | | </li> |
| | | <li class="layui-nav-item layui-hide-xs" lay-unselect> |
| | | <a ew-event="fullScreen" title="全屏"><i class="layui-icon layui-icon-screen-full"></i></a> |
| | | </li> |
| | |
| | | <!--初始化加载层--> |
| | | <div class="layuimini-loader"> |
| | | <div class="layuimini-loader-inner"></div> |
| | | </div> |
| | | |
| | | <!-- 弹窗内容 --> |
| | | <div class="popup" id="popup"> |
| | | <div class="popup-content"> |
| | | <h2 style="font-size: 28px;margin-bottom: 10px;">许可证即将过期</h2> |
| | | <div id="popup-text" style="font-size: 28px;color: red"></div> |
| | | <button |
| | | style="background-color: #007bff;color: #fff;border: none;padding: 10px 20px;border-radius: 5px;cursor: pointer;font-size: 16px;" |
| | | onclick="hidePopup()">关闭</button> |
| | | </div> |
| | | </div> |
| | | |
| | | <!-- 右下角SVG动画 --> |
| | |
| | | loadSystemVersion(); |
| | | }); |
| | | |
| | | // 显示弹窗 |
| | | function showPopup(res) { |
| | | document.getElementById('popup').style.display = 'block'; |
| | | // 获取弹出窗口内容的容器元素 |
| | | var popupText = document.getElementById('popup-text'); |
| | | // 假设后台返回的字符串为 responseString |
| | | if (res !== "") { |
| | | // 获取当前日期 |
| | | const currentDate = new Date(); |
| | | // 创建新日期对象并添加天数 |
| | | const newDate = new Date(); |
| | | newDate.setDate(currentDate.getDate() + res + 1); |
| | | // 将字符串设置为弹窗内容的文本 |
| | | popupText.textContent = "许可证将于" + new Intl.DateTimeFormat('zh-CN').format(newDate) + "过期,剩余有效期:" + res + "天!"; |
| | | } else { |
| | | document.getElementById('popup').style.display = 'none'; |
| | | } |
| | | } |
| | | |
| | | // 隐藏弹窗 |
| | | function hidePopup() { |
| | | document.getElementById('popup').style.display = 'none'; |
| | | } |
| | | |
| | | layui.config({ |
| | | base: baseUrl + "/static/layui/lay/modules/" |
| | | }).extend({ |
| | |
| | | } |
| | | } |
| | | |
| | | let fakeRunning = false |
| | | let fakeStatusInterval = null |
| | | function checkFakeStatus() { |
| | | $.ajax({ |
| | | url: baseUrl + "/openapi/getFakeSystemRunStatus", |
| | | headers: { 'token': localStorage.getItem('token') }, |
| | | method: 'GET', |
| | | success: function (res) { |
| | | if (res.code === 200) { |
| | | if (res.data.isFake) { |
| | | $("#fakeShow").show() |
| | | let running = res.data.running |
| | | if (running) { |
| | | $("#fakeShowText").text("仿真模拟运行中") |
| | | } else { |
| | | $("#fakeShowText").text("仿真模拟未运行") |
| | | } |
| | | fakeRunning = running |
| | | if (!fakeStatusInterval) { |
| | | fakeStatusInterval = setInterval(checkFakeStatus, 1000); |
| | | } |
| | | } else { |
| | | $("#fakeShow").hide() |
| | | if (fakeStatusInterval) { |
| | | clearInterval(fakeStatusInterval); |
| | | fakeStatusInterval = null; |
| | | } |
| | | } |
| | | } else { |
| | | top.location.href = baseUrl + "/login"; |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | checkFakeStatus(); |
| | | |
| | | $("#fakeShow").on("click", function () { |
| | | if (fakeRunning) { |
| | | layer.confirm('确定要停止仿真模拟吗?', function (index) { |
| | | layer.close(index); |
| | | $.ajax({ |
| | | url: baseUrl + "/openapi/stopFakeSystem", |
| | | headers: { 'token': localStorage.getItem('token') }, |
| | | method: 'POST', |
| | | success: function (res) { |
| | | if (res.code === 200) { |
| | | layer.msg("仿真模拟已停止", { icon: 1 }); |
| | | $("#fakeShowText").text("仿真模拟未运行") |
| | | } else { |
| | | layer.msg(res.msg, { icon: 2 }); |
| | | } |
| | | } |
| | | }); |
| | | }); |
| | | } else { |
| | | layer.confirm('确定要启动仿真模拟吗?', function (index) { |
| | | layer.close(index); |
| | | $.ajax({ |
| | | url: baseUrl + "/openapi/startFakeSystem", |
| | | headers: { 'token': localStorage.getItem('token') }, |
| | | method: 'POST', |
| | | success: function (res) { |
| | | if (res.code === 200) { |
| | | layer.msg("仿真模拟已启动", { icon: 1 }); |
| | | $("#fakeShowText").text("仿真模拟运行中") |
| | | } else { |
| | | layer.msg(res.msg, { icon: 2 }); |
| | | } |
| | | } |
| | | }); |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | $.ajax({ |
| | | url: baseUrl + "/menu/auth", |
| | | headers: { 'token': localStorage.getItem('token') }, |
| | |
| | | top.location.href = baseUrl + "/login"; |
| | | } else { |
| | | layer.msg(res.msg, { icon: 2 }); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | $.ajax({ |
| | | url: baseUrl + "/license/getLicenseDays", |
| | | headers: { 'token': localStorage.getItem('token') }, |
| | | method: 'POST', |
| | | success: function (res) { |
| | | if (res.code == 200) { |
| | | let days = res.data |
| | | if (days <= 30) { |
| | | $("#licenseShow").show() |
| | | $("#licenseDays").html(days) |
| | | } |
| | | |
| | | if (days <= 15) { |
| | | showPopup(days) |
| | | } |
| | | |
| | | if (days < 0) { |
| | | top.location.href = baseUrl + "/login"; |
| | | } |
| | | } else { |
| | | top.location.href = baseUrl + "/login"; |
| | | } |
| | | } |
| | | }); |