Przeglądaj źródła

聊天的转存下载,圆点未写完

“yueshang” 2 lat temu
rodzic
commit
41a84343d8

+ 30 - 21
src/components/forwordTree/index.vue

@@ -21,7 +21,7 @@
         </div>
         <el-tree-v2
           ref="treeRef"
-          :data="treeData.data"
+          :data="treeData"
           :highlight-current="true"
           :default-expanded-keys="[spaceId]"
           :show-checkbox="false"
@@ -62,7 +62,16 @@
   </el-dialog>
 </template>
     <script setup>
-import { reactive, ref, toRaw, toRefs, watch, nextTick, onMounted } from "vue";
+import {
+  reactive,
+  ref,
+  toRaw,
+  toRefs,
+  watch,
+  nextTick,
+  onMounted,
+  getCurrentInstance,
+} from "vue";
 import { ElMessage } from "element-plus";
 import fileImg from "@/assets/images/file-img.png";
 import direction from "@/assets/images/direction.png";
@@ -95,28 +104,27 @@ const dirName = ref(""); //新建文件夹名称
 const dirBulidNow = ref(false);
 const treeRef = ref(null);
 const isOpen = ref(props.openForwardFile);
+const instance = getCurrentInstance();
 watch(
   () => props.openForwardFile,
   (newValue) => {
     isOpen.value = newValue;
   }
 );
-const treeData = reactive({ data: [] });
+const treeData = ref([]);
 const defaultExpandedKeys = ref([]);
 watchEffect(() => {
-  treeData.data[0] = props.forwardTreeData;
-//   //默认展开第二级
-//   treeData.data.forEach((node) => {
-//     if (node.children) {
-//       // 如果节点有子节点
-//       const childKeys = node.children.map((child) => child.id); // 获取子节点的 key 数组
-//       defaultExpandedKeys.value= [... defaultExpandedKeys.value, ...childKeys]; // 将子节点的 key 数组合并到 defaultExpandedKeys 中
-//     }
-//   });
-});
-watchEffect(() => {
-  console.log("props.docId", props.docId);
+  treeData.value =[ props.forwardTreeData];
+  //   //默认展开第二级
+  //   treeData.data.forEach((node) => {
+  //     if (node.children) {
+  //       // 如果节点有子节点
+  //       const childKeys = node.children.map((child) => child.id); // 获取子节点的 key 数组
+  //       defaultExpandedKeys.value= [... defaultExpandedKeys.value, ...childKeys]; // 将子节点的 key 数组合并到 defaultExpandedKeys 中
+  //     }
+  //   });
 });
+
 //树
 const clickData = ref({});
 const handleNodeClick = (data) => {
@@ -145,6 +153,11 @@ const buildFile = async () => {
   }
   dirBulidNow.value = true;
 };
+const newTree = async () => {
+    //重新获取树结构
+    const resDir = await dirTree(3);
+    treeData.value=[resDir]
+  };
 //确认新建目录--点击勾选
 const sureDir = async () => {
   const dirRes = await builtDir({
@@ -152,17 +165,13 @@ const sureDir = async () => {
     spaceId: props.spaceId,
     parentId: clickData.value.id,
   });
-  if (dirRes.code === 200) {
+  if (dirRes.code == 200) {
     ElMessage({ message: "创建成功", type: "success" });
     dirBulidNow.value = false;
     clickId.value = "";
     dirName.value = "";
-    //重新获取树结构
-    const resDir = await dirTree(3);
-    treeData.data[0] = resDir;
-    // treeRef.value.setCurrentKey(clickData.value.id)
+    newTree();
   }
-
 };
 </script>
   <style lang="scss" scoped>

+ 4 - 3
src/store/modules/websocket.js

@@ -19,11 +19,11 @@ const useWebsoctStore = defineStore('websoct', {
       this.socket = new WebSocket(`${window.location.origin.replace("http", "ws")}/websocket/message/${useUserStore().uid}`);
       }
       this.socket.addEventListener("open", () => {
-        console.log("WebSocket连接已打开")
+        // console.log("WebSocket连接已打开")
       })
 
       this.socket.addEventListener("message", (event) => {
-        console.log('event发送消息', event)
+        // console.log('event发送消息', event)
         const message=event.data!='连接成功'?JSON.parse(JSON.stringify(event.data)):''
         this.messOne=event.data!='连接成功'?JSON.parse(event.data):{}
         this.messages.push(message)
@@ -31,7 +31,8 @@ const useWebsoctStore = defineStore('websoct', {
       })
 
       this.socket.addEventListener("close", () => {
-        console.log("WebSocket连接已关闭")
+        // console.log("WebSocket连接已关闭")
+        ElMessage({ message: "WebSocket连接已关闭", type: "error" });
       })
 
       this.socket.addEventListener("error", (error) => {

+ 20 - 2
src/views/liveChat/index.vue

@@ -5,6 +5,7 @@ export default {
 </script>
 <script setup>
 import { ref, reactive, toRaw, toRefs } from "vue";
+import { useRouter, useRoute } from "vue-router";
 import useUserStore from "@/store/modules/user";
 import word from "@/assets/images/word2.png";
 import chat from "@/assets/images/profile.jpg";
@@ -21,6 +22,8 @@ import forwordTree from "@/components/forwordTree/index.vue"; //选择文件发
 //websocket连接====
 import useWebsoctStore from "@/store/modules/websocket";
 import { ElMessage } from "element-plus";
+const route = useRoute();
+console.log('route===', route)
 const websoctStore = useWebsoctStore();
 //====
 const { proxy } = getCurrentInstance();
@@ -33,6 +36,7 @@ const sendId = ref(""); //选择发送的文件id
 const isForward = ref(false);
 const openFile = ref(false); //文件目录
 const openForwardFile = ref(false); //转发目录
+const showCircel=ref('')  //是否 显示圆点
 const chatRecords = reactive({ data: [] });
 const sendCont = reactive({
   //发送聊天内容数据组装
@@ -190,6 +194,9 @@ const handleNewMessage = () => {
 };
 watchEffect(() => {
   if (websoctStore.messOne?.fromId) {
+    if(websoctStore.messOne.fromId==personList.data[0]?.fromId){
+      showCircel.value=websoctStore.messOne.fromId
+    }
     msgRecordEvent(websoctStore.messOne.fromId);
   }
 });
@@ -238,7 +245,6 @@ const forwardClick = async (indexs,docIds) => {
   //获取最上层树的id
   const topSpaceid = await spaceInfo(3);
   spaceId.value = topSpaceid.data.spaceId.toString();
-  console.log("topSpaceid", topSpaceid);
   openForwardFile.value = true;
 };
 const forwardChangeMsg = async (val) => {};
@@ -246,7 +252,6 @@ const forwardChangeMsg = async (val) => {};
 const downClick =async (fileId) => {
   // location.href=await fileDownload(fileId)
    location.href=`${import.meta.env.VITE_APP_BASE_API}/api/download/${fileId}`;
-   console.log('downRes===', downRes)
 }
 // 滚动翻页========
 onMounted(() => {
@@ -316,6 +321,7 @@ onMounted(() => {
             {{ item.cont ? item.cont : item.content }}</span
           >
         </div>
+        <span class="yuandian" v-if="showCircel==item.fromId&&$route.path=='/index'"></span>
       </div>
     </div>
     <!-- 右侧聊天 -->
@@ -454,4 +460,16 @@ onMounted(() => {
 
 <style lang="scss" scoped>
 @import "@/assets/styles/my-common.scss";
+.left-container{
+  position: relative;
+}
+.yuandian{
+  width: 8px;
+  height: 8px;
+  position: absolute;
+  right: 8px;
+  top: 6px;
+  background: #FA5151;
+  border-radius: 4px;
+}
 </style>