You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
3.1 KiB
83 lines
3.1 KiB
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>P2P 聊天程序</title>
|
|
<link rel="stylesheet" href="style.css">
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<!-- 连接面板 -->
|
|
<div id="connectPanel" class="panel">
|
|
<div class="logo">
|
|
<h1>💬 P2P 聊天程序</h1>
|
|
<p>基于 TCP/WebSocket 的点对点聊天</p>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="username">用户名</label>
|
|
<input type="text" id="username" placeholder="请输入您的用户名" autofocus>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="serverHost">服务器地址</label>
|
|
<input type="text" id="serverHost" value="120.46.87.202" placeholder="服务器 IP 地址">
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="serverPort">WebSocket 端口</label>
|
|
<input type="number" id="serverPort" value="8888" placeholder="8888">
|
|
</div>
|
|
|
|
<button id="connectBtn" class="btn btn-primary">连接</button>
|
|
|
|
<div class="info-box">
|
|
<h3>使用说明</h3>
|
|
<ul>
|
|
<li>输入用户名和服务器信息</li>
|
|
<li>点击"连接"按钮加入聊天室</li>
|
|
<li>支持多人同时在线聊天</li>
|
|
<li>基于 TCP 协议保证消息可靠传输</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 聊天面板 -->
|
|
<div id="chatPanel" class="panel" style="display: none;">
|
|
<div class="chat-header">
|
|
<div class="header-left">
|
|
<h2>💬 P2P 聊天室</h2>
|
|
<span id="userInfo" class="user-info"></span>
|
|
</div>
|
|
<div class="header-right">
|
|
<span id="onlineCount" class="online-count">在线: 0</span>
|
|
<button id="disconnectBtn" class="btn btn-secondary">断开连接</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="chat-body">
|
|
<div class="sidebar">
|
|
<h3>在线用户</h3>
|
|
<div id="peerList" class="peer-list"></div>
|
|
</div>
|
|
|
|
<div class="main-chat">
|
|
<div id="messageArea" class="message-area"></div>
|
|
|
|
<div class="input-area">
|
|
<input type="text" id="messageInput" placeholder="输入消息..." autocomplete="off">
|
|
<button id="sendBtn" class="btn btn-primary">发送</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 状态提示 -->
|
|
<div id="statusBar" class="status-bar"></div>
|
|
</div>
|
|
|
|
<script src="app.js"></script>
|
|
</body>
|
|
</html>
|