Bladeren bron

修改聊天不显示的bug

“yueshang” 2 jaren geleden
bovenliggende
commit
feee91ae3d

+ 1 - 1
src/layout/indexCommon.vue

@@ -82,7 +82,7 @@
                   v-if="
                     websoctStore.messOne?.fromId &&
                     item.path == '/index' &&
-                    $route.path != item.path
+                    $route.path != item.path&&clickId!==index
                   "
                 ></span>
               </div> </router-link

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

@@ -30,7 +30,7 @@ const useWebsoctStore = defineStore('websoct', {
       })
 
       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)
@@ -40,12 +40,12 @@ const useWebsoctStore = defineStore('websoct', {
       this.socket.addEventListener("close", () => {
         // console.log("WebSocket连接已关闭")
         ElMessage({ message: "WebSocket重连失败,请尝试刷新界面", type: "error" });
-        reconnect(url);  //尝试重新连接
+        this.reconnect(url);  //尝试重新连接
       })
 
       this.socket.addEventListener("error", (error) => {
         ElMessage({ message: "WebSocket连接错误", type: "error" });
-        reconnect(url);  //尝试重新连接
+        this. reconnect(url);  //尝试重新连接
       })
     },
     sendMessage(message) {
@@ -70,6 +70,7 @@ const useWebsoctStore = defineStore('websoct', {
       if (lockReconnect) return ElMessage({ message: "WebSocket重连失败,请尝试刷新界面", type: "error" });
       lockReconnect = true;
       setTimeout(function () { //没连接上会一直重连,设置延迟避免请求过多
+        ElMessage({ message: "请尝试重连中", type: "error" });
           this.socket = new WebSocket(url);
           lockReconnect = false;
       }, 2000);

+ 10 - 3
src/views/department/Department.vue

@@ -292,20 +292,21 @@
                             </el-checkbox-group>
                         </el-form-item>
                         <el-form-item label="选择成员" v-if="directoryPower">
-                            <el-transfer v-model="v1form.tranvalue1" filterable :filter-method="filterMethod1"
-                                filter-placeholder="State Abbreviations" :data="trandata1" />
+                            <!-- <el-transfer v-model="v1form.tranvalue1" filterable :filter-method="filterMethod1"
+                                filter-placeholder="State Abbreviations" :data="trandata1" /> -->
                             <!-- <template #footer>
                                 <span class="dialog-footer">
                                     <el-button @click="transferModal = false">取消</el-button>
                                     <el-button type="primary" @click="transferSure">确定</el-button>
                                 </span>
                             </template> -->
+                            <TransferModal  :isNewMenu="isNewMenu"></TransferModal>
                         </el-form-item>
                     </el-form>
                     <template #footer>
                         <span class="dialog-footer">
                             <el-button @click="directoryModal = false">取消</el-button>
-                            <el-button type="primary" @click="">
+                            <el-button type="primary">
                                 确定
                             </el-button>
                         </span>
@@ -319,6 +320,7 @@
 <script>
 import { ref } from 'vue'
 import myfile from '../../api/myfile/myfile'
+import TransferModal from '../myfile/modalComponebts/Transfer.vue'
 import { Search } from '@element-plus/icons-vue'
 import copy from '../../assets/images/copy.png'
 import clipboard from '../../assets/images/clipboard.png'
@@ -364,6 +366,7 @@ export default {
         let trandata = ref(generateData())
         let trandata1 = ref(generateData1())
         let tranvalue = ref([])
+        const isNewMenu=ref([])  //是否是新建组织目录
         // let tranvalue1 = ref([])
         let v1form = ref({
             names:"",
@@ -592,6 +595,7 @@ export default {
                 directoryPower.value = false
             }else{
                 directoryPower.value = true
+                isNewMenu.value=true
             }
         }
         return {
@@ -656,6 +660,9 @@ export default {
     created() {
         this.getAll();
     },
+    components: {
+        TransferModal,
+    },
 }
 </script>
 

+ 161 - 83
src/views/liveChat/index.vue

@@ -4,7 +4,7 @@ export default {
 };
 </script>
 <script setup>
-import { ref, reactive, toRaw, toRefs, nextTick, computed } from "vue";
+import { ref, reactive, toRaw, toRefs, nextTick, computed, watchEffect } from "vue";
 import { useRouter, useRoute } from "vue-router";
 import useUserStore from "@/store/modules/user";
 import word from "@/assets/images/word2.png";
@@ -50,6 +50,7 @@ const openForwardFile = ref(false); //转发目录
 const showCircel = ref(""); //是否 显示圆点
 const chatRecords = reactive({ data: [] });
 const loading = ref(false);
+const wangzhi=import.meta.env.VITE_APP_BASE_API
 const sendCont = reactive({
   //发送聊天内容数据组装
   data: {
@@ -77,8 +78,6 @@ const getMsgList = async () => {
   searchData.value.map((i) => {
     if (i.fromId == websoctStore.messOne?.fromId) {
       i.showCircel = true;
-    } else {
-      i.showCircel = false;
     }
   });
   //圆点======
@@ -96,16 +95,16 @@ const getMsgList = async () => {
   }
 };
 const noMes = ref(false);
-const boottmScroll=()=>{
-//发送消息后滚动到最底部显示最新消息
-const chatContainer = document.querySelector(".right-container");
+const boottmScroll = () => {
+  //发送消息后滚动到最底部显示最新消息
+  const chatContainer = document.querySelector(".right-container");
   // 计算滚动的目标位置
   const targetScrollTop = chatContainer.scrollHeight;
   // 设置滚动位置
   nextTick(() => {
     chatContainer.scrollTop = targetScrollTop;
   });
-}
+};
 //获取用户的聊天记录
 const msgRecordEvent = async (toIdValue) => {
   const queryParams = {
@@ -126,7 +125,7 @@ const msgRecordEvent = async (toIdValue) => {
       i.createTime = i.createTime.substring(11);
   });
   total.value = resMsgData.total;
-  boottmScroll()
+  boottmScroll();
 };
 //点击左侧新建聊天
 const open = ref(false);
@@ -154,7 +153,7 @@ const clickPerson = (index, item) => {
   clickPersonIndex.value = index;
   //点击某个人就不显示红点
   searchData.value.map((i) => {
-    if (i.fromId == websoctStore.messOne?.fromId) {
+    if (i.fromId == item.fromId) {
       i.showCircel = false;
     }
   });
@@ -205,7 +204,6 @@ const changeMsg = async (val) => {
 //发送聊天
 const inputRef = ref(null);
 const msgSendClick = (event) => {
-  console.log(event);
   if (event.ctrlKey && event.keyCode == 13) {
     //CTRL+enter键换行
     const textarea = event.target;
@@ -221,7 +219,6 @@ const msgSendClick = (event) => {
   } else if (event.shiftKey && event.keyCode == 13) {
     event.preventDefault();
   } else {
-    console.log("onlyenter");
     noMes.value = false;
     if (messageText.value.trim() == "") {
       return ElMessage({ message: "不能发送空白消息", type: "error" });
@@ -233,7 +230,7 @@ const msgSendClick = (event) => {
       toId: sendCont.data.toId,
     };
     websoctStore.sendMessage(message);
-    boottmScroll()
+    boottmScroll();
     event.preventDefault();
     messageText.value = "";
     //  将光标设置到输入框第一行
@@ -278,12 +275,6 @@ const mainContainer = ref(null);
 const handleScroll = (event) => {
   // 在滚动到顶部时,加载上一页的聊天记录
   const mainContainer2 = document.querySelector(".right-container");
-  console.log(
-    " event.deltaY",
-    mainContainer2.scrollTop,
-    noMes.value,
-    loading.value
-  );
   if (
     event.deltaY < 0 &&
     mainContainer2.scrollTop <= 1 &&
@@ -321,7 +312,8 @@ const loadPreviousPage = async () => {
   const newMessages = document.querySelectorAll(".message-container");
   const firstNewMessage = newMessages[previousPageData.length];
   const firstNewMessageTop = mainContainer.offsetHeight + 100;
-  mainContainer.scrollTop = firstNewMessageTop;chatRecords.data
+  mainContainer.scrollTop = firstNewMessageTop;
+  chatRecords.data;
   //===========
   // 将加载的上一页聊天记录插入到 chatRecords.data 的前面
   loading.value = false;
@@ -370,11 +362,6 @@ const formatText = (text) => {
   const formattedText = text.replace(/\n/g, "<br>");
   return formattedText;
 };
-//获得个人头像转换
-
-const getMyThoto=computed(() => item => {
-    return item.toId == userIds.uid?item.fromAvatar:item.toAvatar
-})
 // 滚动翻页========
 onMounted(() => {
   getMsgList();
@@ -435,12 +422,36 @@ onMounted(() => {
         </button> -->
         <div>
           <!-- <img :src="item.avatar?item.avatar : chat" class="head-sculpture" /> -->
-          <img :src="getMyThoto(item)" class="head-sculpture" v-if="getMyThoto(item)"/>
-          <span style="background-color: #7a89ba;display: inline-block;color: #fff;font-weight: 600;text-align: center;line-height: 40px;" class="head-sculpture" v-else>{{item.toId == userIds.uid?item.fromName?.slice(0,1):item.toName?.slice(0,1)}}</span>
+          <img
+            :src="wangzhi + item.fromAvatar"
+            class="head-sculpture"
+            v-if="item.toId == userIds.uid && item.fromAvatar"
+          />
+          <img
+            :src="wangzhi + item.toAvatar"
+            class="head-sculpture"
+            v-else-if="item.toId != userIds.uid && item.toAvatar"
+          />
+          <span
+            style="
+              background-color: #7a89ba;
+              display: inline-block;
+              color: #fff;
+              font-weight: 600;
+              text-align: center;
+              line-height: 40px;
+            "
+            class="head-sculpture"
+            v-else
+            >{{ item.toId == userIds.uid? item.fromName?.slice(0, 1): item.toName?.slice(0, 1) }}</span>
         </div>
         <div class="spill">
           <span class="person-name">{{
-            item.nickName? item.nickName: (item.toId == userIds.uid? item.fromName: item.toName)
+            item.nickName
+              ? item.nickName
+              : item.toId == userIds.uid
+              ? item.fromName
+              : item.toName
           }}</span
           ><span class="person-cont spill">
             {{ item.file?.fileName ? item.file?.fileName : item.content }}</span
@@ -479,82 +490,149 @@ onMounted(() => {
               }"
               :key="index"
             >
-              <div
-                v-if="useUserStore().uid !== record.toId"
-                :class="
-                  record.msgType == '1'
-                    ? 'file-msg right-back'
-                    : 'time-text right-back'
-                "
-              >
-                <img
-                  :src="word"
-                  v-if="record.msgType == '1'"
-                  class="head-sculpture"
-                />
+              <div>
                 <div
-                  :class="
-                    record.msgType == '2' ? 'clip-path' : 'clip-path-right'
-                  "
+                  v-if="useUserStore().uid !== record.toId"
+                  style="display: flex"
                 >
                   <div
-                    style="color: #c1cce3; font-size: 12px; margin-bottom: 4px"
+                    :class="
+                      record.msgType == '1'
+                        ? 'file-msg right-back'
+                        : 'time-text right-back'
+                    "
                   >
-                    {{ record.createTime.slice(0, -3) }}
-                  </div>
-                  <span v-if="record.msgType == '1'">{{
-                    record.file?.fileName
-                  }}</span>
-                  <!-- <span v-else-if="record.msgType == '2'">{{
+                    <img
+                      :src="word"
+                      v-if="record.msgType == '1'"
+                      class="head-sculpture"
+                    />
+                    <div
+                      :class="
+                        record.msgType == '2' ? 'clip-path' : 'clip-path-right'
+                      "
+                    >
+                      <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>
+                      <!-- <span v-else-if="record.msgType == '2'">{{
                     record.content
                   }}</span> -->
-                  <span
-                    v-else-if="record.msgType == '2'"
-                    v-html="formatText(record.content)"
-                  ></span>
+                      <span
+                        v-else-if="record.msgType == '2'"
+                        v-html="formatText(record.content)"
+                      ></span>
+                    </div>
+                  </div>
+                  <div>
+                    <img
+                      :src="wangzhi + record.fromAvatar"
+                      class="head-sculpture"
+                      v-if="
+                        useUserStore().uid != record.toId && record.fromAvatar
+                      "
+                    />
+                    <img
+                      :src="wangzhi + record.toAvatar"
+                      class="head-sculpture"
+                      v-else-if="
+                        useUserStore().uid == record.toId && record.toAvatar
+                      "
+                    />
+                    <span
+                      style="
+                        background-color: #7a89ba;
+                        display: inline-block;
+                        color: #fff;
+                        font-weight: 600;
+                        text-align: center;
+                        line-height: 40px;
+                      "
+                      class="head-sculpture"
+                      v-else
+                      >{{ record.fromName.slice(0, 1) }}</span
+                    >
+                  </div>
                 </div>
+                <!-- 头像 -->
+                <!-- <img :src="chat" class="head-sculpture" /> -->
               </div>
-              <!-- 头像 -->
-              <!-- <img :src="chat" class="head-sculpture" /> -->
-              <img :src="getMyThoto(record)" class="head-sculpture" v-if="getMyThoto(record)"/>
-              <span style="background-color: #7a89ba;display: inline-block;color: #fff;font-weight: 600;text-align: center;line-height: 40px;" class="head-sculpture" v-else>{{ record.fromName.slice(0,1) }}</span>
               <div style="display: flex; align-items: center">
                 <div
                   v-if="useUserStore().uid == record.toId"
-                  :class="
-                    record.msgType == '1' ? 'file-msg left-back' : 'left-back'
-                  "
-                  @click="transferFiles(record.msgType, record.msgId, index)"
+                  style="display: flex"
                 >
-                  <img
-                    v-if="record.msgType == '1'"
-                    :src="word"
-                    class="head-sculpture"
-                  />
+                  <div>
+                    <img
+                      :src="wangzhi + record.fromAvatar"
+                      class="head-sculpture"
+                      v-if="
+                        useUserStore().uid == record.toId && record.fromAvatar
+                      "
+                    />
+                    <img
+                      :src="wangzhi + record.toAvatar"
+                      class="head-sculpture"
+                      v-else-if="
+                        useUserStore().uid != record.toId && record.toAvatar
+                      "
+                    />
+                    <span
+                      style="
+                        background-color: #7a89ba;
+                        display: inline-block;
+                        color: #fff;
+                        font-weight: 600;
+                        text-align: center;
+                        line-height: 40px;
+                      "
+                      class="head-sculpture"
+                      v-else
+                      >{{ record.fromName.slice(0, 1) }}</span
+                    >
+                  </div>
                   <div
                     :class="
-                      record.msgType == '2' ? 'clip-path' : 'clip-path-left'
+                      record.msgType == '1' ? 'file-msg left-back' : 'left-back'
                     "
+                    @click="transferFiles(record.msgType, record.msgId, index)"
                   >
+                    <img
+                      v-if="record.msgType == '1'"
+                      :src="word"
+                      class="head-sculpture"
+                    />
                     <div
-                      style="
-                        color: #7a89ba;
-                        font-size: 12px;
-                        margin-bottom: 4px;
+                      :class="
+                        record.msgType == '2' ? 'clip-path' : 'clip-path-left'
                       "
                     >
-                      {{ record.createTime.slice(0, -3) }}
+                      <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>
+                      <span
+                        v-else-if="record.msgType == '2'"
+                        v-html="formatText(record.content)"
+                      ></span>
                     </div>
-                    <span v-if="record.msgType == '1'">{{
-                      record.file?.fileName
-                    }}</span>
-                    <!-- <span v-else-if="record.msgType == '2'">{{
-                      record.content
-                    }}</span> -->
-                    <span
-                      v-else-if="record.msgType == '2'"
-                      v-html="formatText(record.content)"
-                    ></span>
                   </div>
                 </div>
                 <img

+ 8 - 2
src/views/myfile/modalComponebts/Transfer.vue

@@ -58,13 +58,18 @@ export default {
         workOrEdit: {
             type: Number,
             required: true
-        }
+        },
+        isNewMenu:{
+            type: Boolean,
+            required: true
+        },
     },
     setup(props, { emit }) {
         let { backToFather, sureBackFather } = toRefs(props)
         let result = props.thanks
         let dees = props.clickRowId
         let feeh = props.workOrEdit
+        let isNewMenus = props.isNewMenu
         let transferModals = ref(false)
         let allTreeData = ref([])
         let allTreeProps = {
@@ -155,6 +160,7 @@ export default {
         }
         // 获取用户树
         function getAllUser() {
+            console.log('isNewMenu', props.clickRowId)
             userTree.getUserTree({}).then(res => {
                 allTreeData.value = [res]
                 userTree.getUserTree({}).then(res => {
@@ -182,7 +188,7 @@ export default {
                         return item.userId
                     })
                 })
-            } else {
+            } else if(!isNewMenus){   
                 fileCount.getActor(dees).then(res => {
                     console.log(res, 'count');
                 })

+ 4 - 3
vite.config.js

@@ -39,16 +39,17 @@ export default defineConfig(({
 			proxy: {
 				// https://cn.vitejs.dev/config/#server-proxy
 				'/dev-api': {
-					target: 'http://192.168.1.28:8080/',
+					// target: 'http://192.168.1.28:8080/',
 					// target: 'http://8.142.173.95:19527/',
-					// target:'http://192.168.1.18:8080/',
+					target:'http://192.168.1.11:8080/',
 					changeOrigin: true,
 					rewrite: (p) => p.replace(/^\/dev-api/, '')
 				},
 				//websocket代理
 				'/websocket': {				
 					// target:'ws://8.142.173.95:19527/websocket',
-					target:'ws://192.168.1.28:8080/websocket',
+					// target:'ws://192.168.1.28:8080/websocket',
+					target:'ws://192.168.1.11:8080/websocket',
 					changeOrigin: true,
 					rewrite: (p) => p.replace(/^\/websocket/, '')
 				}