Przeglądaj źródła

【修复】需求

PJ-568 2 lat temu
rodzic
commit
6632ad4016
2 zmienionych plików z 72 dodań i 43 usunięć
  1. 7 3
      new_chat.html
  2. 65 40
      需求.md

+ 7 - 3
new_chat.html

@@ -67,6 +67,7 @@
             background-color: #0056b3;
         }
     </style>
+    <meta http-equiv="refresh" content="60">
 </head>
 
 <body>
@@ -76,10 +77,13 @@
                 <legend>聊天室 - {{ roomid }}</legend>
                 <textarea id="chatLog" rows="10" cols="50" readonly></textarea>
                 <br>
-                <input type="text" id="messageInput">
-                <button id="sendButton">发送</button>
-                <button id="exitButton">退出</button>
+                <label for="messageInput">消息:</label>
+                <input type="text" id="messageInput" name="messageInput">
+                <button type="submit">发送</button>
+                <a href="."><button type="button">退出</button></a>
             </fieldset>
+            <input type="text" id="nickname" name="nickname" value="{{ nickname }}" style="display: none;">
+            <input type="text" id="roomid" name="roomid" value="{{ roomid }}" style="display: none;">
         </form>
     </div>
 </body>

+ 65 - 40
需求.md

@@ -1,62 +1,83 @@
-统一 UTF-8 编码。
+统一 UTF-8 编码,中文支持。
 前端使用 HTML(尽量兼容老旧浏览器(NetSurf)且不使用JS)。
 服务端使用 python(尽量不引入第三方库),搭建最小轻量化独立聊天室。慢慢来,实现以下功能:
 
-## 主页
+## 客户端
+
+### 主页
 
 地址:(/)
 
 用户界面:
 
-```html
-<fieldset>
-    <legend>主页</legend>
-    <label for="nickname">昵称:</label>
-    <input type="text" id="nickname" name="nickname" value="匿名">
-    <br>
-    <label for="roomId">房间号:</label>
-    <input type="text" id="roomId" name="roomId">
-    <br>
-    <button type="submit">进入聊天室</button>
-</fieldset>
+```html index.html
+<!DOCTYPE html>
+<html lang="zh-Hans">
+
+<head>
+    <meta charset="UTF-8">
+    <title>聊天室</title>
+</head>
+
+<body>
+    <div class="container">
+        <form action="/chat" method="get">
+            <fieldset>
+                <legend>主页</legend>
+                <label for="nickname">昵称</label>
+                <input type="text" id="nickname" name="nickname" value="匿名">
+                <br>
+                <label for="roomid">房间号:</label>
+                <input type="text" id="roomid" name="roomid" value="默认">
+                <br>
+                <button type="submit">进入聊天室</button>
+            </fieldset>
+        </form>
+    </div>
+</body>
+
+</html>
 ```
 
 1. 用户设置昵称,空值默认为“匿名”。
 2. 输入或创建聊天室ID,空值默认为“默认”。
 3. 只能在主页输入设置昵称和号码。
 
-## 聊天室
+### 聊天室
 
-地址:(/chat?nickname=昵称&roomid=聊天室号码&message=发送消息内容)
+地址:(/chat?nickname=昵称&roomid=聊天室号码)
 
 用户界面:
 
-```html index.html
-<form action="/chat" method="get">
-    <fieldset>
-        <legend>主页</legend>
-        <label for="nickname">昵称</label>
-        <input type="text" id="nickname" name="nickname" value="匿名">
-        <br>
-        <label for="roomid">房间号:</label>
-        <input type="text" id="roomid" name="roomid" value="默认">
-        <br>
-        <button type="submit">进入聊天室</button>
-    </fieldset>
-</form>
-```
-
 ```html chat.html
-<form action="/send_message" method="post">
-    <fieldset>
-        <legend>聊天室 - {{ roomid }}</legend>
-        <textarea id="chatLog" rows="10" cols="50" readonly></textarea>
-        <br>
-        <input type="text" id="messageInput">
-        <button id="sendButton">发送</button>
-        <button id="exitButton">退出</button>
-    </fieldset>
-</form>
+<!DOCTYPE html>
+<html lang="zh-Hans">
+
+<head>
+    <meta charset="UTF-8">
+    <title>聊天室 - {{ roomid }}</title>
+    <meta http-equiv="refresh" content="60">
+</head>
+
+<body>
+    <div class="container">
+        <form action="/send_message" method="post">
+            <fieldset>
+                <legend>聊天室 - {{ roomid }}</legend>
+                <textarea id="chatLog" rows="10" cols="50" readonly></textarea>
+                <br>
+                <label for="messageInput">消息:</label>
+                <input type="text" id="messageInput" name="messageInput">
+                <button type="submit">发送</button>
+                <a href="."><button type="button">退出</button></a>
+            </fieldset>
+            <input type="text" id="nickname" name="nickname" value="{{ nickname }}" style="display: none;">
+            <input type="text" id="roomid" name="roomid" value="{{ roomid }}" style="display: none;">
+        </form>
+    </div>
+</body>
+
+</html>
 ```
 
 1. 聊天记录区,发送消息,退出键返回主页。
@@ -66,6 +87,10 @@
 5. 每个聊天室存储最多50条聊天记录,超出则删除最早记录。
 6. 总聊天室数量限制为32个,超出则删除最早的聊天室。
 
+### send_message
+
+302 重定向回聊天室。
+
 ## 服务端
 
 - 服务器动态生成聊天室界面。