fix swagger
This commit is contained in:
@@ -1,227 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<title>WebSocket 广播测试</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
|
||||
<link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">
|
||||
<script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
|
||||
<style>
|
||||
body {
|
||||
padding: 20px;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.container {
|
||||
background-color: white;
|
||||
padding: 30px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||
}
|
||||
h2 {
|
||||
color: #333;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
#divShow {
|
||||
max-height: 500px;
|
||||
overflow-y: auto;
|
||||
margin-bottom: 20px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
padding: 10px;
|
||||
background-color: #fafafa;
|
||||
}
|
||||
.client-info {
|
||||
background-color: #e8f4f8;
|
||||
padding: 8px;
|
||||
margin-bottom: 10px;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
}
|
||||
.message-item {
|
||||
margin-bottom: 8px;
|
||||
padding: 8px;
|
||||
border-radius: 4px;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
.timestamp {
|
||||
font-size: 11px;
|
||||
color: #999;
|
||||
margin-right: 10px;
|
||||
}
|
||||
.user-input {
|
||||
margin-top: 15px;
|
||||
}
|
||||
.status-badge {
|
||||
display: inline-block;
|
||||
padding: 4px 8px;
|
||||
border-radius: 3px;
|
||||
font-size: 12px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
.status-connected {
|
||||
background-color: #5cb85c;
|
||||
color: white;
|
||||
}
|
||||
.status-disconnected {
|
||||
background-color: #d9534f;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h2>
|
||||
WebSocket 广播测试
|
||||
<span id="statusBadge" class="status-badge status-disconnected">未连接</span>
|
||||
</h2>
|
||||
<div class="client-info" id="clientInfo">
|
||||
客户端ID: <span id="clientId"></span> | 连接状态: <span id="connectionStatus">等待连接...</span>
|
||||
</div>
|
||||
<div class="list-group" id="divShow"></div>
|
||||
<div class="user-input">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" id="txtContent" autofocus placeholder="输入要广播的消息...">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-primary" id="btnSend">发送广播</button>
|
||||
</span>
|
||||
</div>
|
||||
<small class="text-muted" style="display: block; margin-top: 10px;">
|
||||
提示:打开多个浏览器窗口或标签页,在一个窗口中发送消息,所有窗口都会收到广播消息
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<script type="application/javascript">
|
||||
// 生成客户端ID
|
||||
const clientId = 'Client-' + Math.random().toString(36).substr(2, 9);
|
||||
document.getElementById('clientId').textContent = clientId;
|
||||
|
||||
function showInfo(content) {
|
||||
const timestamp = new Date().toLocaleTimeString();
|
||||
const html = '<div class="list-group-item list-group-item-info message-item">' +
|
||||
'<span class="timestamp">[' + timestamp + ']</span>' + content + '</div>';
|
||||
$(html).appendTo("#divShow");
|
||||
$("#divShow").scrollTop($("#divShow")[0].scrollHeight);
|
||||
}
|
||||
|
||||
function showWarning(content) {
|
||||
const timestamp = new Date().toLocaleTimeString();
|
||||
const html = '<div class="list-group-item list-group-item-warning message-item">' +
|
||||
'<span class="timestamp">[' + timestamp + ']</span>' + content + '</div>';
|
||||
$(html).appendTo("#divShow");
|
||||
$("#divShow").scrollTop($("#divShow")[0].scrollHeight);
|
||||
}
|
||||
|
||||
function showSuccess(content) {
|
||||
const timestamp = new Date().toLocaleTimeString();
|
||||
const html = '<div class="list-group-item list-group-item-success message-item">' +
|
||||
'<span class="timestamp">[' + timestamp + ']</span>' + content + '</div>';
|
||||
$(html).appendTo("#divShow");
|
||||
$("#divShow").scrollTop($("#divShow")[0].scrollHeight);
|
||||
}
|
||||
|
||||
function showError(content) {
|
||||
const timestamp = new Date().toLocaleTimeString();
|
||||
const html = '<div class="list-group-item list-group-item-danger message-item">' +
|
||||
'<span class="timestamp">[' + timestamp + ']</span>' + content + '</div>';
|
||||
$(html).appendTo("#divShow");
|
||||
$("#divShow").scrollTop($("#divShow")[0].scrollHeight);
|
||||
}
|
||||
|
||||
function updateStatus(connected) {
|
||||
const badge = $('#statusBadge');
|
||||
const status = $('#connectionStatus');
|
||||
if (connected) {
|
||||
badge.removeClass('status-disconnected').addClass('status-connected').text('已连接');
|
||||
status.text('已连接');
|
||||
} else {
|
||||
badge.removeClass('status-connected').addClass('status-disconnected').text('未连接');
|
||||
status.text('未连接');
|
||||
}
|
||||
}
|
||||
|
||||
$(function () {
|
||||
// 获取当前页面的协议和主机
|
||||
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
const host = window.location.host;
|
||||
const url = protocol + "//" + host + "/ws";
|
||||
let ws = new WebSocket(url);
|
||||
|
||||
try {
|
||||
// WebSocket 连接成功
|
||||
ws.onopen = function () {
|
||||
updateStatus(true);
|
||||
showInfo("✅ WebSocket 服务器 [" + url + "] 连接成功!客户端ID: " + clientId);
|
||||
};
|
||||
|
||||
// WebSocket 连接关闭
|
||||
ws.onclose = function () {
|
||||
updateStatus(false);
|
||||
if (ws) {
|
||||
ws.close();
|
||||
ws = null;
|
||||
}
|
||||
showError("❌ WebSocket 服务器 [" + url + "] 连接已关闭!");
|
||||
};
|
||||
|
||||
// WebSocket 连接错误
|
||||
ws.onerror = function () {
|
||||
updateStatus(false);
|
||||
if (ws) {
|
||||
ws.close();
|
||||
ws = null;
|
||||
}
|
||||
showError("❌ WebSocket 服务器 [" + url + "] 连接错误!");
|
||||
};
|
||||
|
||||
// WebSocket 响应消息(接收广播)
|
||||
ws.onmessage = function (event) {
|
||||
try {
|
||||
// 服务端使用 WriteJSON 发送,所以消息是 JSON 字符串
|
||||
let message = event.data;
|
||||
// 如果是 JSON 字符串,尝试解析
|
||||
if (typeof message === 'string' && message.startsWith('"')) {
|
||||
message = JSON.parse(message);
|
||||
}
|
||||
showWarning("📢 收到广播: " + message);
|
||||
} catch (e) {
|
||||
showWarning("📢 收到广播: " + event.data);
|
||||
}
|
||||
};
|
||||
} catch (e) {
|
||||
alert("连接错误: " + e.message);
|
||||
}
|
||||
|
||||
// 点击发送消息
|
||||
$("#btnSend").on("click", function () {
|
||||
if (ws == null || ws.readyState !== WebSocket.OPEN) {
|
||||
showError("WebSocket 服务器连接失败,请刷新页面!");
|
||||
return;
|
||||
}
|
||||
const content = $.trim($("#txtContent").val());
|
||||
if (content.length <= 0) {
|
||||
alert("请输入要发送的内容!");
|
||||
return;
|
||||
}
|
||||
|
||||
// 发送 JSON 格式的消息(服务端使用 ReadJSON 读取)
|
||||
try {
|
||||
ws.send(JSON.stringify(content));
|
||||
$("#txtContent").val("");
|
||||
showSuccess("📤 发送广播: " + content);
|
||||
} catch (e) {
|
||||
showError("发送失败: " + e.message);
|
||||
}
|
||||
});
|
||||
|
||||
// 回车发送消息
|
||||
$("#txtContent").on("keydown", function (event) {
|
||||
if (event.keyCode === 13) {
|
||||
$("#btnSend").trigger("click");
|
||||
}
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -1,359 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<title>TrangleAgent - 聊天室测试</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
|
||||
<link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">
|
||||
<script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
|
||||
<style>
|
||||
body {
|
||||
padding: 20px;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.container {
|
||||
background-color: white;
|
||||
padding: 30px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
h2 {
|
||||
color: #333;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.chat-container {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.chat-messages {
|
||||
flex: 1;
|
||||
max-height: 500px;
|
||||
overflow-y: auto;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
padding: 15px;
|
||||
background-color: #fafafa;
|
||||
min-height: 400px;
|
||||
}
|
||||
.message-item {
|
||||
margin-bottom: 12px;
|
||||
padding: 10px;
|
||||
border-radius: 4px;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
.message-own {
|
||||
background-color: #d4edda;
|
||||
border-left: 3px solid #28a745;
|
||||
}
|
||||
.message-other {
|
||||
background-color: #fff3cd;
|
||||
border-left: 3px solid #ffc107;
|
||||
}
|
||||
.message-system {
|
||||
background-color: #e2e3e5;
|
||||
border-left: 3px solid #6c757d;
|
||||
font-style: italic;
|
||||
}
|
||||
.timestamp {
|
||||
font-size: 11px;
|
||||
color: #999;
|
||||
margin-right: 10px;
|
||||
}
|
||||
.user-info {
|
||||
font-weight: bold;
|
||||
color: #007bff;
|
||||
margin-right: 8px;
|
||||
}
|
||||
.room-info {
|
||||
background-color: #e8f4f8;
|
||||
padding: 15px;
|
||||
margin-bottom: 20px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.input-group {
|
||||
margin-top: 15px;
|
||||
}
|
||||
.status-badge {
|
||||
display: inline-block;
|
||||
padding: 4px 8px;
|
||||
border-radius: 3px;
|
||||
font-size: 12px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
.status-connected {
|
||||
background-color: #5cb85c;
|
||||
color: white;
|
||||
}
|
||||
.status-disconnected {
|
||||
background-color: #d9534f;
|
||||
color: white;
|
||||
}
|
||||
.sidebar {
|
||||
width: 250px;
|
||||
}
|
||||
.sidebar-card {
|
||||
background-color: #f8f9fa;
|
||||
padding: 15px;
|
||||
border-radius: 4px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h2>
|
||||
TrangleAgent 聊天室测试
|
||||
<span id="statusBadge" class="status-badge status-disconnected">未连接</span>
|
||||
</h2>
|
||||
|
||||
<div class="room-info">
|
||||
<div class="form-group">
|
||||
<label>房间ID:</label>
|
||||
<input type="text" class="form-control" id="roomId" value="room1" placeholder="输入房间ID">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>用户ID:</label>
|
||||
<input type="text" class="form-control" id="userId" value="" placeholder="输入用户ID(留空自动生成)">
|
||||
</div>
|
||||
<button class="btn btn-primary" id="btnConnect">连接聊天室</button>
|
||||
<button class="btn btn-danger" id="btnDisconnect" disabled>断开连接</button>
|
||||
</div>
|
||||
|
||||
<div class="chat-container">
|
||||
<div class="chat-messages" id="chatMessages">
|
||||
<div class="message-item message-system">
|
||||
<span class="timestamp">[系统]</span>
|
||||
等待连接到聊天室...
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sidebar">
|
||||
<div class="sidebar-card">
|
||||
<h4>使用说明</h4>
|
||||
<ul style="font-size: 12px; padding-left: 20px;">
|
||||
<li>输入房间ID和用户ID</li>
|
||||
<li>点击"连接聊天室"</li>
|
||||
<li>打开多个窗口测试</li>
|
||||
<li>在不同窗口发送消息</li>
|
||||
<li>所有窗口都会收到广播</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="sidebar-card">
|
||||
<h4>连接信息</h4>
|
||||
<div id="connectionInfo" style="font-size: 12px;">
|
||||
<div>状态: <span id="connStatus">未连接</span></div>
|
||||
<div>房间: <span id="connRoom">-</span></div>
|
||||
<div>用户: <span id="connUser">-</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" id="txtMessage" placeholder="输入消息..." disabled>
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-primary" id="btnSend" disabled>发送</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<script type="application/javascript">
|
||||
let ws = null;
|
||||
let currentRoomId = '';
|
||||
let currentUserId = '';
|
||||
|
||||
// 生成用户ID
|
||||
function generateUserId() {
|
||||
return 'User-' + Math.random().toString(36).substr(2, 9);
|
||||
}
|
||||
|
||||
// 初始化用户ID
|
||||
$(function() {
|
||||
const userIdInput = $('#userId');
|
||||
if (!userIdInput.val()) {
|
||||
userIdInput.val(generateUserId());
|
||||
}
|
||||
});
|
||||
|
||||
function updateStatus(connected) {
|
||||
const badge = $('#statusBadge');
|
||||
const status = $('#connStatus');
|
||||
if (connected) {
|
||||
badge.removeClass('status-disconnected').addClass('status-connected').text('已连接');
|
||||
status.text('已连接');
|
||||
$('#btnConnect').prop('disabled', true);
|
||||
$('#btnDisconnect').prop('disabled', false);
|
||||
$('#txtMessage').prop('disabled', false);
|
||||
$('#btnSend').prop('disabled', false);
|
||||
} else {
|
||||
badge.removeClass('status-connected').addClass('status-disconnected').text('未连接');
|
||||
status.text('未连接');
|
||||
$('#btnConnect').prop('disabled', false);
|
||||
$('#btnDisconnect').prop('disabled', true);
|
||||
$('#txtMessage').prop('disabled', true);
|
||||
$('#btnSend').prop('disabled', true);
|
||||
}
|
||||
}
|
||||
|
||||
function addMessage(message, type, userId) {
|
||||
const timestamp = new Date().toLocaleTimeString();
|
||||
const messagesDiv = $('#chatMessages');
|
||||
|
||||
let messageClass = 'message-other';
|
||||
let displayUserId = userId || '系统';
|
||||
|
||||
if (type === 'own') {
|
||||
messageClass = 'message-own';
|
||||
} else if (type === 'system') {
|
||||
messageClass = 'message-system';
|
||||
displayUserId = '系统';
|
||||
}
|
||||
|
||||
const html = '<div class="message-item ' + messageClass + '">' +
|
||||
'<span class="timestamp">[' + timestamp + ']</span>' +
|
||||
'<span class="user-info">' + displayUserId + ':</span>' +
|
||||
message +
|
||||
'</div>';
|
||||
|
||||
messagesDiv.append(html);
|
||||
messagesDiv.scrollTop(messagesDiv[0].scrollHeight);
|
||||
}
|
||||
|
||||
function connect() {
|
||||
const roomId = $('#roomId').val().trim();
|
||||
const userId = $('#userId').val().trim() || generateUserId();
|
||||
|
||||
if (!roomId) {
|
||||
alert('请输入房间ID!');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!userId) {
|
||||
$('#userId').val(generateUserId());
|
||||
return;
|
||||
}
|
||||
|
||||
currentRoomId = roomId;
|
||||
currentUserId = userId;
|
||||
|
||||
$('#connRoom').text(roomId);
|
||||
$('#connUser').text(userId);
|
||||
|
||||
// 获取当前页面的协议和主机
|
||||
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
const host = window.location.host;
|
||||
const url = protocol + "//" + host + "/ws/chat?roomId=" + encodeURIComponent(roomId);
|
||||
|
||||
try {
|
||||
ws = new WebSocket(url);
|
||||
|
||||
ws.onopen = function() {
|
||||
updateStatus(true);
|
||||
addMessage('成功连接到聊天室: ' + roomId, 'system');
|
||||
|
||||
// 发送加入消息
|
||||
const joinMsg = {
|
||||
roomId: roomId,
|
||||
userId: userId,
|
||||
message: userId + ' 加入了聊天室',
|
||||
type: 'join'
|
||||
};
|
||||
ws.send(JSON.stringify(joinMsg));
|
||||
};
|
||||
|
||||
ws.onclose = function() {
|
||||
updateStatus(false);
|
||||
addMessage('连接已断开', 'system');
|
||||
ws = null;
|
||||
};
|
||||
|
||||
ws.onerror = function() {
|
||||
updateStatus(false);
|
||||
addMessage('连接错误', 'system');
|
||||
};
|
||||
|
||||
ws.onmessage = function(event) {
|
||||
try {
|
||||
// 解析收到的消息
|
||||
const data = JSON.parse(event.data);
|
||||
if (data.userId === currentUserId) {
|
||||
addMessage(data.message, 'own', data.userId);
|
||||
} else {
|
||||
addMessage(data.message, 'other', data.userId);
|
||||
}
|
||||
} catch (e) {
|
||||
// 如果不是JSON,直接显示
|
||||
addMessage(event.data, 'other');
|
||||
}
|
||||
};
|
||||
} catch (e) {
|
||||
alert('连接错误: ' + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
function disconnect() {
|
||||
if (ws) {
|
||||
// 发送离开消息
|
||||
const leaveMsg = {
|
||||
roomId: currentRoomId,
|
||||
userId: currentUserId,
|
||||
message: currentUserId + ' 离开了聊天室',
|
||||
type: 'leave'
|
||||
};
|
||||
try {
|
||||
ws.send(JSON.stringify(leaveMsg));
|
||||
} catch (e) {
|
||||
console.error('发送离开消息失败:', e);
|
||||
}
|
||||
ws.close();
|
||||
ws = null;
|
||||
}
|
||||
updateStatus(false);
|
||||
addMessage('已断开连接', 'system');
|
||||
}
|
||||
|
||||
function sendMessage() {
|
||||
if (!ws || ws.readyState !== WebSocket.OPEN) {
|
||||
alert('未连接到聊天室!');
|
||||
return;
|
||||
}
|
||||
|
||||
const message = $('#txtMessage').val().trim();
|
||||
if (!message) {
|
||||
alert('请输入消息!');
|
||||
return;
|
||||
}
|
||||
|
||||
const chatMsg = {
|
||||
roomId: currentRoomId,
|
||||
userId: currentUserId,
|
||||
message: message,
|
||||
type: 'message'
|
||||
};
|
||||
|
||||
try {
|
||||
ws.send(JSON.stringify(chatMsg));
|
||||
$('#txtMessage').val('');
|
||||
} catch (e) {
|
||||
alert('发送失败: ' + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
// 绑定事件
|
||||
$(function() {
|
||||
$('#btnConnect').on('click', connect);
|
||||
$('#btnDisconnect').on('click', disconnect);
|
||||
$('#btnSend').on('click', sendMessage);
|
||||
|
||||
$('#txtMessage').on('keydown', function(event) {
|
||||
if (event.keyCode === 13) {
|
||||
sendMessage();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<title>GoFrame WebSocket Echo Server</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
|
||||
<link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">
|
||||
<script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
|
||||
<style>
|
||||
body {
|
||||
padding: 20px;
|
||||
}
|
||||
#divShow {
|
||||
max-height: 400px;
|
||||
overflow-y: auto;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h2>GoFrame WebSocket Echo Server</h2>
|
||||
<div class="list-group" id="divShow"></div>
|
||||
<div>
|
||||
<div><input class="form-control" id="txtContent" autofocus placeholder="输入要发送的内容..."></div>
|
||||
<div><button class="btn btn-primary" id="btnSend" style="margin-top:15px">发送</button></div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<script type="application/javascript">
|
||||
function showInfo(content) {
|
||||
$("<div class=\"list-group-item list-group-item-info\">" + content + "</div>").appendTo("#divShow")
|
||||
$("#divShow").scrollTop($("#divShow")[0].scrollHeight);
|
||||
}
|
||||
function showWaring(content) {
|
||||
$("<div class=\"list-group-item list-group-item-warning\">" + content + "</div>").appendTo("#divShow")
|
||||
$("#divShow").scrollTop($("#divShow")[0].scrollHeight);
|
||||
}
|
||||
function showSuccess(content) {
|
||||
$("<div class=\"list-group-item list-group-item-success\">" + content + "</div>").appendTo("#divShow")
|
||||
$("#divShow").scrollTop($("#divShow")[0].scrollHeight);
|
||||
}
|
||||
function showError(content) {
|
||||
$("<div class=\"list-group-item list-group-item-danger\">" + content + "</div>").appendTo("#divShow")
|
||||
$("#divShow").scrollTop($("#divShow")[0].scrollHeight);
|
||||
}
|
||||
|
||||
$(function () {
|
||||
// 获取当前页面的协议和主机
|
||||
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
const host = window.location.host;
|
||||
const url = protocol + "//" + host + "/ws";
|
||||
let ws = new WebSocket(url);
|
||||
|
||||
try {
|
||||
// WebSocket 连接成功
|
||||
ws.onopen = function () {
|
||||
showInfo("WebSocket 服务器 [" + url + "] 连接成功!");
|
||||
};
|
||||
// WebSocket 连接关闭
|
||||
ws.onclose = function () {
|
||||
if (ws) {
|
||||
ws.close();
|
||||
ws = null;
|
||||
}
|
||||
showError("WebSocket 服务器 [" + url + "] 连接已关闭!");
|
||||
};
|
||||
// WebSocket 连接错误
|
||||
ws.onerror = function () {
|
||||
if (ws) {
|
||||
ws.close();
|
||||
ws = null;
|
||||
}
|
||||
showError("WebSocket 服务器 [" + url + "] 连接错误!");
|
||||
};
|
||||
// WebSocket 响应消息
|
||||
ws.onmessage = function (result) {
|
||||
showWaring(" > " + result.data);
|
||||
};
|
||||
} catch (e) {
|
||||
alert(e.message);
|
||||
}
|
||||
|
||||
// 点击发送消息
|
||||
$("#btnSend").on("click", function () {
|
||||
if (ws == null) {
|
||||
showError("WebSocket 服务器 [" + url + "] 连接失败,请刷新页面!");
|
||||
return;
|
||||
}
|
||||
const content = $.trim($("#txtContent").val()).replace(/[\n]/g, "");
|
||||
if (content.length <= 0) {
|
||||
alert("请输入要发送的内容!");
|
||||
return;
|
||||
}
|
||||
$("#txtContent").val("")
|
||||
showSuccess("发送: " + content);
|
||||
ws.send(content);
|
||||
});
|
||||
|
||||
// 回车发送消息
|
||||
$("#txtContent").on("keydown", function (event) {
|
||||
if (event.keyCode === 13) {
|
||||
$("#btnSend").trigger("click");
|
||||
}
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -1,305 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>三角机构 · 机密通行码</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: #f5f5f7;
|
||||
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",
|
||||
Arial,"PingFang SC","Microsoft YaHei",sans-serif;
|
||||
color: #1f2933;
|
||||
}
|
||||
.wrapper {
|
||||
padding: 32px 12px;
|
||||
}
|
||||
.window {
|
||||
max-width: 560px;
|
||||
margin: 0 auto;
|
||||
background: #ffffff;
|
||||
border-radius: 14px;
|
||||
box-shadow:
|
||||
0 20px 40px rgba(0,0,0,.16),
|
||||
0 0 0 3px #111827;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
.window::before {
|
||||
/* 顶部“打印残影”质感 */
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: -18px;
|
||||
height: 18px;
|
||||
background: repeating-linear-gradient(
|
||||
90deg,
|
||||
rgba(15,23,42,.12) 0,
|
||||
rgba(15,23,42,.12) 24px,
|
||||
transparent 24px,
|
||||
transparent 48px
|
||||
);
|
||||
opacity: .7;
|
||||
}
|
||||
.window-header {
|
||||
background: #f3f4f6;
|
||||
border-bottom: 1px solid #d1d5db;
|
||||
padding: 8px 14px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.title-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 13px;
|
||||
letter-spacing: .12em;
|
||||
text-transform: uppercase;
|
||||
color: #4b5563;
|
||||
}
|
||||
.title-icon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 6px;
|
||||
background: #b91c1c;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.title-icon-inner {
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-left: 5px solid transparent;
|
||||
border-right: 5px solid transparent;
|
||||
border-bottom: 8px solid #f9fafb;
|
||||
}
|
||||
.title-right {
|
||||
font-size: 12px;
|
||||
color: #9ca3af;
|
||||
}
|
||||
.window-body {
|
||||
padding: 24px 24px 20px;
|
||||
}
|
||||
.logo-block {
|
||||
text-align: center;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
.logo-main {
|
||||
font-size: 22px;
|
||||
font-weight: 800;
|
||||
letter-spacing: .18em;
|
||||
color: #111827;
|
||||
}
|
||||
.logo-main span {
|
||||
color: #b91c1c;
|
||||
}
|
||||
.logo-sub {
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
color: #6b7280;
|
||||
}
|
||||
.alert-banner {
|
||||
margin: 4px 0 18px;
|
||||
padding: 10px 14px;
|
||||
border-radius: 10px;
|
||||
background: #fee2e2;
|
||||
border: 1px solid #b91c1c;
|
||||
color: #7f1d1d;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.alert-badge {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 999px;
|
||||
background: #b91c1c;
|
||||
color: #f9fafb;
|
||||
font-size: 14px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.headline {
|
||||
font-size: 18px;
|
||||
font-weight: 800;
|
||||
color: #b91c1c;
|
||||
text-align: center;
|
||||
margin: 4px 0 10px;
|
||||
}
|
||||
.headline-sub {
|
||||
font-size: 13px;
|
||||
color: #4b5563;
|
||||
text-align: center;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
.code-panel {
|
||||
margin: 0 auto 20px;
|
||||
max-width: 340px;
|
||||
background: #111827;
|
||||
border-radius: 16px;
|
||||
padding: 16px 14px 18px;
|
||||
box-shadow:
|
||||
0 0 0 2px #b91c1c,
|
||||
0 14px 26px rgba(0,0,0,.45);
|
||||
text-align: center;
|
||||
color: #e5e7eb;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
.code-panel::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: -30%;
|
||||
background:
|
||||
radial-gradient(circle at 0% 0%, rgba(248,113,113,.35), transparent 60%),
|
||||
radial-gradient(circle at 100% 100%, rgba(239,68,68,.22), transparent 60%);
|
||||
opacity: .9;
|
||||
mix-blend-mode: screen;
|
||||
}
|
||||
.code-label {
|
||||
position: relative;
|
||||
font-size: 11px;
|
||||
letter-spacing: .24em;
|
||||
text-transform: uppercase;
|
||||
color: #9ca3af;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.code-value {
|
||||
position: relative;
|
||||
font-size: 30px;
|
||||
font-weight: 900;
|
||||
letter-spacing: .3em;
|
||||
color: #fef2f2;
|
||||
text-shadow:
|
||||
0 0 10px rgba(248,113,113,.95),
|
||||
0 0 24px rgba(248,113,113,.85);
|
||||
}
|
||||
.code-meta {
|
||||
position: relative;
|
||||
margin-top: 10px;
|
||||
font-size: 11px;
|
||||
color: #e5e7eb;
|
||||
opacity: .9;
|
||||
}
|
||||
.code-meta span {
|
||||
color: #f97373;
|
||||
}
|
||||
.text-block {
|
||||
font-size: 13px;
|
||||
line-height: 1.7;
|
||||
color: #4b5563;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
.text-block strong {
|
||||
color: #b91c1c;
|
||||
}
|
||||
.punish {
|
||||
font-size: 13px;
|
||||
line-height: 1.7;
|
||||
color: #111827;
|
||||
background: #fef2f2;
|
||||
border-radius: 10px;
|
||||
border: 1px dashed #b91c1c;
|
||||
padding: 10px 12px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
.punish span {
|
||||
color: #b91c1c;
|
||||
font-weight: 700;
|
||||
}
|
||||
.footer {
|
||||
margin-top: 4px;
|
||||
font-size: 11px;
|
||||
color: #9ca3af;
|
||||
text-align: right;
|
||||
}
|
||||
.footer span {
|
||||
color: #b91c1c;
|
||||
font-weight: 600;
|
||||
}
|
||||
@media (max-width: 520px) {
|
||||
.window {
|
||||
margin: 0 4px;
|
||||
}
|
||||
.code-value {
|
||||
font-size: 24px;
|
||||
letter-spacing: .22em;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<div class="window">
|
||||
<div class="window-header">
|
||||
<div class="title-left">
|
||||
<div class="title-icon">
|
||||
<div class="title-icon-inner"></div>
|
||||
</div>
|
||||
<span>TRIANGLE AGENCY · INTERNAL</span>
|
||||
</div>
|
||||
<div class="title-right">ACCESS LEVEL: REDACTED</div>
|
||||
</div>
|
||||
|
||||
<div class="window-body">
|
||||
<div class="logo-block">
|
||||
<div class="logo-main">
|
||||
TRI<span>▲</span>NGLE AG<span>▲</span>NCY
|
||||
</div>
|
||||
<div class="logo-sub">三角机构 · 机密通信单</div>
|
||||
</div>
|
||||
|
||||
<div class="alert-banner">
|
||||
<div class="alert-badge">!</div>
|
||||
<div>此邮件包含<span>机密通行密码</span>,仅限机构内部人员查阅。</div>
|
||||
</div>
|
||||
|
||||
<div class="headline">内部通行码 · 请勿外传</div>
|
||||
<div class="headline-sub">
|
||||
下方代码用于解锁指定散逸端终端。请在系统提示时准确输入。
|
||||
</div>
|
||||
|
||||
<div class="code-panel">
|
||||
<div class="code-label">CONTAINMENT ACCESS CODE</div>
|
||||
<div class="code-value">{{.Code}}</div>
|
||||
<div class="code-meta">
|
||||
有效期:<span>5 分钟</span> · 失效后请向直属经理申请新码。
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-block">
|
||||
使用前,请再次确认:
|
||||
<br>· 您正在使用的是<span>机构提供的终端或安全网络环境</span>;
|
||||
<br>· 周围无未授权人员,屏幕不可被旁人窥视;
|
||||
<br>· 本通行码只用于当前任务,不得截图、转发或长期存储。
|
||||
</div>
|
||||
|
||||
<div class="punish">
|
||||
如将本通行码<span>泄露给三角机构外部人员</span>,
|
||||
或被系统判定存在高风险共享行为,
|
||||
您将被立即要求前往<span>经理办公室</span>领取
|
||||
<span>1 次申戒</span>,并记录在个人档案中。
|
||||
</div>
|
||||
|
||||
<div class="text-block">
|
||||
若您认为本邮件系误发或内容与任务不符,请立即与上级经理或风控部门联系,
|
||||
并在完成报告前<span>不要尝试使用该通行码</span>。
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
发件单位:<span>三角机构 · 机密通讯科</span><br>
|
||||
此邮件由系统自动发送,请勿直接回复。
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user