From 780ff45fdc167cadf4724c6c94530929b7445aab Mon Sep 17 00:00:00 2001
From: zwl <1051256694@qq.com>
Date: 星期一, 16 三月 2026 10:37:51 +0800
Subject: [PATCH] 完善许可证
---
src/main/webapp/views/login.html | 621 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 585 insertions(+), 36 deletions(-)
diff --git a/src/main/webapp/views/login.html b/src/main/webapp/views/login.html
index a113203..6456928 100644
--- a/src/main/webapp/views/login.html
+++ b/src/main/webapp/views/login.html
@@ -46,6 +46,178 @@
text-align: center;
}
+ .license-entry-text {
+ width: 80%;
+ margin: 0 auto 12px;
+ color: #5e5e5e;
+ font-size: 12px;
+ line-height: 1.7;
+ text-align: left;
+ }
+
+ .system-tool-shell {
+ background: #ffffff;
+ border-radius: 22px;
+ overflow: hidden;
+ }
+
+ .system-tool-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 14px 20px;
+ border-bottom: 1px solid #dbe4ef;
+ }
+
+ .system-tool-title {
+ color: #243447;
+ font-size: 18px;
+ font-weight: 700;
+ }
+
+ .system-tool-close {
+ color: #97a5b4;
+ font-size: 24px;
+ line-height: 1;
+ cursor: pointer;
+ user-select: none;
+ }
+
+ .system-tool-body {
+ padding: 18px 20px 22px;
+ background: #ffffff;
+ }
+
+ .system-tool-group + .system-tool-group {
+ margin-top: 18px;
+ padding-top: 18px;
+ border-top: 1px solid #e8eef5;
+ }
+
+ .system-tool-group-title {
+ color: #34495e;
+ font-size: 14px;
+ font-weight: 700;
+ margin-bottom: 14px;
+ }
+
+ .system-tool-actions {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 12px 18px;
+ }
+
+ .system-tool-btn {
+ min-width: 104px;
+ height: 34px;
+ padding: 0 18px;
+ border: 1px solid #d7dfea;
+ border-radius: 4px;
+ background: #ffffff;
+ color: #4d5d6d;
+ font-size: 14px;
+ cursor: pointer;
+ box-sizing: border-box;
+ }
+
+ .system-tool-btn.primary {
+ color: #ffffff;
+ background: #5da8ff;
+ border-color: #5da8ff;
+ }
+
+ .system-tool-btn.secondary {
+ color: #7eb4ef;
+ background: #d9ecff;
+ border-color: #aed4ff;
+ }
+
+ .system-tool-desc {
+ margin-top: 12px;
+ color: #9aa8b6;
+ font-size: 12px;
+ line-height: 1.7;
+ }
+
+ .system-dialog-shell {
+ background: #ffffff;
+ border-radius: 18px;
+ overflow: hidden;
+ }
+
+ .system-dialog-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 14px 18px;
+ border-bottom: 1px solid #e1e8f0;
+ background: #f8fbff;
+ }
+
+ .system-dialog-title {
+ color: #243447;
+ font-size: 16px;
+ font-weight: 700;
+ }
+
+ .system-dialog-close {
+ color: #97a5b4;
+ font-size: 22px;
+ line-height: 1;
+ cursor: pointer;
+ user-select: none;
+ }
+
+ .system-dialog-body {
+ padding: 18px;
+ background: #ffffff;
+ }
+
+ .system-dialog-label {
+ color: #43576b;
+ font-size: 13px;
+ font-weight: 700;
+ margin-bottom: 8px;
+ }
+
+ .system-dialog-tip {
+ margin-bottom: 10px;
+ color: #8c9aac;
+ font-size: 12px;
+ line-height: 1.7;
+ }
+
+ .system-dialog-textarea {
+ width: 100%;
+ min-height: 220px;
+ resize: none;
+ border: 1px solid #d7dfea;
+ border-radius: 8px;
+ padding: 10px 12px;
+ box-sizing: border-box;
+ color: #4d5d6d;
+ background: #fbfdff;
+ font-size: 13px;
+ line-height: 1.7;
+ }
+
+ .system-dialog-footer {
+ display: flex;
+ justify-content: flex-end;
+ gap: 10px;
+ margin-top: 14px;
+ }
+
+ body .system-tool-popup {
+ border-radius: 22px !important;
+ overflow: hidden !important;
+ }
+
+ body .system-tool-popup .layui-layer-content {
+ overflow: hidden !important;
+ background: transparent;
+ }
+
</style>
</head>
<body>
@@ -90,10 +262,8 @@
<button class="login100-form-btn login-btn">Login</button>
</div>
<div class="container-login100-form-btn p-t-10" style="display: none;margin-top: 50px;" id="updateLicense">
- <form enctype="multipart/form-data" style="display: none;">
- <input id="license" type="file" name="file">
- </form>
- <button class="login100-form-btn" id="submitLicense">鏇存柊璁稿彲璇�</button>
+ <div class="license-entry-text" id="licenseEntryMessage">绯荤粺褰撳墠鏈娴嬪埌鍙敤璁稿彲璇侊紝璇锋墦寮�绯荤粺宸ュ叿澶勭悊璁稿彲璇併��</div>
+ <button class="login100-form-btn" id="openLicenseTool" type="button">绯荤粺宸ュ叿</button>
</div>
</div>
</div>
@@ -115,10 +285,417 @@
if (oldPass) {
$('#password').val(oldPass);
}
+ autoShowLicenseTool();
})
window.onload = function () {
document.getElementById("username").focus();
+ }
+
+ var licenseToolState = {
+ toolLayerIndex: null,
+ textLayerIndex: null,
+ uploadLayerIndex: null
+ };
+
+ function getQueryValue(name) {
+ var query = window.location.search.substring(1).split("&");
+ for (var i = 0; i < query.length; i++) {
+ var item = query[i].split("=");
+ if (item[0] === name) {
+ return decodeURIComponent(item[1] || "");
+ }
+ }
+ return "";
+ }
+
+ function autoShowLicenseTool() {
+ var needOpen = getQueryValue("license") === "invalid" || sessionStorage.getItem("licensePanelAutoOpen") === "1";
+ if (!needOpen) {
+ return;
+ }
+ var message = sessionStorage.getItem("licenseInvalidReason") || "绯荤粺褰撳墠鏈娴嬪埌鍙敤璁稿彲璇侊紝璇峰厛瀵煎叆鏂扮殑璁稿彲璇併��";
+ showLicenseEntry(message);
+ openLicenseTool(message);
+ }
+
+ function showLicenseEntry(message) {
+ $("#updateLicense").show();
+ if (message) {
+ $("#licenseEntryMessage").text(message);
+ }
+ }
+
+ function escapeHtml(text) {
+ return String(text || "")
+ .replace(/&/g, "&")
+ .replace(/</g, "<")
+ .replace(/>/g, ">")
+ .replace(/\"/g, """)
+ .replace(/'/g, "'");
+ }
+
+ function buildLicenseToolContent() {
+ return ''
+ + '<div class="system-tool-shell">'
+ + ' <div class="system-tool-header">'
+ + ' <div class="system-tool-title">绯荤粺宸ュ叿</div>'
+ + ' <span class="system-tool-close" id="toolClose">脳</span>'
+ + ' </div>'
+ + ' <div class="system-tool-body">'
+ + ' <div class="system-tool-group">'
+ + ' <div class="system-tool-group-title">鎺ㄨ崘鎿嶄綔</div>'
+ + ' <div class="system-tool-actions">'
+ + ' <button type="button" class="system-tool-btn primary" id="toolRequestCode">鑾峰彇璇锋眰鐮�</button>'
+ + ' <button type="button" class="system-tool-btn secondary" id="toolActivate">涓�閿縺娲�</button>'
+ + ' </div>'
+ + ' <div class="system-tool-desc">浼樺厛浣跨敤鈥滆幏鍙栬姹傜爜鈥濆拰鈥滀竴閿縺娲烩�濆畬鎴愯鍙瘉鐢宠涓庢縺娲汇��</div>'
+ + ' </div>'
+ + ' <div class="system-tool-group">'
+ + ' <div class="system-tool-group-title">鍏朵粬宸ュ叿</div>'
+ + ' <div class="system-tool-actions">'
+ + ' <button type="button" class="system-tool-btn" id="toolProjectName">鑾峰彇椤圭洰鍚嶇О</button>'
+ + ' <button type="button" class="system-tool-btn" id="toolServerInfo">鑾峰彇绯荤粺閰嶇疆</button>'
+ + ' <button type="button" class="system-tool-btn" id="toolInputLicense">褰曞叆璁稿彲璇�</button>'
+ + ' </div>'
+ + ' </div>'
+ + ' </div>'
+ + '</div>';
+ }
+
+ function openLicenseTool(message) {
+ var toolMessage = message || $("#licenseEntryMessage").text() || "绯荤粺褰撳墠鏈娴嬪埌鍙敤璁稿彲璇侊紝璇峰厛瀵煎叆鏂扮殑璁稿彲璇併��";
+ var toolWidth = Math.min($(window).width() - 32, 760);
+ showLicenseEntry(toolMessage);
+ if (licenseToolState.toolLayerIndex !== null) {
+ layer.close(licenseToolState.toolLayerIndex);
+ }
+ licenseToolState.toolLayerIndex = layer.open({
+ type: 1,
+ title: false,
+ closeBtn: 0,
+ area: [Math.min(toolWidth, 560) + 'px', 'auto'],
+ shadeClose: false,
+ skin: 'system-tool-popup',
+ content: buildLicenseToolContent(),
+ success: function (layero, index) {
+ licenseToolState.toolLayerIndex = index;
+ bindLicenseToolEvents(layero);
+ },
+ end: function () {
+ licenseToolState.toolLayerIndex = null;
+ }
+ });
+ }
+
+ function bindLicenseToolEvents(layero) {
+ layero.find("#toolClose").on("click", function () {
+ layer.close(licenseToolState.toolLayerIndex);
+ });
+ layero.find("#toolRequestCode").on("click", function () {
+ requestCode();
+ });
+ layero.find("#toolActivate").on("click", function () {
+ activateLicense();
+ });
+ layero.find("#toolProjectName").on("click", function () {
+ getProjectName();
+ });
+ layero.find("#toolServerInfo").on("click", function () {
+ getServerInfo();
+ });
+ layero.find("#toolInputLicense").on("click", function () {
+ openLicenseInputDialog();
+ });
+ }
+
+ function getResponseValue(res) {
+ if (!res) {
+ return "";
+ }
+ if (typeof res.data !== "undefined" && res.data !== null && res.data !== "") {
+ return res.data;
+ }
+ if (typeof res.msg !== "undefined" && res.msg !== null && res.msg !== "") {
+ return res.msg;
+ }
+ return "";
+ }
+
+ function openTextDialog(title, label, text, tip) {
+ var prettyText = "";
+ try {
+ prettyText = typeof text === "string" ? text : JSON.stringify(text, null, 2);
+ } catch (e) {
+ prettyText = String(text || "");
+ }
+ if (licenseToolState.textLayerIndex !== null) {
+ layer.close(licenseToolState.textLayerIndex);
+ }
+ licenseToolState.textLayerIndex = layer.open({
+ type: 1,
+ title: false,
+ closeBtn: 0,
+ area: [Math.min($(window).width() - 32, 720) + 'px', 'auto'],
+ shadeClose: false,
+ skin: 'system-tool-popup',
+ content: ''
+ + '<div class="system-dialog-shell">'
+ + ' <div class="system-dialog-header">'
+ + ' <div class="system-dialog-title">' + escapeHtml(title) + '</div>'
+ + ' <span class="system-dialog-close" id="systemTextClose">脳</span>'
+ + ' </div>'
+ + ' <div class="system-dialog-body">'
+ + ' <div class="system-dialog-label">' + escapeHtml(label) + '</div>'
+ + (tip ? '<div class="system-dialog-tip">' + escapeHtml(tip) + '</div>' : '')
+ + ' <textarea class="system-dialog-textarea" id="systemDialogText" readonly></textarea>'
+ + ' <div class="system-dialog-footer">'
+ + ' <button type="button" class="system-tool-btn" id="systemTextCloseBtn">鍏抽棴</button>'
+ + ' <button type="button" class="system-tool-btn primary" id="systemTextCopy">澶嶅埗</button>'
+ + ' </div>'
+ + ' </div>'
+ + '</div>',
+ success: function (layero, index) {
+ licenseToolState.textLayerIndex = index;
+ layero.find("#systemDialogText").val(prettyText);
+ layero.find("#systemTextClose, #systemTextCloseBtn").on("click", function () {
+ layer.close(index);
+ });
+ layero.find("#systemTextCopy").on("click", function () {
+ copyRequestCodeText(prettyText);
+ });
+ },
+ end: function () {
+ licenseToolState.textLayerIndex = null;
+ }
+ });
+ }
+
+ function openLicenseInputDialog() {
+ if (licenseToolState.uploadLayerIndex !== null) {
+ layer.close(licenseToolState.uploadLayerIndex);
+ }
+ licenseToolState.uploadLayerIndex = layer.open({
+ type: 1,
+ title: false,
+ closeBtn: 0,
+ area: [Math.min($(window).width() - 32, 760) + 'px', 'auto'],
+ shadeClose: false,
+ skin: 'system-tool-popup',
+ content: ''
+ + '<div class="system-dialog-shell">'
+ + ' <div class="system-dialog-header">'
+ + ' <div class="system-dialog-title">褰曞叆璁稿彲璇�</div>'
+ + ' <span class="system-dialog-close" id="licenseInputClose">脳</span>'
+ + ' </div>'
+ + ' <div class="system-dialog-body">'
+ + ' <div class="system-dialog-label">璁稿彲璇� Base64</div>'
+ + ' <div class="system-dialog-tip">灏嗚鍙瘉鏈嶅姟绔繑鍥炵殑 license 瀛楁瀹屾暣绮樿创鍒拌繖閲屻��</div>'
+ + ' <textarea class="system-dialog-textarea" id="licenseInputValue"></textarea>'
+ + ' <div class="system-dialog-footer">'
+ + ' <button type="button" class="system-tool-btn" id="licenseInputCancel">鍙栨秷</button>'
+ + ' <button type="button" class="system-tool-btn primary" id="licenseInputSubmit">鎻愪氦</button>'
+ + ' </div>'
+ + ' </div>'
+ + '</div>',
+ success: function (layero, index) {
+ licenseToolState.uploadLayerIndex = index;
+ layero.find("#licenseInputClose, #licenseInputCancel").on("click", function () {
+ layer.close(index);
+ });
+ layero.find("#licenseInputSubmit").on("click", function () {
+ submitLicense(layero.find("#licenseInputValue").val());
+ });
+ },
+ end: function () {
+ licenseToolState.uploadLayerIndex = null;
+ }
+ });
+ }
+
+ function requestCode() {
+ fetchRequestCode(function (value, errorMsg) {
+ if (value) {
+ openTextDialog("鑾峰彇璇锋眰鐮�", "璇锋眰鐮�", value, "璇锋眰鐮佷腑宸插寘鍚」鐩悕绉帮紝鐩存帴鍙戠粰璁稿彲璇佹湇鍔$鍗冲彲銆�");
+ return;
+ }
+ layer.msg(errorMsg || '鑾峰彇璇锋眰鐮佸け璐�', {time: 2000});
+ });
+ }
+
+ function fetchRequestCode(callback) {
+ $.ajax({
+ url: baseUrl + "/license/getRequestCode",
+ method: 'GET',
+ success: function (res) {
+ var value = getResponseValue(res);
+ if (res.code == 200) {
+ callback(value ? String(value) : "", "");
+ return;
+ }
+ callback("", res.msg || '鑾峰彇璇锋眰鐮佸け璐�');
+ },
+ error: function (xhr) {
+ callback("", xhr && xhr.status === 404 ? "鑾峰彇璇锋眰鐮佹帴鍙d笉瀛樺湪" : "鑾峰彇璇锋眰鐮佸け璐�");
+ }
+ })
+ }
+
+ function getProjectName() {
+ $.ajax({
+ url: baseUrl + "/license/getProjectName",
+ method: 'GET',
+ success: function (res) {
+ var value = getResponseValue(res);
+ if (res.code == 200 && value) {
+ layer.alert(escapeHtml(String(value)), {
+ title: '椤圭洰鍚嶇О'
+ });
+ return;
+ }
+ layer.msg(res.msg || '鑾峰彇椤圭洰鍚嶇О澶辫触', {time: 2000});
+ },
+ error: function () {
+ layer.msg('鑾峰彇椤圭洰鍚嶇О澶辫触', {time: 2000});
+ }
+ })
+ }
+
+ function getServerInfo() {
+ $.ajax({
+ url: baseUrl + "/license/getServerInfos",
+ method: 'GET',
+ success: function (res) {
+ openTextDialog("鑾峰彇绯荤粺閰嶇疆", "绯荤粺閰嶇疆淇℃伅", res, "鏂拌鍙瘉妯″紡涓嬪彲鐢ㄤ簬鎺掓煡褰撳墠鑺傜偣纭欢缁戝畾淇℃伅銆�");
+ },
+ error: function () {
+ fallbackServerInfoFromRequestCode();
+ }
+ })
+ }
+
+ function fallbackServerInfoFromRequestCode() {
+ fetchRequestCode(function (requestCode, errorMsg) {
+ if (!requestCode) {
+ layer.msg(errorMsg || '鑾峰彇绯荤粺閰嶇疆淇℃伅澶辫触', {time: 2000});
+ return;
+ }
+ try {
+ var decoded = decodeRequestCodePayload(requestCode);
+ var node = (((decoded || {}).licenseBind || {}).nodes || [])[0] || {};
+ var serverInfo = {
+ subject: decoded.subject || "",
+ nodeId: node.nodeId || "",
+ ipAddress: node.ipAddress || [],
+ macAddress: node.macAddress || [],
+ cpuSerial: node.cpuSerial || "",
+ mainBoardSerial: node.mainBoardSerial || ""
+ };
+ openTextDialog("鑾峰彇绯荤粺閰嶇疆", "绯荤粺閰嶇疆淇℃伅", serverInfo, "褰撳墠鎺ュ彛涓嶅彲鐢紝宸叉寜璇锋眰鐮佽В鏋愬嚭鏈満鑺傜偣閰嶇疆銆�");
+ } catch (e) {
+ layer.msg('鑾峰彇绯荤粺閰嶇疆淇℃伅澶辫触', {time: 2000});
+ }
+ });
+ }
+
+ function decodeRequestCodePayload(requestCode) {
+ var normalized = String(requestCode || "").replace(/\s+/g, "");
+ if (!normalized) {
+ return {};
+ }
+ var binary = window.atob(normalized);
+ var bytes = [];
+ for (var i = 0; i < binary.length; i++) {
+ bytes.push("%" + ("00" + binary.charCodeAt(i).toString(16)).slice(-2));
+ }
+ return JSON.parse(decodeURIComponent(bytes.join("")));
+ }
+
+ function activateLicense() {
+ layer.confirm('纭畾鎵ц涓�閿縺娲诲悧锛�', {
+ title: '鎻愮ず'
+ }, function (index) {
+ layer.close(index);
+ $.ajax({
+ url: baseUrl + "/license/activate",
+ method: 'POST',
+ success: function (res) {
+ if (res.code == 200) {
+ layer.msg('婵�娲绘垚鍔�', {time: 1500});
+ return;
+ }
+ layer.msg(res.msg || '婵�娲诲け璐�', {time: 2000});
+ },
+ error: function () {
+ layer.msg('婵�娲诲け璐�', {time: 2000});
+ }
+ })
+ });
+ }
+
+ function submitLicense(licenseBase64) {
+ if (!licenseBase64 || !licenseBase64.trim()) {
+ layer.msg('璁稿彲璇佸唴瀹逛笉鑳戒负绌�', {time: 1500});
+ return;
+ }
+ $.ajax({
+ url: baseUrl + "/license/updateLicense",
+ headers: {'Content-Type': 'application/json'},
+ data: JSON.stringify({license: licenseBase64.trim()}),
+ method: 'POST',
+ success: function (res) {
+ if (res.code == 200) {
+ sessionStorage.removeItem("licensePanelAutoOpen");
+ sessionStorage.removeItem("licenseInvalidReason");
+ if (licenseToolState.uploadLayerIndex !== null) {
+ layer.close(licenseToolState.uploadLayerIndex);
+ }
+ layer.msg('璁稿彲璇佹洿鏂版垚鍔�', {time: 1000}, function () {
+ parent.location.reload();
+ });
+ return;
+ }
+ layer.msg(res.msg || '璁稿彲璇佹洿鏂板け璐�', {time: 2000});
+ },
+ error: function (xhr) {
+ if (xhr && xhr.status === 403) {
+ layer.msg('璁稿彲璇佸綍鍏ユ帴鍙h鎷︽埅锛岃閲嶅惎鏈嶅姟鍚庨噸璇�', {time: 2500});
+ return;
+ }
+ layer.msg('璁稿彲璇佸綍鍏ュけ璐�', {time: 2000});
+ }
+ });
+ }
+
+ function copyRequestCodeText(text) {
+ if (!text) {
+ layer.msg('璇锋眰鐮佷负绌�', {time: 1500});
+ return;
+ }
+ if (navigator.clipboard && window.isSecureContext) {
+ navigator.clipboard.writeText(text).then(function () {
+ layer.msg('璇锋眰鐮佸凡澶嶅埗', {time: 1200});
+ }, function () {
+ fallbackCopy(text);
+ });
+ return;
+ }
+ fallbackCopy(text);
+ }
+
+ function fallbackCopy(text) {
+ var copyInput = $("<textarea>").val(text).css({
+ position: "fixed",
+ top: "-1000px"
+ }).appendTo("body");
+ copyInput[0].select();
+ try {
+ document.execCommand("copy");
+ layer.msg('璇锋眰鐮佸凡澶嶅埗', {time: 1200});
+ } catch (e) {
+ layer.msg('澶嶅埗澶辫触锛岃鎵嬪姩澶嶅埗', {time: 1500});
+ }
+ copyInput.remove();
}
$(document).on('click', '.login-btn', function () {
@@ -151,7 +728,8 @@
layer.tips(res.msg, '#password', {tips: [4, '#ff0000']});
} else if (res.code == 20001) {
layer.tips(res.msg, '.login-btn', {tips: [3, '#ff0000']});
- $("#updateLicense").show()
+ showLicenseEntry(res.msg)
+ openLicenseTool(res.msg)
} else {
layer.tips(res.msg, '.login-btn', {tips: [3, '#ff0000']});
}
@@ -165,37 +743,8 @@
}
});
-
- //鏇存柊璁稿彲璇�
- $("#submitLicense").on("click", () => {
- $("#license").click()
- })
-
- //涓婁紶骞舵洿鏂拌鍙瘉
- $("#license").on("change", (evt) => {
- var files = evt.target.files;
- let formData = new FormData();
- formData.append("file", files[0])
- $.ajax({
- url: baseUrl + "/license/updateLicense",
- headers: {'token': localStorage.getItem('token')},
- data: formData,
- method: 'POST',
- cache: false,
- processData: false,
- contentType: false,
- success: function (res) {
- if (res.code == 200) {
- layer.msg('鏇存柊鎴愬姛', {time: 1000}, () => {
- parent.location.reload()
- });
- } else {
- layer.msg(res.msg, {time: 2000}, () => {
- parent.location.reload()
- })
- }
- }
- })
+ $("#openLicenseTool").on("click", () => {
+ openLicenseTool($("#licenseEntryMessage").text());
})
</script>
</body>
--
Gitblit v1.9.1