Forráskód Böngészése

聊天加载,和系统管理路由

“yueshang” 2 éve
szülő
commit
763f5b32be

+ 8 - 0
src/layout/indexCommon.vue

@@ -91,6 +91,8 @@ import zuijin from "@/assets/images/zuijin.png";
 import bezuijin from "@/assets/images/bezuijin.png";
 import colloect from "@/assets/images/colloect.png";
 import becolloect from "@/assets/images/becolloect.png";
+import system from "@/assets/images/system.png";
+import issystem from "@/assets/images/issystem.png";
 import my from "@/assets/images/my.png";
 import bemy from "@/assets/images/bemy.png";
 import bumen from "@/assets/images/bumen.png";
@@ -253,6 +255,12 @@ const menuList = reactive({
       imgs: chuanshu,
       beimgs: bechuanshu,
     },
+    {
+      label: "系统管理",
+      path: "/admin",
+      imgs: system,
+      beimgs: issystem,
+    },
   ],
 });
 

+ 15 - 0
src/router/index.js

@@ -149,6 +149,21 @@ export const constantRoutes = [{
 				component: () => import("@/views/highSearch/SupplierAllBack.vue"),
 				name: "allback",
 				meta: { title: "kongbaiye", icon: "department" }
+			  },{
+				path: "/admin",
+				component: Layout,
+				redirect: '/admin/index',
+				children: [{
+					path: 'index',
+					// component: () => import('@/layout/index.vue'),
+					name: 'adminIndex',
+					meta: {
+						title: '首页',
+						icon: 'dashboard',
+						affix: true
+					},
+	
+				},]
 			  }
 		]
 	},

+ 1 - 1
src/store/modules/websocket.js

@@ -23,7 +23,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)

+ 12 - 10
src/views/liveChat/index.vue

@@ -38,6 +38,7 @@ const openFile = ref(false); //文件目录
 const openForwardFile = ref(false); //转发目录
 const showCircel=ref('')  //是否 显示圆点
 const chatRecords = reactive({ data: [] });
+const loading = ref(false)
 const sendCont = reactive({
   //发送聊天内容数据组装
   data: {
@@ -194,9 +195,6 @@ const handleNewMessage = () => {
 };
 watchEffect(() => {
   if (websoctStore.messOne?.fromId) {
-    if(websoctStore.messOne.fromId==personList.data[0]?.fromId){
-      showCircel.value=websoctStore.messOne.fromId
-    }
     msgRecordEvent(websoctStore.messOne.fromId);
   }
 });
@@ -205,7 +203,8 @@ const noMes = ref(false);
 const handleScroll = (event) => {
   // 在滚动到顶部时,加载上一页的聊天记录
   const mainContainer = document.querySelector(".right-container");
-  if (event.deltaY < 0 && mainContainer.scrollTop <= 1) {
+  if (event.deltaY < 0 && mainContainer.scrollTop <= 1&&!noMes.value) {
+    loading.value=true
     loadPreviousPage();
   }
 };
@@ -216,10 +215,12 @@ const loadPreviousPage = async () => {
     pageSize: 10,
   };
   const resMsgData = await msgRecord(sendCont.data.toId, queryParams);
+  loading.value=false
   const previousPageData = resMsgData.rows.reverse();
   if (currentPageNum * 10 >= resMsgData.total && !noMes.value) {
-    noMes.value = true;
-    return ElMessage("无更多聊天记录");
+    return noMes.value = true;
+
+    // return ElMessage("无更多聊天记录");
   }
   // 将加载的上一页聊天记录插入到 chatRecords.data 的前面
   chatRecords.data = [...previousPageData, ...chatRecords.data];
@@ -276,8 +277,7 @@ onMounted(() => {
           @change="SearchChat"
         />
         <!-- 添加聊天人员 -->
-        <el-icon size="24" color="#505870" @click="clickNewPerson"
-          ><Plus
+        <el-icon size="24" color="#505870" @click="clickNewPerson" style=" margin-right: 8px;"><Plus
         /></el-icon>
         <!-- 新建聊天弹框 -->
         <Addperson
@@ -318,10 +318,10 @@ onMounted(() => {
               : item.toName
           }}</span
           ><span class="person-cont spill">
-            {{ item.cont ? item.cont : item.content }}</span
+            {{ item.file?.fileName ? item.file?.fileName : item.content }}</span
           >
         </div>
-        <span class="yuandian" v-if="showCircel==item.fromId&&$route.path=='/index'"></span>
+        <!-- <span class="yuandian" v-if="showCircel==item.fromId&&$route.path=='/index'"></span> -->
       </div>
     </div>
     <!-- 右侧聊天 -->
@@ -340,6 +340,8 @@ onMounted(() => {
             @mousewheel="handleScroll"
             ref="mainContainer"
           >
+            <div  v-loading="loading"></div>
+            <!-- <div v-if="noMes" style="color:#9fa1a5 ;">无更多聊天记录</div> -->
             <div
               class="message-container"
               v-for="(record, index) in chatRecords.data"

+ 2 - 2
vite.config.js

@@ -47,8 +47,8 @@ export default defineConfig(({
 				},
 				//websocket代理
 				'/websocket': {				
-					target:'ws://8.142.173.95:19527/websocket',
-					// target:'ws://192.168.1.18:8080/websocket',
+					// target:'ws://8.142.173.95:19527/websocket',
+					target:'ws://192.168.1.28:8080/websocket',
 					changeOrigin: true,
 					rewrite: (p) => p.replace(/^\/websocket/, '')
 				}