Преглед на файлове

修改复制到还有历史版本的bug

“yueshang” преди 2 години
родител
ревизия
42cf13e9de
променени са 4 файла, в които са добавени 95 реда и са изтрити 64 реда
  1. 22 6
      src/layout/indexCommon.vue
  2. 58 49
      src/views/liveChat/index.vue
  3. 10 7
      src/views/myfile/MyFile.vue
  4. 5 2
      src/views/myfile/components/FileEdit.vue

+ 22 - 6
src/layout/indexCommon.vue

@@ -7,7 +7,9 @@
       >
         <div class="nav-top">
           <div>
-            <img src="@/assets/images/logos.png" /><span>聚合智慧文档管理系统</span>
+            <img src="@/assets/images/logos.png" /><span
+              >聚合智慧文档管理系统</span
+            >
           </div>
           <!-- TODO 搜索触发事件优化,跳转页面优化 -->
           <div class="search">
@@ -31,12 +33,19 @@
             >
               <div class="avatar-wrapper">
                 <img
-                  src="@/assets/images/profile.png"
+                  :src="
+                    userStore.avatar
+                      ? userStore.avatar
+                      : '@/assets/images/profile.png'
+                  "
                   class="head-img"
                 /><span>{{ logingName }}</span>
               </div>
               <template #dropdown>
                 <el-dropdown-menu>
+                  <router-link to="/user/profile">
+                    <el-dropdown-item>个人中心</el-dropdown-item>
+                  </router-link>
                   <el-dropdown-item divided command="logout">
                     <span>退出登录</span>
                   </el-dropdown-item>
@@ -53,9 +62,9 @@
               :to="item.path"
               v-for="(item, index) in menuList.data"
               :key="index"
-              @click="clickPath(index,item)"
+              @click="clickPath(index, item)"
               ><div
-              style="position: relative;"
+                style="position: relative"
                 :class="
                   $route.path == item.path
                     ? 'acitve-img-style img-style'
@@ -68,7 +77,14 @@
                 <div class="text-style" v-if="$route.path != item.path">
                   {{ item.label }}
                 </div>
-                <span class="yuandian" v-if="websoctStore.messOne?.fromId&&item.path == '/index'&& $route.path != item.path"></span>
+                <span
+                  class="yuandian"
+                  v-if="
+                    websoctStore.messOne?.fromId &&
+                    item.path == '/index' &&
+                    $route.path != item.path
+                  "
+                ></span>
               </div> </router-link
             ><br />
           </div>
@@ -268,7 +284,7 @@ const menuList = reactive({
     },
   ],
 });
-const clickPath = (index,items) => {
+const clickPath = (index, items) => {
   clickId.value = index;
 };
 </script>

+ 58 - 49
src/views/liveChat/index.vue

@@ -4,7 +4,7 @@ export default {
 };
 </script>
 <script setup>
-import { ref, reactive, toRaw, toRefs, nextTick } from "vue";
+import { ref, reactive, toRaw, toRefs, nextTick, computed } from "vue";
 import { useRouter, useRoute } from "vue-router";
 import useUserStore from "@/store/modules/user";
 import word from "@/assets/images/word2.png";
@@ -96,6 +96,16 @@ const getMsgList = async () => {
   }
 };
 const noMes = ref(false);
+const boottmScroll=()=>{
+//发送消息后滚动到最底部显示最新消息
+const chatContainer = document.querySelector(".right-container");
+  // 计算滚动的目标位置
+  const targetScrollTop = chatContainer.scrollHeight;
+  // 设置滚动位置
+  nextTick(() => {
+    chatContainer.scrollTop = targetScrollTop;
+  });
+}
 //获取用户的聊天记录
 const msgRecordEvent = async (toIdValue) => {
   const queryParams = {
@@ -107,23 +117,16 @@ const msgRecordEvent = async (toIdValue) => {
   chatRecords.data = resMsgData.rows.reverse();
   const PageNum = Math.ceil(chatRecords.data.length / 10) + 1;
   if (PageNum * 10 >= resMsgData.total && !noMes.value) {
-      loading.value = false;
-      noMes.value = true;
-    }
+    loading.value = false;
+    noMes.value = true;
+  }
   const nowtime = parseTime(new Date().getTime(), "{y}-{m}-{d}");
   chatRecords.data.map((i) => {
     if (nowtime == i.createTime.substr(0, 10))
       i.createTime = i.createTime.substring(11);
   });
   total.value = resMsgData.total;
-  //发送消息后滚动到最底部显示最新消息
-  const chatContainer = document.querySelector(".right-container");
-  // 计算滚动的目标位置
-  const targetScrollTop = chatContainer.scrollHeight;
-  // 设置滚动位置
-  nextTick(() => {
-    chatContainer.scrollTop = targetScrollTop;
-  });
+  boottmScroll()
 };
 //点击左侧新建聊天
 const open = ref(false);
@@ -230,12 +233,7 @@ const msgSendClick = (event) => {
       toId: sendCont.data.toId,
     };
     websoctStore.sendMessage(message);
-    //发送消息后滚动到最底部显示最新消息
-    const chatContainer = document.querySelector(".right-container");
-    // 计算滚动的目标位置
-    const targetScrollTop = chatContainer.scrollHeight;
-    // 设置滚动位置
-    chatContainer.scrollTop = targetScrollTop;
+    boottmScroll()
     event.preventDefault();
     messageText.value = "";
     //  将光标设置到输入框第一行
@@ -275,12 +273,17 @@ watchEffect(() => {
   }
 });
 // 滚动翻页========
-const mainContainer=ref(null)
+const mainContainer = ref(null);
 
 const handleScroll = (event) => {
   // 在滚动到顶部时,加载上一页的聊天记录
   const mainContainer2 = document.querySelector(".right-container");
-  console.log(' event.deltaY', mainContainer2.scrollTop,noMes.value,loading.value)
+  console.log(
+    " event.deltaY",
+    mainContainer2.scrollTop,
+    noMes.value,
+    loading.value
+  );
   if (
     event.deltaY < 0 &&
     mainContainer2.scrollTop <= 1 &&
@@ -298,29 +301,30 @@ const loadPreviousPage = async () => {
     pageSize: 10,
   };
   // setTimeout(async () => {
-    const resMsgData = await msgRecord(sendCont.data.toId, queryParams);
-    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) {
-      loading.value = false;
-      noMes.value = true;
-      return;
-    }
-    // await nextTick();
-    // const mainContainer = document.querySelector(".right-container");
-    // const newMessages = document.querySelectorAll(".message-container");
-    // const firstNewMessage = newMessages[previousPageData.length];
-  // const firstNewMessageTop = mainContainer.offsetHeight;
-  // console.log('firstNewMessageTop', firstNewMessageTop)
-  // mainContainer.scrollTop = firstNewMessageTop;
-    // 将加载的上一页聊天记录插入到 chatRecords.data 的前面
+  const resMsgData = await msgRecord(sendCont.data.toId, queryParams);
+  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) {
     loading.value = false;
+    noMes.value = true;
+    return;
+  }
+  //获取数据后滚动到获得新消息的最后一条,而不是第一条=========
+  await nextTick();
+  const mainContainer = document.querySelector(".right-container");
+  const newMessages = document.querySelectorAll(".message-container");
+  const firstNewMessage = newMessages[previousPageData.length];
+  const firstNewMessageTop = mainContainer.offsetHeight + 100;
+  mainContainer.scrollTop = firstNewMessageTop;chatRecords.data
+  //===========
+  // 将加载的上一页聊天记录插入到 chatRecords.data 的前面
+  loading.value = false;
   // }, 50);
 };
 const transferFiles = (forwardVal, msgIds, indexs) => {
@@ -366,7 +370,11 @@ 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();
@@ -426,15 +434,13 @@ onMounted(() => {
           删除聊天
         </button> -->
         <div>
-          <img :src="item.avatar ? item.avatar : chat" class="head-sculpture" />
+          <!-- <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>
         </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
@@ -508,7 +514,10 @@ onMounted(() => {
                   ></span>
                 </div>
               </div>
-              <img :src="chat" class="head-sculpture" />
+              <!-- 头像 -->
+              <!-- <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"

+ 10 - 7
src/views/myfile/MyFile.vue

@@ -230,10 +230,10 @@
             </div>
             <div v-else>
                 <div>
-                    <el-button @click="editOnline = true">返回</el-button>
+                    <el-button @click="editOnline = true;historyPrew=false">返回</el-button>
                 </div>
                 <FileEdit :docId="clickRowId" :copyRow="copyRow" :historyPrew="historyPrew"
-                    :historycopyRow="historycopyRow" :onlyView="onlyView"></FileEdit>
+                    :historycopyRow="historycopyRow" :onlyView="onlyView" @cancleHistoryPrew="cancleHistoryPrew"></FileEdit>
             </div>
             <!-- 扩容弹窗 -->
             <div>
@@ -533,11 +533,11 @@ export default {
             },
             {
                 img: ImgFile.addolder,
-                name: "移动",
+                name: "移动到...",
             },
             {
                 img: ImgFile.copy,
-                name: "复制",
+                name: "复制到...",
             },
             // {
             //     img: ImgFile.clipboard,
@@ -770,11 +770,11 @@ export default {
                     }
                 })
             }
-            if (row.name === '复制') {
+            if (row.name === '复制到...') {
                 copyOrMove.value = 0
                 fileTrees.value = true
             }
-            if (row.name === '移动') {
+            if (row.name === '移动到...') {
                 copyOrMove.value = 1
                 fileTrees.value = true
             }
@@ -838,7 +838,9 @@ export default {
             oneOrTwo.value = num
             folderCase.value = true
         }
-
+        function cancleHistoryPrew(val){
+            historyPrew.value=false
+        }
         function createNewFile() {
             addFile.value = true
         }
@@ -1318,6 +1320,7 @@ export default {
             thisFolder,
             folderRClick,
             closeRMenu,
+            cancleHistoryPrew,
             //历史版本=========
             fileUserTreeData,
             thanks,

+ 5 - 2
src/views/myfile/components/FileEdit.vue

@@ -7,7 +7,7 @@
 </template>
 
 <script>
-import { ref, onMounted, } from 'vue'
+import { ref, onMounted,defineEmits  } from 'vue'
 import jjtOnlyOffice from '@/components/OnlyOffice/index.vue'
 import useUserStore from '@/store/modules/user'
 // import ClassicEditor from '@ckeditor/ckeditor5-build-classic';
@@ -87,7 +87,10 @@ export default {
                     id: useUserStore().uid, //用户ID
                     name: useUserStore().uname //用户姓名
                 };
-                console.log(option.value,'option3===');
+                console.log('333333')
+                // const emit = defineEmits(["cancleHistoryPrew"]);
+                // emit("cancleHistoryPrew",false);
+                // console.log(option.value,'option3===');
             }
             
         }