开源im聊天源码/Uniapp即时通讯源码社交聊天系统下载+视频搭建教程

  IM即时通讯聊天系统源码,用来在WhatsApp消息中看到的与本地主机服务器多人及时沟通。多个用户可以来这里分享他们的观点,MySQL数据库存储了搜索和检索它的有效性。为了实现这一成功的应用,我们需要构建CSS和JavaScript来塑造UI, HTML部分来渲射它,PHP代码用于存储和检索数据库。
  完整源码:im.jstxym.top
  源码搭建的技术环境:
  HTML、CSS、Javascript (basics)
  PHP(数据库连接)
  SQL queries
  源码系统配置:
  XAMPP服务器:这是一个自由软件,可以访问Apache web服务器,MySQL(或MariaDB)数据库管理系统,它可以从官方网站下载。


  phpmyadmin:这是管理MySQL和MariaDB的自由开源软件。你可以从官方网站下载。拉链文件下载必须在接下来的位置进行。
  C:\xampp\htdocs</strong
  把文件放在任何地方都行不通。只要把内容拉出来就行了。
  文本编辑:任何像Notepad++或普通Notepad这样的文本编辑都足以实现这一点。
  任何JavaScript enabled都将足以运行代码。
  CSS:把这个放在风格标签下,或者放在外部风格文件和链接中。这个CSS文件压缩了聊天室的风格、文本样式和聊天室UI界面。

<style>
  *{
  box-sizing:border-box;
  }
  body{
  background-color:#abd9e9;
  font-family:Arial;
  }
  #container{
  width:500px;
  height:700px;
  background:white;
  margin:0 auto;
  font-size:0;
  border-radius:5px;
  overflow:hidden;
  }
  main{
  width:500px;
  height:700px;
  display:inline-block;
  font-size:15px;
  vertical-align:top;
  }
  main header{
  height:100px;
  padding:30px 20px 30px 40px;
  background-color:#622569;
  }
  main header > *{
  display:inline-block;
  vertical-align:top;
  }
  main header img:first-child{
  width:24px;
  margin-top:8px;
  }
  main header img:last-child{
  width:24px;
  margin-top:8px;
  }
  main header div{
  margin-left:90px;
  margin-right:90px;
  }
  main header h2{
  font-size:25px;
  margin-top:5px;
  text-align:center;
  color:#FFFFFF;
  }
  main .inner_div{
  padding-left:0;
  margin:0;
  list-style-type:none;
  position:relative;
  overflow:auto;
  height:500px;
  background-image:url(
  https://media.geeksforgeeks.org/wp-content/cdn-uploads/20200911064223/bg.jpg);
  background-position:center;
  background-repeat:no-repeat;
  background-size:cover;
  position: relative;
  border-top:2px solid #fff;
  border-bottom:2px solid #fff;
  }
  main .triangle{
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 8px 8px 8px;
  border-color: transparent
  transparent #58b666 transparent;
  margin-left:20px;
  clear:both;
  }
  main .message{
  padding:10px;
  color:#000;
  margin-left:15px;
  background-color:#58b666;
  line-height:20px;
  max-width:90%;
  display:inline-block;
  text-align:left;
  border-radius:5px;
  clear:both;
  }
  main .triangle1{
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 8px 8px 8px;
  border-color: transparent
  transparent #6fbced transparent;
  margin-right:20px;
  float:right;
  clear:both;
  }
  main .message1{
  padding:10px;
  color:#000;
  margin-right:15px;
  background-color:#6fbced;
  line-height:20px;
  max-width:90%;
  display:inline-block;
  text-align:left;
  border-radius:5px;
  float:right;
  clear:both;
  }
  main .triangle2{
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 8px 8px 8px;
  border-color: transparent
  transparent #58b666 transparent;
  margin-left:20px;
  clear:both
  }
  main .message2{
  padding:10px;
  color:#000;
  margin-left:15px;
  background-color:#58b666;
  line-height:20px;
  max-width:90%;
  display:inline-block;
  text-align:left;
  border-radius:5px;
  clear:both
  }
  main footer{
  height:150px;
  padding:20px 30px 10px 20px;
  background-color:#622569;
  }
  main footer .input1{
  resize:none;
  border:100%;
  display:block;
  width:120%;
  height:55px;
  border-radius:3px;
  padding:20px;
  font-size:13px;
  margin-bottom:13px;
  }
  main footer textarea{
  resize:none;
  border:100%;
  display:block;
  width:140%;
  height:55px;
  border-radius:3px;
  padding:20px;
  font-size:13px;
  margin-bottom:13px;
  margin-left:20px;
  }
  main footer .input2{
  resize:none;
  border:100%;
  display:block;
  width:40%;
  height:55px;
  border-radius:3px;
  padding:20px;
  font-size:13px;
  margin-bottom:13px;
  margin-left:100px;
  color:white;
  text-align:center;
  background-color:black;
  border: 2px solid white;
  }
  }
  main footer textarea::placeholder{
  color:#ddd;
  }
  </style>

  数据库创建:打开XAMPP control面板在您的个人电脑,点击开始按钮为两个Apache和MySQL。这一步对于创建数据库和运行应用程序非常重要。打开浏览器。在搜索条上,下面是一行given。
  localhost/phpmyadmin
  它将打开一个选项卡,你可以创建一个数据库。对于这个应用程序,一个名为chat_app的数据库是创建的。一张被称为“uname”、“msg”和“dt”的桌子是虚构的。这里的“uname”是varchar类型和用户名,msg也是varchar类型和发送消息的msg,
  PHP代码存储在MySQL数据库中:每次输入用户对发送按钮的压力,在开始HTML标签之前编写此代码。Attempt MySQL服务器连接。假设您正在运行带有默认设置的MySQL服务器。

  <?php
  if (isset($_POST['submit'])){
  $link = mysqli_connect("localhost",
  "root", "", "chat_app");
  // Check connection
  if($link === false){
  die("ERROR: Could not connect. "
  . mysqli_connect_error());
  }
  // Escape user inputs for security
  $un= mysqli_real_escape_string(
  $link, $_REQUEST['uname']);
  $m = mysqli_real_escape_string(
  $link, $_REQUEST['msg']);
  date_default_timezone_set('Asia/Kolkata');
  $ts=date('y-m-d h:ia');
  // Attempt insert query execution
  $sql = "INSERT INTO chats (uname, msg, dt)
  VALUES ('$un', '$m', '$ts')";
  if(mysqli_query($link, $sql)){
  ;
  } else{
  echo "ERROR: Message not sent!!!";
  }
  // Close connection
  mysqli_close($link);
  }
  ?>

  PHP和HTML在聊天室获取和接收信息的代码:在这个聊天室应用程序中,第一个用户的聊天室被直接连接到右边。如果下一个消息来自同一个用户,它也会直接传到聊天室的右边。如果消息来自其他用户,那么消息将被发送到左边。实现这一点的PHP功能在下面。自使用PHP功能被删除以来,在 <表单> 标签中,动作被设置在相同文件的名称中。

  <body onload="show_func()">
  <div id="container">
  <main>
  <header>
  <img src="https://s3-us-west-2.amazonaws.com/
  s.cdpn.io/1940306/ico_star.png" alt="">
  <div>
  <h2>GROUP CHAT</h2>
  </div>
  <img src="https://s3-us-west-2.amazonaws.com/
  s.cdpn.io/1940306/ico_star.png" alt="">
  </header>
  <script>
  function show_func(){
  var element = document.getElementById("chathist");
  element.scrollTop = element.scrollHeight;
  }
  </script>
  <form id="myform" action="Group_chat.php" method="POST" >
  <div class="inner_div" id="chathist">
  <?php
  $host = "localhost";
  $user = "root";
  $pass = "";
  $db_name = "chat_app";
  $con = new mysqli($host, $user, $pass, $db_name);
  $query = "SELECT * FROM chats";
  $run = $con->query($query);
  $i=0;
  while($row = $run->fetch_array()) :
  if($i==0){
  $i=5;
  $first=$row;
  ?>
  <div id="triangle1" class="triangle1"></div>
  <div id="message1" class="message1">
  <span style="color:white;float:right;">
  <?php echo $row['msg']; ?>
  </span> <br/>
  <div>
  <span style="color:black;float:left;
  font-size:10px;clear:both;">
  <?php echo $row['uname']; ?>, <?php echo $row['dt']; ?>
  </span>
  </div>
  </div>
  <br/><br/>
  <?php
  }
  else
  {
  if($row['uname']!=$first['uname'])
  {
  ?>
  <div id="triangle" class="triangle"></div>
  <div id="message" class="message">
  <span style="color:white;float:left;">
  <?php echo $row['msg']; ?></span> <br/>
  <div>
  <span style="color:black;float:right;
  font-size:10px;clear:both;">
  <?php echo $row['uname']; ?>,
  <?php echo $row['dt']; ?>
  </span>
  </div>
  </div>
  <br/><br/>
  <?php
  }
  else
  {
  ?>
  <div id="triangle1" class="triangle1"></div>
  <div id="message1" class="message1">
  <span style="color:white;float:right;">
  <?php echo $row['msg']; ?></span> <br/>
  <div>
  <span style="color:black;float:left;
  font-size:10px;clear:both;">
  <?php echo $row['uname']; ?>,
  <?php echo $row['dt']; ?>
  </span>
  </div>
  </div>
  <br/><br/>
  <?php
  }
  }
  endwhile; ?>
  </div>
  <footer>
  <table>
  <tr>
  <th>
  <input class="input1" type="text" id="uname"
  name="uname" placeholder="From"></input>
  </th>
  <th>
  <textarea id="msg" name="msg" rows='3'
  cols='50' placeholder="Type your message">
  </textarea>
  </th>
  <th>
  <input class="input2" type="submit" id="submit"
  name="submit" value="send"></input>
  </th>
  </tr>
  </table>
  </footer>
  </form>
  </main>
  </div>
  </body>

  现在CSS, JavaScript, PHP和HTML部分放在一起,整个代码在下面。它像分组聊天一样保存着。

  <?php
  if (isset($_POST['submit'])){
  /* Attempt MySQL server connection. Assuming
  you are running MySQL server with default
  setting (user 'root' with no password) */
  $link = mysqli_connect("localhost",
  "root", "", "chat_app");
  // Check connection
  if($link === false){
  die("ERROR: Could not connect. "
  . mysqli_connect_error());
  }
  // Escape user inputs for security
  $un= mysqli_real_escape_string(
  $link, $_REQUEST['uname']);
  $m = mysqli_real_escape_string(
  $link, $_REQUEST['msg']);
  date_default_timezone_set('Asia/Kolkata');
  $ts=date('y-m-d h:ia');
  // Attempt insert query execution
  $sql = "INSERT INTO chats (uname, msg, dt)
  VALUES ('$un', '$m', '$ts')";
  if(mysqli_query($link, $sql)){
  ;
  } else{
  echo "ERROR: Message not sent!!!";
  }
  // Close connection
  mysqli_close($link);
  }
  ?>
  <html>
  <head>
  <style>
  *{
  box-sizing:border-box;
  }
  body{
  background-color:#abd9e9;
  font-family:Arial;
  }
  #container{
  width:500px;
  height:700px;
  background:white;
  margin:0 auto;
  font-size:0;
  border-radius:5px;
  overflow:hidden;
  }
  main{
  width:500px;
  height:700px;
  display:inline-block;
  font-size:15px;
  vertical-align:top;
  }
  main header{
  height:100px;
  padding:30px 20px 30px 40px;
  background-color:#622569;
  }
  main header > *{
  display:inline-block;
  vertical-align:top;
  }
  main header img:first-child{
  width:24px;
  margin-top:8px;
  }
  main header img:last-child{
  width:24px;
  margin-top:8px;
  }
  main header div{
  margin-left:90px;
  margin-right:90px;
  }
  main header h2{
  font-size:25px;
  margin-top:5px;
  text-align:center;
  color:#FFFFFF;
  }
  main .inner_div{
  padding-left:0;
  margin:0;
  list-style-type:none;
  position:relative;
  overflow:auto;
  height:500px;
  background-image:url(
  https://media.geeksforgeeks.org/wp-content/cdn-uploads/20200911064223/bg.jpg);
  background-position:center;
  background-repeat:no-repeat;
  background-size:cover;
  position: relative;
  border-top:2px solid #fff;
  border-bottom:2px solid #fff;
  }
  main .triangle{
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 8px 8px 8px;
  border-color: transparent transparent
  #58b666 transparent;
  margin-left:20px;
  clear:both;
  }
  main .message{
  padding:10px;
  color:#000;
  margin-left:15px;
  background-color:#58b666;
  line-height:20px;
  max-width:90%;
  display:inline-block;
  text-align:left;
  border-radius:5px;
  clear:both;
  }
  main .triangle1{
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 8px 8px 8px;
  border-color: transparent
  transparent #6fbced transparent;
  margin-right:20px;
  float:right;
  clear:both;
  }
  main .message1{
  padding:10px;
  color:#000;
  margin-right:15px;
  background-color:#6fbced;
  line-height:20px;
  max-width:90%;
  display:inline-block;
  text-align:left;
  border-radius:5px;
  float:right;
  clear:both;
  }
  main footer{
  height:150px;
  padding:20px 30px 10px 20px;
  background-color:#622569;
  }
  main footer .input1{
  resize:none;
  border:100%;
  display:block;
  width:120%;
  height:55px;
  border-radius:3px;
  padding:20px;
  font-size:13px;
  margin-bottom:13px;
  }
  main footer textarea{
  resize:none;
  border:100%;
  display:block;
  width:140%;
  height:55px;
  border-radius:3px;
  padding:20px;
  font-size:13px;
  margin-bottom:13px;
  margin-left:20px;
  }
  main footer .input2{
  resize:none;
  border:100%;
  display:block;
  width:40%;
  height:55px;
  border-radius:3px;
  padding:20px;
  font-size:13px;
  margin-bottom:13px;
  margin-left:100px;
  color:white;
  text-align:center;
  background-color:black;
  border: 2px solid white;
  }
  }
  main footer textarea::placeholder{
  color:#ddd;
  }
  </style>
  <body onload="show_func()">
  <div id="container">
  <main>
  <header>
  <img src="https://s3-us-west-2.amazonaws.com/
  s.cdpn.io/1940306/ico_star.png" alt="">
  <div>
  <h2>GROUP CHAT</h2>
  </div>
  <img src="https://s3-us-west-2.amazonaws.com/
  s.cdpn.io/1940306/ico_star.png" alt="">
  </header>
  <script>
  function show_func(){
  var element = document.getElementById("chathist");
  element.scrollTop = element.scrollHeight;
  }
  </script>
  <form id="myform" action="Group_chat.php" method="POST" >
  <div class="inner_div" id="chathist">
  <?php
  $host = "localhost";
  $user = "root";
  $pass = "";
  $db_name = "chat_app";
  $con = new mysqli($host, $user, $pass, $db_name);
  $query = "SELECT * FROM chats";
  $run = $con->query($query);
  $i=0;
  while($row = $run->fetch_array()) :
  if($i==0){
  $i=5;
  $first=$row;
  ?>
  <div id="triangle1" class="triangle1"></div>
  <div id="message1" class="message1">
  <span style="color:white;float:right;">
  <?php echo $row['msg']; ?></span> <br/>
  <div>
  <span style="color:black;float:left;
  font-size:10px;clear:both;">
  <?php echo $row['uname']; ?>,
  <?php echo $row['dt']; ?>
  </span>
  </div>
  </div>
  <br/><br/>
  <?php
  }
  else
  {
  if($row['uname']!=$first['uname'])
  {
  ?>
  <div id="triangle" class="triangle"></div>
  <div id="message" class="message">
  <span style="color:white;float:left;">
  <?php echo $row['msg']; ?>
  </span> <br/>
  <div>
  <span style="color:black;float:right;
  font-size:10px;clear:both;">
  <?php echo $row['uname']; ?>,
  <?php echo $row['dt']; ?>
  </span>
  </div>
  </div>
  <br/><br/>
  <?php
  }
  else
  {
  ?>
  <div id="triangle1" class="triangle1"></div>
  <div id="message1" class="message1">
  <span style="color:white;float:right;">
  <?php echo $row['msg']; ?>
  </span> <br/>
  <div>
  <span style="color:black;float:left;
  font-size:10px;clear:both;">
  <?php echo $row['uname']; ?>,
  <?php echo $row['dt']; ?>
  </span>
  </div>
  </div>
  <br/><br/>
  <?php
  }
  }
  endwhile;
  ?>
  </div>
  <footer>
  <table>
  <tr>
  <th>
  <input class="input1" type="text"
  id="uname" name="uname"
  placeholder="From">
  </th>
  <th>
  <textarea id="msg" name="msg"
  rows='3' cols='50'
  placeholder="Type your message">
  </textarea></th>
  <th>
  <input class="input2" type="submit"
  id="submit" name="submit" value="send">
  </th>
  </tr>
  </table>
  </footer>
  </form>
  </main>
  </div>
  </body>
  </html>

  运行源码的步骤:
  1、将文件作为分组聊天保存,举个例子,我把文件放在了htdocs folder中称为“myfile”的文件中。
  2、在运行应用程序之前,通过跟随顶部的步骤创建数据库,将数据库名称为chat_app。
  3、检查XAMPP控制小组以确定Apache和MySQL在运行状态。
  4、打开浏览器和本地主机类型/myfiles,那个目录的索引将会打开,点击组聊天。
  5、开始发送消息并看到结果。

  • 16
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
鸽哒IM是一款2022年最新的即时通讯系统源码,它提供了安卓、苹果和PC端的全套开源代码,可以自由部署和定制。以下是鸽哒IM的部署教程: 1. 准备环境: - 安装JDK,并配置环境变量。 - 安装Android Studio和Xcode,用于编译安卓和苹果客户端。 - 安装Node.js和npm,用于编译PC端。 2. 下载源码: - 从鸽哒IM官方网站或GitHub上下载最新的源码压缩包。 - 解压缩源码到指定的目录。 3. 配置数据库: - 创建一个MySQL数据库,并导入源码中提供的SQL脚本。 - 修改配置文件,将数据库连接信息配置为正确的地址、用户名和密码。 4. 编译安卓客户端: - 打开Android Studio,导入鸽哒IM安卓客户端源码。 - 建立一个安卓模拟器或连接一个真实设备。 - 点击编译和运行按钮,等待编译完成。 5. 编译苹果客户端: - 打开Xcode,导入鸽哒IM苹果客户端源码。 - 连接一个iOS设备或选择一个模拟器。 - 点击编译和运行按钮,等待编译完成。 6. 编译PC端: - 打开命令提示符,导航到源码的PC端目录。 - 运行`npm install`命令,安装依赖项。 - 运行`npm run build`命令,编译PC端应用。 7. 部署服务器: - 将编译好的安卓、苹果和PC端应用部署到相应的服务器上。 - 配置服务器的域名和端口,使其与客户端连接。 至此,鸽哒IM即时通讯系统已经成功部署完成。用户可以从安卓、苹果和PC端访问该系统,并进行实时通讯、发送消息等操作。希望以上教程可以帮助你顺利部署和使用鸽哒IM
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值