瀏覽代碼

Merge remote-tracking branch 'origin/v3' into v3

wukai 2 年之前
父節點
當前提交
0bf98fe4a3
共有 4 個文件被更改,包括 91 次插入31 次删除
  1. 10 0
      src/components/forwordTree/index.vue
  2. 1 0
      src/layout/indexCommon.vue
  3. 1 2
      src/store/modules/user.js
  4. 79 29
      src/views/liveChat/index.vue

+ 10 - 0
src/components/forwordTree/index.vue

@@ -11,6 +11,7 @@
           <img :src="fileImg" alt="" class="left-img build-img" />
           <el-input
             v-model="dirName"
+            maxlength="32"
             class="bulid-input"
             clearable
             placeholder="新建目录"
@@ -158,8 +159,17 @@ const newTree = async () => {
     const resDir = await dirTree(3);
     treeData.value=[resDir]
   };
+
 //确认新建目录--点击勾选
 const sureDir = async () => {
+  const selectedNode = treeRef.value.getCurrentNode()
+  const siblings = selectedNode.children;
+  const hasSameLabel = siblings.some((node) => node.label === dirName.value);
+  if(hasSameLabel){
+    ElMessage({ message: "该目录名字已存在,请重新创建", type: "error" });
+    return
+  }
+  console.log('selectedNode', selectedNode)
   const dirRes = await builtDir({
     dirName: dirName.value,
     spaceId: props.spaceId,

+ 1 - 0
src/layout/indexCommon.vue

@@ -13,6 +13,7 @@
           <div class="search">
             <el-input
               v-model="searchText"
+              maxlength="32"
               class="w-50 m-2"
               size="small"
               placeholder="搜索文件"

+ 1 - 2
src/store/modules/user.js

@@ -43,8 +43,7 @@ const useUserStore = defineStore(
 				return new Promise((resolve, reject) => {
 					getInfo().then(res => {
 						const user = res.user
-						const avatar = (user.avatar == "" || user.avatar == null) ? defAva : import
-							.meta.env.VITE_APP_BASE_API + user.avatar;
+						const avatar = (user.avatar == "" || user.avatar == null) ? defAva : import.meta.env.VITE_APP_BASE_API + user.avatar/* @vite-ignore */;
 						if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组
 							this.roles = res.roles
 							this.permissions = res.permissions

+ 79 - 29
src/views/liveChat/index.vue

@@ -14,8 +14,20 @@ import send from "@/assets/images/send.png";
 import downFile from "@/assets/images/down-file.png";
 import forwardFile from "@/assets/images/forward-file.png";
 import sendFile from "@/assets/images/send-file.png";
+import { parseTime } from "@/utils/ruoyi";
 import store from "@/store";
-import {msgFriend,userTree,userInfo,msgSend,msgRecord,delMsg,dirTree,fileTree,spaceInfo,fileDownload} from "@/api/chat/msg";
+import {
+  msgFriend,
+  userTree,
+  userInfo,
+  msgSend,
+  msgRecord,
+  delMsg,
+  dirTree,
+  fileTree,
+  spaceInfo,
+  fileDownload,
+} from "@/api/chat/msg";
 import Addperson from "@/components/AddPerson/index.vue"; //添加人员的弹框
 import FileTreeChoice from "@/components/FileTreeChoice/index.vue"; //选择文件发送的列表
 import forwordTree from "@/components/forwordTree/index.vue"; //选择文件发送的列表
@@ -23,7 +35,6 @@ import forwordTree from "@/components/forwordTree/index.vue"; //选择文件发
 import useWebsoctStore from "@/store/modules/websocket";
 import { ElMessage } from "element-plus";
 const route = useRoute();
-console.log('route===', route)
 const websoctStore = useWebsoctStore();
 //====
 const { proxy } = getCurrentInstance();
@@ -36,9 +47,9 @@ const sendId = ref(""); //选择发送的文件id
 const isForward = ref(false);
 const openFile = ref(false); //文件目录
 const openForwardFile = ref(false); //转发目录
-const showCircel=ref('')  //是否 显示圆点
+const showCircel = ref(""); //是否 显示圆点
 const chatRecords = reactive({ data: [] });
-const loading = ref(false)
+const loading = ref(false);
 const sendCont = reactive({
   //发送聊天内容数据组装
   data: {
@@ -61,7 +72,6 @@ const SearchChat = () => {
 }; //搜索的点击事件
 //聊天列表数据模拟
 const personList = reactive({ data: [] });
-// const personList =reactive({data: []})
 //获取好友列表
 const getMsgList = async () => {
   const resFriend = await msgFriend();
@@ -92,6 +102,12 @@ const msgRecordEvent = async (toIdValue) => {
   const resMsgData = await msgRecord(toIdValue, queryParams);
   resMsgData.rows.map((i) => (i.isForward = false));
   chatRecords.data = resMsgData.rows.reverse();
+  const nowtime = parseTime(new Date().getTime(), "{y}-{m}-{d}");
+  console.log("firstnowtime", nowtime);
+  chatRecords.data.map((i) => {
+    if (nowtime == i.createTime.substr(0, 10))
+      i.createTime = i.createTime.substring(11);
+  });
   total.value = resMsgData.total;
 };
 //点击左侧新建聊天
@@ -187,15 +203,17 @@ const sendFileClick = async () => {
   openFile.value = true;
 };
 //获取用户聊天记录
-const handleNewMessage = () => {
+const handleNewMessage = async () => {
   if (websoctStore.newMessage) {
     msgRecordEvent(sendCont.data.toId); //获取用户的聊天记录
+    getMsgList()
     websoctStore.newMessage = false; // 重置新消息标记
   }
 };
 watchEffect(() => {
   if (websoctStore.messOne?.fromId) {
     msgRecordEvent(websoctStore.messOne.fromId);
+    getMsgList()
   }
 });
 // 滚动翻页========
@@ -203,8 +221,13 @@ const noMes = ref(false);
 const handleScroll = (event) => {
   // 在滚动到顶部时,加载上一页的聊天记录
   const mainContainer = document.querySelector(".right-container");
-  if (event.deltaY < 0 && mainContainer.scrollTop <= 1&&!noMes.value) {
-    loading.value=true
+  if (
+    event.deltaY < 0 &&
+    mainContainer.scrollTop <= 1 &&
+    !noMes.value &&
+    !loading.value
+  ) {
+    loading.value = true;
     loadPreviousPage();
   }
 };
@@ -214,16 +237,23 @@ const loadPreviousPage = async () => {
     pageNum: currentPageNum,
     pageSize: 10,
   };
+
   const resMsgData = await msgRecord(sendCont.data.toId, queryParams);
-  loading.value=false
   const previousPageData = resMsgData.rows.reverse();
+  chatRecords.data = [...previousPageData, ...chatRecords.data];
+  const nowtime2 = parseTime(new Date().getTime(), "{y}-{m}-{d}");
+  chatRecords.data.map((i) => {
+    if (nowtime2 == i.createTime.substr(0, 10))
+      i.createTime = i.createTime.substring(11);
+  });
+  noMes.value = false;
   if (currentPageNum * 10 >= resMsgData.total && !noMes.value) {
-    return noMes.value = true;
-
-    // return ElMessage("无更多聊天记录");
+    loading.value = false;
+    noMes.value = true;
+    return;
   }
   // 将加载的上一页聊天记录插入到 chatRecords.data 的前面
-  chatRecords.data = [...previousPageData, ...chatRecords.data];
+  loading.value = false;
 };
 const transferFiles = (forwardVal, msgIds, indexs) => {
   chatRecords.data.map((i, index) => {
@@ -237,9 +267,9 @@ const transferFiles = (forwardVal, msgIds, indexs) => {
 // 点击转存
 const forwardTreeData = reactive({ data: {} });
 const spaceId = ref("");
-const docId=ref('')
-const forwardClick = async (indexs,docIds) => {
-  docId.value=docIds.toString()
+const docId = ref("");
+const forwardClick = async (indexs, docIds) => {
+  docId.value = docIds ? docIds.toString() : "";
   const resDir = await dirTree(3);
   forwardTreeData.data = resDir;
   toRaw(forwardTreeData.data);
@@ -250,10 +280,10 @@ const forwardClick = async (indexs,docIds) => {
 };
 const forwardChangeMsg = async (val) => {};
 //点击下载
-const downClick =async (fileId) => {
+const downClick = async (fileId) => {
   // location.href=await fileDownload(fileId)
-   location.href=`${import.meta.env.VITE_APP_BASE_API}/api/download/${fileId}`;
-}
+  location.href = `${import.meta.env.VITE_APP_BASE_API}/api/download/${fileId}`;
+};
 // 滚动翻页========
 onMounted(() => {
   getMsgList();
@@ -269,6 +299,7 @@ onMounted(() => {
       <div class="left-top search">
         <el-input
           v-model="searchText"
+          maxlength="32"
           class="w-50 m-2"
           size="small"
           clearable
@@ -277,7 +308,12 @@ onMounted(() => {
           @change="SearchChat"
         />
         <!-- 添加聊天人员 -->
-        <el-icon size="24" color="#505870" @click="clickNewPerson" style=" margin-right: 8px;"><Plus
+        <el-icon
+          size="24"
+          color="#505870"
+          @click="clickNewPerson"
+          style="margin-right: 8px"
+          ><Plus
         /></el-icon>
         <!-- 新建聊天弹框 -->
         <Addperson
@@ -299,13 +335,13 @@ onMounted(() => {
         @click="clickPerson(index, item)"
       >
         <img :src="cebian" class="cebian" v-if="clickPersonIndex == index" />
-        <button
+        <!-- <button
           class="del-chat"
           v-if="clickPersonIndex == index"
           @click="delClick(item.msgId)"
         >
           删除聊天
-        </button>
+        </button> -->
         <div>
           <img :src="item.avatar ? item.avatar : chat" class="head-sculpture" />
         </div>
@@ -340,7 +376,7 @@ onMounted(() => {
             @mousewheel="handleScroll"
             ref="mainContainer"
           >
-            <div  v-loading="loading"></div>
+            <div v-loading="loading"></div>
             <!-- <div v-if="noMes" style="color:#9fa1a5 ;">无更多聊天记录</div> -->
             <div
               class="message-container"
@@ -369,7 +405,11 @@ onMounted(() => {
                     record.msgType == '2' ? 'clip-path' : 'clip-path-right'
                   "
                 >
-                  <div>{{ record.createTime }}</div>
+                  <div
+                    style="color: #c1cce3; font-size: 12px; margin-bottom: 4px"
+                  >
+                    {{ record.createTime.slice(0, -3) }}
+                  </div>
                   <span v-if="record.msgType == '1'">{{
                     record.file?.fileName
                   }}</span>
@@ -397,7 +437,15 @@ onMounted(() => {
                       record.msgType == '2' ? 'clip-path' : 'clip-path-left'
                     "
                   >
-                    <div>{{ record.createTime }}</div>
+                    <div
+                      style="
+                        color: #7a89ba;
+                        font-size: 12px;
+                        margin-bottom: 4px;
+                      "
+                    >
+                      {{ record.createTime.slice(0, -3) }}
+                    </div>
                     <span v-if="record.msgType == '1'">{{
                       record.file?.fileName
                     }}</span>
@@ -411,7 +459,7 @@ onMounted(() => {
                   class="zhuanfa forwd"
                   alt="转存"
                   v-if="record.isForward"
-                  @click="forwardClick(index,record.file.docId)"
+                  @click="forwardClick(index, record.file?.docId)"
                 />
                 <img
                   :src="downFile"
@@ -440,8 +488,10 @@ onMounted(() => {
             <el-input
               v-model="messageText"
               class="w-50 m-2"
+              clearable
               size="small"
               placeholder="请输入聊天内容"
+              @keydown.enter="msgSendClick"
             />
             <!-- 发送按钮 -->
             <img :src="send" class="send-info" @click="msgSendClick" />
@@ -462,16 +512,16 @@ onMounted(() => {
 
 <style lang="scss" scoped>
 @import "@/assets/styles/my-common.scss";
-.left-container{
+.left-container {
   position: relative;
 }
-.yuandian{
+.yuandian {
   width: 8px;
   height: 8px;
   position: absolute;
   right: 8px;
   top: 6px;
-  background: #FA5151;
+  background: #fa5151;
   border-radius: 4px;
 }
 </style>