Procházet zdrojové kódy

reactor:消息推送调试;

zhangchong před 10 měsíci
rodič
revize
e442c0625b

+ 2 - 4
src/App.vue

@@ -10,7 +10,7 @@
 </template>
 
 <script lang="ts" name="app" setup>
-import { computed, ref, onBeforeMount, onMounted, onUnmounted, nextTick, watch, reactive, defineAsyncComponent } from 'vue';
+import { computed, ref, onBeforeMount, onMounted, onBeforeUnmount, nextTick, watch, reactive, defineAsyncComponent } from 'vue';
 import { useRoute } from 'vue-router';
 import zhCn from 'element-plus/es/locale/lang/zh-cn';
 import { storeToRefs } from 'pinia';
@@ -24,8 +24,6 @@ import setIntroduction from '@/utils/setIconfont';
 import { loginPageInfo } from '@/api/login';
 import { getImageUrl } from '@/utils/tools';
 import { useKeepALiveNames } from '@/stores/keepAliveNames';
-import { ola } from '@/utils/ola_api';
-import signalR from '@/utils/signalR';
 import { useUserInfo } from '@/stores/userInfo';
 // 引入组件
 const LockScreen = defineAsyncComponent(() => import('@/layout/lockScreen/index.vue'));
@@ -145,7 +143,7 @@ const clearCacheTagsView = async (routeName: string) => {
 	if (item.meta?.isKeepAlive) await storesKeepALiveNames.addCachedView(item);
 };
 // 页面销毁时,关闭监听布局配置/i18n监听
-onUnmounted(() => {
+onBeforeUnmount(() => {
 	mittBus.off('openSetTingsDrawer', () => {});
 	mittBus.off('clearCache', () => {});
 	window.removeEventListener('unload', (e) => unloadHandler(e));

+ 2 - 2
src/layout/component/columnsAside.vue

@@ -47,7 +47,7 @@
 </template>
 
 <script lang="ts" name="layoutColumnsAside" setup>
-import { reactive, ref, onMounted, nextTick, watch, onUnmounted } from 'vue';
+import { reactive, ref, onMounted, nextTick, watch, onBeforeUnmount } from 'vue';
 import { useRoute, useRouter, onBeforeRouteUpdate } from 'vue-router';
 import { storeToRefs } from 'pinia';
 import pinia from '@/stores/index';
@@ -191,7 +191,7 @@ onMounted(() => {
 	});
 });
 // 页面卸载时
-onUnmounted(() => {
+onBeforeUnmount(() => {
 	mittBus.off('restoreDefault', () => {});
 });
 // 路由更新时

+ 2 - 2
src/layout/index.vue

@@ -3,7 +3,7 @@
 </template>
 
 <script setup lang="ts" name="layout">
-import { onBeforeMount, onUnmounted, defineAsyncComponent } from 'vue';
+import { onBeforeMount, onBeforeUnmount, defineAsyncComponent } from 'vue';
 import { storeToRefs } from 'pinia';
 import { useThemeConfig } from '@/stores/themeConfig';
 import { Local } from '@/utils/storage';
@@ -43,7 +43,7 @@ onBeforeMount(() => {
 	window.addEventListener('resize', onLayoutResize);
 });
 // 页面卸载时
-onUnmounted(() => {
+onBeforeUnmount(() => {
 	window.removeEventListener('resize', onLayoutResize);
 });
 </script>

+ 2 - 2
src/layout/lockScreen/index.vue

@@ -58,7 +58,7 @@
 </template>
 
 <script setup lang="ts" name="layoutLockScreen">
-import {nextTick, onMounted, onUnmounted, reactive, ref} from 'vue';
+import {nextTick, onMounted, onBeforeUnmount, reactive, ref} from 'vue';
 import {formatDate} from '@/utils/formatTime';
 import {Cookie, Local, Session} from '@/utils/storage';
 import {storeToRefs} from 'pinia';
@@ -214,7 +214,7 @@ onMounted(() => {
 	initLockScreen();
 });
 // 页面卸载时
-onUnmounted(() => {
+onBeforeUnmount(() => {
 	window.clearInterval(state.setIntervalTime);
 	window.clearInterval(state.isShowLockScreenIntervalTime);
 });

+ 2 - 2
src/layout/navBars/breadcrumb/index.vue

@@ -10,7 +10,7 @@
 </template>
 
 <script setup lang="ts" name="layoutBreadcrumbIndex">
-import { computed, reactive, onMounted, onUnmounted, defineAsyncComponent } from 'vue';
+import { computed, reactive, onMounted, onBeforeUnmount, defineAsyncComponent } from 'vue';
 import { useRoute } from 'vue-router';
 import { storeToRefs } from 'pinia';
 import { useRoutesList } from '@/stores/routesList';
@@ -105,7 +105,7 @@ onMounted(() => {
 	});
 });
 // 页面卸载时
-onUnmounted(() => {
+onBeforeUnmount(() => {
 	mittBus.off('getBreadcrumbIndexSetFilterRoutes', () => {});
 });
 </script>

+ 2 - 2
src/layout/navBars/breadcrumb/setings.vue

@@ -412,7 +412,7 @@
 </template>
 
 <script setup lang="ts" name="layoutBreadcrumbsetTing">
-import { nextTick, onUnmounted, onMounted, computed, reactive, ref } from 'vue';
+import { nextTick, onBeforeUnmount, onMounted, computed, reactive, ref } from 'vue';
 import { ElMessage } from 'element-plus';
 import { storeToRefs } from 'pinia';
 import { useThemeConfig } from '@/stores/themeConfig';
@@ -648,7 +648,7 @@ onMounted(() => {
 		}, 100);
 	});
 });
-onUnmounted(() => {
+onBeforeUnmount(() => {
 	mittBus.off('layoutMobileResize', () => { });
 });
 // 暴露变量

+ 6 - 6
src/layout/navBars/breadcrumb/telControl.vue

@@ -690,7 +690,7 @@ const removeTimerOnDuty = () => {
 };
 // 监听消息
 const signalRStart = async () => {
-	mittBus.on('RestApplyPass', (data) => {
+	signalR.SR.on('RestApplyPass', (data) => {
 		// 小休审批通过消息
 		console.log(data, '小休审批通过消息');
 		RestApplyPassFn(data);
@@ -2043,10 +2043,10 @@ onMounted(async () => {
 	await getTodayWaitNumFn(); // 查询今日等待数量
 	// 加入分组
 	await signalR.joinGroup('CallCenter');
-	mittBus.on('ToDayWaitNum', (data: number) => {
+  signalR.SR.on('ToDayWaitNum', (data: number) => {
 		todayWait.value = data;
 	});
-	mittBus.on('CurrentWaitNum', (data: number) => {
+  signalR.SR.on('CurrentWaitNum', (data: number) => {
 		currentWait.value = data;
 	});
 });
@@ -2058,9 +2058,9 @@ watch(
 	{ immediate: true }
 );
 onBeforeUnmount(() => {
-	mittBus.off('RestApplyPass');
-	mittBus.off('ToDayWaitNum');
-	mittBus.off('CurrentWaitNum');
+  signalR.SR.off('RestApplyPass');
+  signalR.SR.off('ToDayWaitNum');
+  signalR.SR.off('CurrentWaitNum');
 	if (ola.ws) ola.close();
 });
 </script>

+ 4 - 4
src/layout/navBars/breadcrumb/user.vue

@@ -153,7 +153,7 @@
 </template>
 
 <script setup lang="ts" name="layoutBreadcrumbUser">
-import { defineAsyncComponent, ref, computed, reactive, onMounted, onUnmounted } from 'vue';
+import { defineAsyncComponent, ref, computed, reactive, onMounted, onUnmounted } from "vue";
 import { useRouter } from 'vue-router';
 import { ElMessageBox, ElMessage, ElNotification, FormInstance } from 'element-plus';
 import screenfull from 'screenfull';
@@ -478,15 +478,15 @@ onMounted(() => {
 	if (Local.get('themeConfig')) {
 		initComponentSize();
 	}
-	getNumAndList();
-	mittBus.on('CircularRecord', (data) => {
+	signalR.SR.on('CircularRecord', (data) => {
 		// 小红点数量消息通知
 		console.log(data, '小红点数量消息通知');
 		getNumAndList();
 	});
+	getNumAndList();
 });
 onUnmounted(() => {
-	mittBus.off('CircularRecord');
+  signalR.SR.off('CircularRecord');
 });
 </script>
 

+ 9 - 11
src/layout/navBars/breadcrumb/userNews.vue

@@ -20,12 +20,10 @@
 </template>
 
 <script setup lang="ts" name="layoutBreadcrumbUserNews">
-import { onMounted, onUnmounted, reactive } from 'vue';
+import { onMounted, reactive } from "vue";
 import { useRouter } from 'vue-router';
 import { muquery } from '@/api/auxiliary/notice';
 import dayjs from 'dayjs';
-import { ElMessage } from 'element-plus';
-import mittBus from '@/utils/mitt';
 
 const emit = defineEmits(['hideNws']);
 
@@ -61,15 +59,15 @@ const linkNews = (v: any) => {
 };
 onMounted(() => {
 	getNumAndList();
-	mittBus.on('CircularRecord', (data) => {
-		// 小红点数量消息通知
-		console.log(data, '小红点数量消息通知');
-		getNumAndList();
-	});
-});
-onUnmounted(() => {
-	mittBus.off('CircularRecord');
+  // signalR.SR.on('CircularRecord', (data) => {
+  //   // 小红点数量消息通知
+  //   console.log(data, '小红点数量消息通知');
+  //   getNumAndList();
+  // });
 });
+// onUnmounted(() => {
+//   signalR.SR.off('CircularRecord');
+// });
 </script>
 
 <style lang="scss" scoped>

+ 2 - 2
src/layout/navBars/tagsView/contextmenu.vue

@@ -18,7 +18,7 @@
 </template>
 
 <script setup lang="ts" name="layoutTagsViewContextmenu">
-import { computed, reactive, onMounted, onUnmounted, watch } from 'vue';
+import { computed, reactive, onMounted, onBeforeUnmount, watch } from 'vue';
 
 // 定义父组件传过来的值
 const props = defineProps({
@@ -83,7 +83,7 @@ onMounted(() => {
 	document.body.addEventListener('click', closeContextmenu);
 });
 // 页面卸载时,移除右键菜单监听事件
-onUnmounted(() => {
+onBeforeUnmount(() => {
 	document.body.removeEventListener('click', closeContextmenu);
 });
 // 监听下拉菜单位置

+ 2 - 2
src/layout/navBars/tagsView/tagsView.vue

@@ -50,7 +50,7 @@
 </template>
 
 <script setup lang="ts" name="layoutTagsView">
-import { defineAsyncComponent, reactive, onMounted, computed, ref, nextTick, onBeforeUpdate, onBeforeMount, onUnmounted, watch } from 'vue';
+import { defineAsyncComponent, reactive, onMounted, computed, ref, nextTick, onBeforeUpdate, onBeforeMount, onBeforeUnmount, watch } from 'vue';
 import { useRoute, useRouter, onBeforeRouteUpdate } from 'vue-router';
 import Sortable from 'sortablejs';
 import { ElMessage } from 'element-plus';
@@ -568,7 +568,7 @@ onBeforeMount(() => {
 	});
 });
 // 页面卸载时
-onUnmounted(() => {
+onBeforeUnmount(() => {
 	// 取消非本页面调用监听
 	mittBus.off('onCurrentContextmenuClick', () => {});
 	// 取消监听布局配置界面开启/关闭拖拽

+ 2 - 2
src/layout/routerView/parent.vue

@@ -14,7 +14,7 @@
 </template>
 
 <script setup lang="ts" name="layoutParentView">
-import { defineAsyncComponent, computed, reactive, onBeforeMount, onUnmounted, nextTick, watch, onMounted } from 'vue';
+import { defineAsyncComponent, computed, reactive, onBeforeMount, nextTick, watch, onMounted,onBeforeUnmount } from 'vue';
 import { useRoute, useRouter } from 'vue-router';
 import { storeToRefs } from 'pinia';
 import { useKeepALiveNames } from '@/stores/keepAliveNames';
@@ -91,7 +91,7 @@ onMounted(() => {
   });
 });
 // 页面卸载时
-onUnmounted(() => {
+onBeforeUnmount(() => {
   mittBus.off('onTagsViewRefreshRouterView', () => {});
 });
 // 监听路由变化,防止 tagsView 多标签时,切换动画消失

+ 10 - 22
src/utils/signalR.ts

@@ -38,44 +38,32 @@ export default {
 		});
 		// 服务端推送消息
 		connection.on('CircularRecord', (message: any) => {
-			mittBus.emit('CircularRecord', message); // 小红点消息
+			console.log(`小红点消息:${message}`);
 		});
 		// 服务端推送消息
 		connection.on('SeatState', (message: any) => {
-			mittBus.emit('SeatState', message); // 坐席状态
+			console.log(`座席状态:${message}`);
 		});
 		// 服务端推送消息
 		connection.on('RestApplyPass', (message: any) => {
-			mittBus.emit('RestApplyPass', message); // 小休审批消息
+			console.log(`休息申请通过:${message}`);
 		});
 		// 服务端推送消息
 		connection.on('ToDayWaitNum', (message: any) => {
-			mittBus.emit('ToDayWaitNum', message); // 今日等待
+			// console.log(`今日等待:${message}`);
 		});
 		// 服务端推送消息
 		connection.on('CurrentWaitNum', (message: any) => {
-			mittBus.emit('CurrentWaitNum', message); // 当前等待
+			// console.log(`当前等待:${message}`);
 		});
 		// 服务端推送消息
-		connection.on('RestApplyPass', (message: any) => {
-			mittBus.emit('RestApplyPass', message); // 小休审批消息
-		});
+		connection.on('BsSeatStateDataShowArea1', (message: any) => {});
 		// 服务端推送消息
-		connection.on('BsSeatStateDataShowArea1', (message: any) => {
-
-		});
+		connection.on('BsSeatStateDataShowArea2', (message: any) => {});
 		// 服务端推送消息
-		connection.on('BsSeatStateDataShowArea2', (message: any) => {
-
-		});
+		connection.on('BsSeatStateDataShowArea3', (message: any) => {});
 		// 服务端推送消息
-		connection.on('BsSeatStateDataShowArea3', (message: any) => {
-
-		});
-		// 服务端推送消息
-		connection.on('BsSeatStateDataShowArea4', (message: any) => {
-
-		});
+		connection.on('BsSeatStateDataShowArea4', (message: any) => {});
 	},
 	/**
 	 * @description 调用 this.signalR.start().then(async () => { await this.SR.invoke("method")})
@@ -195,4 +183,4 @@ export default {
 			console.log('signalR', error);
 		}
 	},
-};
+};

+ 0 - 1
src/views/system/organize/component/Org-edit.vue

@@ -71,7 +71,6 @@
 import { reactive, ref } from 'vue';
 import { ElMessage, FormInstance } from 'element-plus';
 import mittBus from '@/utils/mitt';
-import { auth } from '@/utils/authFunction';
 import { excludeSelfById } from '@/utils/tools';
 import other from '@/utils/other';
 import { getOrgById, updateOrg } from '@/api/system/organize';

+ 4 - 5
src/views/tels/extension/index.vue

@@ -84,7 +84,7 @@
 </template>
 
 <script lang="tsx" setup name="telsExtension">
-import { computed, onMounted, onUnmounted, reactive, ref } from 'vue';
+import { computed, onMounted, reactive, ref,onBeforeUnmount } from 'vue';
 import type { FormInstance } from 'element-plus';
 import { ElMessage, ElMessageBox } from 'element-plus';
 import signalR from '@/utils/signalR';
@@ -92,7 +92,6 @@ import { ola } from '@/utils/ola_api';
 import { storeToRefs } from 'pinia';
 import { useTelStatus } from '@/stores/telStatus';
 import { extensionPaged, forceLogout } from '@/api/tels/extension';
-import mittBus from '@/utils/mitt';
 
 const proTableRef = ref<RefType>(); // 表格ref
 // 表格配置项
@@ -212,7 +211,7 @@ const onOffline = (row: any) => {
 onMounted(() => {
 	queryList();
 	signalR.joinGroup('BigScreen-SeatState');
-	mittBus.on('SeatState', (data) => {
+  signalR.SR.on('SeatState', (data) => {
 		const item = state.tableList.find((item: any) => item.telNo === data.telNo);
 		if (item) {
 			item.state = data.state;
@@ -220,8 +219,8 @@ onMounted(() => {
 		search();
 	});
 });
-onUnmounted(() => {
-	mittBus.off('SeatState');
+onBeforeUnmount(() => {
+  signalR.SR.off('SeatState');
 });
 </script>
 <style lang="scss" scoped>

+ 0 - 1
src/views/todo/seats/index.vue

@@ -117,7 +117,6 @@ import { downloadFileByStream, downloadZip } from '@/utils/tools';
 import { exportJbOrder, exportOrder } from '@/api/business/order';
 import { defaultDateThree, defaultTimeStartEnd, shortcuts } from "@/utils/constants";
 import Other from '@/utils/other';
-import mittBus from "@/utils/mitt";
 // 引入组件
 const OrderDetail = defineAsyncComponent(() => import('@/components/OrderDetail/index.vue')); // 工单详情
 // 定义变量内容