SegmentFault (www.sf.gg)开发者社区,是中国年轻开发者喜爱的极客社区,我们为开发者提供最纯粹的技术交流和分享平台。 |
|
码农翻身 · 漫画 | 为什么大家都愿意进入外企? · 2 天前 |
|
程序员小灰 · 清华大学《DeepSeek学习手册》(全5册) · 3 天前 |
|
OSC开源社区 · AI大模型如何影响基础软件行业中的开发工具与环境? · 6 天前 |
|
OSC开源社区 · 2024: 大模型背景下知识图谱的理性回归 · 5 天前 |
|
程序猿 · “未来 3 年内,Python 在 AI ... · 5 天前 |
什么是
Websocket
呢?
我们都知道在
Http
协议中,客户端与服务器端的通信是靠客户端发起请求,然后服务器端收到请求再进行回应,这个过程中,客户端是主动的,服务器端是被动的。
Websocket
协议就不一样了,它是基于
TCP
的一种新的网络协议,它与
Http
协议不同之处就在于
Websocket
能实现服务器端主动推送消息到客户端,服务器端与客户端都能发起通信,这一次,服务器端终于也拥有了主动权。
什么是
socket.io
?
socket.io
封装了
Websocket
以及其他的一些协议,并且实现了
Websocket
的服务端代码。同时还有很强的兼容性,兼容各种浏览器以及移动设备。有了它,我们能更方便快捷地实现服务器端与客户端之间的实时通讯。
要实现多人聊天室的核心就是区分当前用户发送的消息与其他用户发送的消息,在这里我通过用户登录使用的用户名来进行区分。所以用户进入首先展示登录页面。
登录成功之后,新用户加入聊天室
如果用户重名,会弹出提示,保持吴彦祖的登录状态,我们再打开一个标签,输入“吴彦祖”查看效果
只有当昵称唯一时,才允许登录,我们再登录一个查看效果
可以看到,当新用户登录时,其他在线用户会收到提示,接下来就是发送消息了
发送的消息是实时推送的,当前用户发送的消息与其他用户发送的消息对话框做了区分。
当用户退出时,系统也会给出提示,效果如下
怎么样,有没有兴趣继续了解呢?下面就开始着手开发吧。
后端服务是用的
node.js
,所以我们首先要进行安装,安装方法很简单,我在之前一篇文章也提过。首先在node.js官网下载稳定版本,下载完成后点击安装,安装过程也很简单,一直next即可,安装完成会自动添加
node
及
npm
环境变量。
检验是否安装成功,在cmd输入命令
node-v
,回车 及
npm-v
,回车,如出现下图所示版本信息,表示安装成功
新建文件夹
chatroom
,在这里我把它建到D盘根目录下。打开cmd,定位到刚建的
chatroom
文件夹下,输入
npm install socket.io
安装
socket.io
安装完成之后,可以看到文件夹下多了
node_modules
文件,里面全是刚下载的
socket.io
依赖包。
在
chatroom
文件夹下新建页面文件
index.html
,样式
chat.css
,后端js
app.js
,前端js
chat.js
,并下载jquery.min.js,socket.io.js。再下载一张图片作为用户头像,放在
images/user/
下。
目录结构如下
好了,环境搭建完成,开始撸码吧。
在app.js里面构建服务器
/*app.js*/
/*构建http服务*/
var app = require('http').createServer()
/*引入socket.io*/
var io = require('socket.io')(app);
/*定义监听端口,可以自定义,端口不要被占用*/
var PORT = 8081;
/*监听端口*/
app.listen(PORT);
console.log('app listen at'+PORT);
接着启动服务。 打开
cmd
,定位到
app.js
所在目录,输入
node app.js
,如图所示,打印出了我们写的内容,表示服务启动成功。
2.建立服务端socket连接监听
先给大家简单讲一下服务器端与客户端通信的基本方法。大家可以看一下socket.io的文档。
(1)socket.emit
客户端与服务器端之间发送消息是用
emit
例如客户端向服务端发送登录请求
socket.emit('login',{username:uname})
login
是自定义的事件,后面是带的参数
(2)socket.on
服务器端要接收客户端发送的
login
事件,就得对该事件进行监听
socket.on('login',function(data){})
在回调函数中进行处理。
同理,服务器端也可以向客户端发送事件,只要客户端也对该事件进行监听就行
(3)io.sockets.emit
服务器端向连接的所有客户端发送消息得用
io.sockets.emit
(4)socket.broadcast.emit
给除了自己以外的客户端广播消息。
/*app.js*/
/*构建http服务*/
var app = require('http').createServer()
/*引入socket.io*/
var io = require('socket.io')(app);
/*定义监听端口,可以自定义,端口不要被占用*/
var PORT = 8081;
/*监听端口*/
app.listen(PORT);
/**
*监听客户端连接
*io是我们定义的服务端的socket
*回调函数里面的socket是本次连接的客户端socket
*io与socket是一对多的关系
*/
io.on('connection', function (socket) {
/*所有的监听on,与发送emit都得写在连接里面,包括断开连接*/
})
console.log('app listen at'+PORT);
3.前端页面
index.html
页面中需引入
socket.io.js
,socket.io.js下载地址
/*index.html*/
"en" >
"UTF-8">
"viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">聊天室</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> <link type="</span"/><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"text/css"</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> rel=</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"stylesheet"</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> href=</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"css/chat.css"</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">></span></span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> <script type="</span"><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"text/javascript"</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> src=</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"js/jquery.min.js"</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">></script></span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> <script type="</span"><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"text/javascript"</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> src=</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"js/socket.io.js"</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">></script></span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> <script type="</span"><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"text/javascript"</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> src=</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"js/chat.js"</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">></script></span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"/></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"/></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">/*登录界面*/</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> <div><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">class</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">=</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"login-wrap"</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">></span><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> <div><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">class</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">=</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"login-con"</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">></span><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"><h3/></span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">用户登录</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> <input type="</span"/><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"text"</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> placeholder=</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"请输入昵称"</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> id=</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"loginName"</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">></span></span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> <button><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">class</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">=</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"login-btn"</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">>登录</span></button></span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span></code></span></p></li></div></span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span></code></span></p></li></div></span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"/></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">/*聊天界面,一开始隐藏,用户登录成功后再显示*/</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> <div><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">class</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">=</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"chat-wrap hide"</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">></span><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"><h1/></span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">多人聊天室</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> <div><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">class</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">=</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"chat-con clearfix"</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">></span></div></span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> <div><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">class</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">=</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"bottom"</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">></span><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> <input type="</span"/><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"text"</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> id=</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"sendtxt"</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">></span></span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> <button><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">class</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">=</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"sendBtn"</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">>发送</span></button></span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span></code></span></p></li></div></span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span></code></span></p></li></div></span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"/></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"/></code></span></p></li></ol></pre><h3 style="box-sizing: border-box;margin-top: 1.5rem;margin-bottom: 1rem;color: rgb(21, 153, 87);line-height: 1.35;font-size: 20px;white-space: normal;">4.样式</h3><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;font-size: 16px;white-space: pre-line;line-height: 30px;color: rgb(74, 74, 74);font-family: Avenir, -apple-system-font, 微软雅黑, sans-serif;">样式可以自己编写,我这里随便写了一下</p><pre class="prettyprint linenums prettyprinted" style="box-sizing: border-box;margin-top: 0px;margin-bottom: 0px;padding: 8px 0px 6px;background-color: rgb(47, 54, 64);border-radius: 0px;overflow-y: auto;color: rgb(80, 97, 109);font-size: 10px;line-height: 12px;"><ol class="linenums list-paddingleft-2" style="list-style-type: none;"><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">/*公共样式*/</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">*{padding:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">0</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; margin:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">0</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">;}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">html,body{width:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">100</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">%;height: </span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">100</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">%;}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.clearfix:after{content:</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"."</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">;display:block;height:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">0</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">;clear:both;visibility:hidden}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.clearfix{*zoom:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">1</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.cred{color:#f03e3e;}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.cgreen{color:#</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">459d36</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">;}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.hide{display:none;}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.fr{</span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">float</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">:right;}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.fl{</span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">float</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">: left;}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.rela{position: relative;}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.abs{position:absolute;}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">h1{position: </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">fixed</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; z-index:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">20</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; width: </span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">100</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">%; height:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">50px</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; line-height:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">50px</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; font-size:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">20px</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; left: </span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">0</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; top: </span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">0</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; background: </span><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">#000; color: #fff;}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"/></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">/*登录界面*/</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.login-wrap{background:#e7e7e7;width:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">100</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">%;height:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">100</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">%; text-align:center;}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.login-con{padding-top: </span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">50px</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">;}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.login-con h3{margin-bottom: </span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">20px</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">;}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.login-con input{width:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">60</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">%; display:block; margin:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">0</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">auto</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; height: </span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">40px</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; line-height: </span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">40px</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; margin-bottom: </span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">20px</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">;}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.login-con button{width:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">60</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">%;display:block; margin:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">0</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">auto</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; height: </span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">40px</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; line-height:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">40px</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; border:none; background:#</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">459d36</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; color:#fff; border-radius:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">5px</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">;}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"/></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">/*聊天界面*/</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.chat-wrap{width: </span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">100</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">%; height: </span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">100</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">%;overflow-y:scroll; background:#e7e7e7; text-align:center;}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.chat-con{padding: </span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">50px</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">0</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; background:#e7e7e7;}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.chat-con p{display:</span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">inline</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">-block; padding:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">5px</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">10px</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; background:#</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">999</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">;border-radius:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">5px</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; color:#fff; margin:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">5px</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">0</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">;}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.bottom{position:</span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">fixed</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">;bottom:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">0</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; left: </span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">0</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; width:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">100</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">%; height: </span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">50px</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; background: </span><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">#fff;}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.bottom input{width: </span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">78</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">%; height: </span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">50px</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; line-height: </span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">50px</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">float</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">:left;border:none;}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.bottom button{width: </span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">20</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">%;height: </span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">50px</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">float</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">: right; border:none; background:#</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">459d36</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">;color: </span><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">#fff;}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.chat-item{width:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">100</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">%; margin-bottom:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">20px</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">;}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.item-right .message{background: </span><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">#62b900;}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.item-left .message{background: </span><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">#fff; margin-top:20px;}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.item-left .img{margin-right:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">10px</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">;}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.item-left .uname{font-size:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">12px</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; left:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">50px</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; top:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">0</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">;}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.chat-item .message{width:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">60</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">%;display:block; padding:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">10px</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">;border-radius:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">5px</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; margin-right:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">10px</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">;}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.chat-item .img{display:</span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">inline</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">-block; width:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">40px</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; height:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">40px</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; background:url(../images/user/user.jpg) </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">no</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">-repeat; background-size:</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">100</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">% </span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">100</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">%;}</span></code></span></p></li></ol></pre><h3 style="box-sizing: border-box;margin-top: 1.5rem;margin-bottom: 1rem;color: rgb(21, 153, 87);line-height: 1.35;font-size: 20px;white-space: normal;">5.逻辑编写</h3><h5 style="box-sizing: border-box;margin-top: 1.5rem;margin-bottom: 1rem;color: rgb(21, 153, 87);line-height: 1.35;white-space: normal;">(1)登录</h5><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;font-size: 16px;white-space: pre-line;line-height: 30px;color: rgb(74, 74, 74);font-family: Avenir, -apple-system-font, 微软雅黑, sans-serif;"><strong style="box-sizing: border-box;color: rgb(0, 0, 0);">客户端</strong></p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;font-size: 16px;white-space: pre-line;line-height: 30px;color: rgb(74, 74, 74);font-family: Avenir, -apple-system-font, 微软雅黑, sans-serif;">浏览器端将获得的用户输入的昵称信息,发送到服务器端,告诉服务器端我要触发 <code class="prettyprint code-in-text prettyprinted" style="box-sizing: border-box;background: rgb(243, 241, 241);color: rgb(88, 88, 88);line-height: 18px;"><span class="pln" style="box-sizing: border-box;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;display: inline-block;padding-right: 2px;padding-left: 2px;font-size: 14px;">login</span></code>事件。</p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;font-size: 16px;white-space: pre-line;line-height: 30px;color: rgb(74, 74, 74);font-family: Avenir, -apple-system-font, 微软雅黑, sans-serif;">在客户端 <code class="prettyprint code-in-text prettyprinted" style="box-sizing: border-box;background: rgb(243, 241, 241);color: rgb(88, 88, 88);line-height: 18px;"><span class="pln" style="box-sizing: border-box;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;display: inline-block;padding-right: 2px;padding-left: 2px;font-size: 14px;">chat.js</span></code>中发送登录事件 </p><pre class="prettyprint linenums prettyprinted" style="box-sizing: border-box;margin-top: 0px;margin-bottom: 0px;padding: 8px 0px 6px;background-color: rgb(47, 54, 64);border-radius: 0px;overflow-y: auto;color: rgb(80, 97, 109);font-size: 10px;line-height: 12px;"><ol class="linenums list-paddingleft-2" style="list-style-type: none;"><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">/*chat.js*/</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">$(</span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">function</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(){</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">/*建立socket连接,使用websocket协议,端口号是服务器端监听端口号*/</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">var</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> socket = io(</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'ws://localhost:8081'</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">/*定义用户名*/</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">var</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> uname = </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">null</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">;</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"/></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">/*登录*/</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> $(</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'.login-btn'</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">).click(</span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">function</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(){</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> uname = $.trim($(</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'#loginName'</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">).val());</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">if</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(uname){</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">/*向服务端发送登录事件*/</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> socket.emit(</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'login'</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">,{username:uname})</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">else</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">{</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> alert(</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'请输入昵称'</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">)</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> })</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"/></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">})</span></code></span></p></li></ol></pre><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;font-size: 16px;white-space: pre-line;line-height: 30px;color: rgb(74, 74, 74);font-family: Avenir, -apple-system-font, 微软雅黑, sans-serif;"><strong style="box-sizing: border-box;color: rgb(0, 0, 0);">服务器端</strong></p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;font-size: 16px;white-space: pre-line;line-height: 30px;color: rgb(74, 74, 74);font-family: Avenir, -apple-system-font, 微软雅黑, sans-serif;">服务器端监听 <code class="prettyprint code-in-text prettyprinted" style="box-sizing: border-box;background: rgb(243, 241, 241);color: rgb(88, 88, 88);line-height: 18px;"><span class="pln" style="box-sizing: border-box;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;display: inline-block;padding-right: 2px;padding-left: 2px;font-size: 14px;">login</span></code>事件,在后台打印出获取到的昵称信息。在服务器端 <code class="prettyprint code-in-text prettyprinted" style="box-sizing: border-box;background: rgb(243, 241, 241);color: rgb(88, 88, 88);line-height: 18px;"><span class="pln" style="box-sizing: border-box;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;display: inline-block;padding-right: 2px;padding-left: 2px;font-size: 14px;">app.js</span></code>中监听登录事件</p><pre class="prettyprint linenums prettyprinted" style="box-sizing: border-box;margin-top: 0px;margin-bottom: 0px;padding: 8px 0px 6px;background-color: rgb(47, 54, 64);border-radius: 0px;overflow-y: auto;color: rgb(80, 97, 109);font-size: 10px;line-height: 12px;"><ol class="linenums list-paddingleft-2" style="list-style-type: none;"><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">/*app.js*/</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">var</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> app = </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">require</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'http'</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">).createServer()</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">var</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> io = </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">require</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'socket.io'</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">)(app);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">var</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> PORT = </span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">8081</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">;</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"/></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">app.listen(PORT);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">io.on(</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'connection'</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">, </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">function</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> (socket) {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">/*监听登录*/</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> socket.on(</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'login'</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">,</span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">function</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(data){</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> console.log(data)</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> })</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">})</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"/></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">console.log(</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'app listen at'</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">+PORT);</span></code></span></p></li></ol></pre><blockquote style="box-sizing: border-box;margin-top: 1em;margin-bottom: 1.2em;padding: 15px 15px 15px 1rem;color: rgb(129, 145, 152);border-left-width: 6px;border-left-color: rgb(220, 230, 240);font-size: 14px;line-height: 22px;background: rgb(242, 247, 251);font-family: Avenir, -apple-system-font, 微软雅黑, sans-serif;white-space: normal;"><p style="box-sizing: border-box;white-space: pre-line;line-height: 30px;color: rgb(74, 74, 74);">注:更改了app.js,需再次启动服务才能看见效果</p></blockquote><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;font-size: 16px;white-space: pre-line;line-height: 30px;color: rgb(74, 74, 74);font-family: Avenir, -apple-system-font, 微软雅黑, sans-serif;">打开cmd,按 <code class="prettyprint code-in-text prettyprinted" style="box-sizing: border-box;background: rgb(243, 241, 241);color: rgb(88, 88, 88);line-height: 18px;"><span class="typ" style="box-sizing: border-box;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;display: inline-block;padding-right: 2px;padding-left: 2px;font-size: 14px;">Ctrl</span></code>+ <code class="prettyprint code-in-text prettyprinted" style="box-sizing: border-box;background: rgb(243, 241, 241);color: rgb(88, 88, 88);line-height: 18px;"><span class="pln" style="box-sizing: border-box;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;display: inline-block;padding-right: 2px;padding-left: 2px;font-size: 14px;">C</span></code>退出上次服务,再次输入 <code class="prettyprint code-in-text prettyprinted" style="box-sizing: border-box;background: rgb(243, 241, 241);color: rgb(88, 88, 88);line-height: 18px;"><span class="pln" style="box-sizing: border-box;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;display: inline-block;padding-right: 2px;padding-left: 2px;font-size: 14px;">node app.js</span></code>启动服务,打开浏览器,查看效果</p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;font-size: 16px;white-space: pre-line;line-height: 30px;color: rgb(74, 74, 74);font-family: Avenir, -apple-system-font, 微软雅黑, sans-serif;"><img referrerpolicy="no-referrer" data- referrerpolicy="no-referrer" src="http://mmbiz.qpic.cn/mmbiz_gif/aVp1YC8UV0fFCxH0ajUPia5RpyxOTQZrHje1uL6FXeJKibPh64bgwdPHNUjbbcHFiaXnS8EibhPXXnOb9icqs0ZAEbQ/0?wx_fmt=gif" style="box-sizing: border-box;border-width: 2px;border-style: solid;border-color: rgb(238, 238, 238);border-radius: 6px;" class="" data-ratio="0.4367945823927765" data-w="886" data-type="gif"/>可以看到,点击登录按钮时,服务器端打印出了接收到的用户名信息,没问题,继续往下写登录成功事件。</p><h5 style="box-sizing: border-box;margin-top: 1.5rem;margin-bottom: 1rem;color: rgb(21, 153, 87);line-height: 1.35;white-space: normal;">(2)登录成功与失败</h5><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;font-size: 16px;white-space: pre-line;line-height: 30px;color: rgb(74, 74, 74);font-family: Avenir, -apple-system-font, 微软雅黑, sans-serif;">由于没有使用到数据库,所以我们就定义一个用户数组,用户每次登录之后,我们就判断该昵称是否已存在,如果已存在就弹出提示,转到登录失败事件,如果该昵称不存在数组里面,就视为新用户,转到登录成功事件,并且将该昵称存入数组。</p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;font-size: 16px;white-space: pre-line;line-height: 30px;color: rgb(74, 74, 74);font-family: Avenir, -apple-system-font, 微软雅黑, sans-serif;"><strong style="box-sizing: border-box;color: rgb(0, 0, 0);">服务器端</strong></p><pre class="prettyprint linenums prettyprinted" style="box-sizing: border-box;margin-top: 0px;margin-bottom: 0px;padding: 8px 0px 6px;background-color: rgb(47, 54, 64);border-radius: 0px;overflow-y: auto;color: rgb(80, 97, 109);font-size: 10px;line-height: 12px;"><ol class="linenums list-paddingleft-2" style="list-style-type: none;"><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">/*app.js*/</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">var</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> app = </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">require</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'http'</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">).createServer()</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">var</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> io = </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">require</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'socket.io'</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">)(app);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">var</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> PORT = </span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">8081</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">;</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">/*定义用户数组*/</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">var</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> users = [];</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"/></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">app.listen(PORT);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">io.on(</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'connection'</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">, </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">function</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> (socket) {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">/*是否是新用户标识*/</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">var</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> isNewPerson = </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">true</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; </span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">/*当前登录用户*/</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">var</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> username = </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">null</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">;</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">/*监听登录*/</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> socket.on(</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'login'</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">,</span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">function</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(data){</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">for</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(</span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">var</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> i=</span><span class="lit" style="box-sizing: border-box;color: rgb(172, 146, 236);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">0</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">;i<users.length/></span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">if</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(users[i].username === data.username){</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> isNewPerson = </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">false</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">break</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">;</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">else</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">{</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> isNewPerson = </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">true</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">if</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(isNewPerson){</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> username = data.username</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> users.push({</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> username:data.username</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> })</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">/*登录成功*/</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> socket.emit(</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'loginSuccess'</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">,data)</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">/*向所有连接的客户端广播add事件*/</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> io.sockets.emit(</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'add'</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">,data)</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">else</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">{</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">/*登录失败*/</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> socket.emit(</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'loginFail'</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">,</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">''</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">)</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> } </span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> })</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">})</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"/></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">console.log(</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'app listen at'</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">+PORT);</span></code></span></p></li></ol></pre><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;font-size: 16px;white-space: pre-line;line-height: 30px;color: rgb(74, 74, 74);font-family: Avenir, -apple-system-font, 微软雅黑, sans-serif;"><strong style="box-sizing: border-box;color: rgb(0, 0, 0);">客户端</strong></p><pre class="prettyprint linenums prettyprinted" style="box-sizing: border-box;margin-top: 0px;margin-bottom: 0px;padding: 8px 0px 6px;background-color: rgb(47, 54, 64);border-radius: 0px;overflow-y: auto;color: rgb(80, 97, 109);font-size: 10px;line-height: 12px;"><ol class="linenums list-paddingleft-2" style="list-style-type: none;"><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">/*chat.js*/</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">$(</span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">function</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(){</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">/*建立socket连接,使用websocket协议,端口号是服务器端监听端口号*/</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">var</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> socket = io(</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'ws://localhost:8081'</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">/*定义用户名*/</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">var</span><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> uname = </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">null</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">;</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"/></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">/*登录*/</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> $(</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'.login-btn'</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">).click(</span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">function</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(){</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> uname = $.trim($(</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'#loginName'</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">).val());</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">if</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(uname){</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">/*向服务端发送登录事件*/</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> socket.emit(</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'login'</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">,{username:uname})</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">else</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">{</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> alert(</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'请输入昵称'</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">)</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> })</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"/></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">/*登录成功*/</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> socket.on(</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'loginSuccess'</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">,</span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">function</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(data){</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">if</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(data.username === uname){</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> checkin(data)</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">else</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">{</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> alert(</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'用户名不匹配,请重试'</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">)</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> })</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"/></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="com" style="box-sizing: border-box;color: rgb(101, 109, 120);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">/*登录失败*/</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;line-height: 22px;font-size: 14px !important;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;word-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> socket.on(</span><span class="str" style="box-sizing: border-box;color: rgb(255, 206, 84);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'loginFail'</span><span class="pun" style="box-sizing: border-box;color: rgb(230, 233, 237);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">,</span><span class="kwd" style="box-sizing: border-box;color: rgb(79, 193, 233);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">function
|
码农翻身 · 漫画 | 为什么大家都愿意进入外企? 2 天前 |
|
程序员小灰 · 清华大学《DeepSeek学习手册》(全5册) 3 天前 |
|
OSC开源社区 · AI大模型如何影响基础软件行业中的开发工具与环境? 6 天前 |
|
OSC开源社区 · 2024: 大模型背景下知识图谱的理性回归 5 天前 |
|
程序猿 · “未来 3 年内,Python 在 AI 统治地位将被 Java 取代!” 5 天前 |
|
微路况 · 被这些明星代言的车型都挂了 8 年前 |
|
冯仑风马牛 · 最穷的时候才能憋出富来|看世界 8 年前 |
|
政事儿 · 令计划、黄兴国们的“内线” 8 年前 |
|
创业邦 · 注意!这里有投资人出没 8 年前 |
|
杂学杂问 · 花400万留学8年,海归后月薪万元却感“挫败不已”!出国留学值不值? 7 年前 |