|
@@ -19,11 +19,15 @@ import { useThemeConfig } from '@/stores/themeConfig';
|
|
|
import other from '@/utils/other';
|
|
|
import checkUpdate from '@/utils/checkUpdate';
|
|
|
import mittBus from '@/utils/mitt';
|
|
|
-import { Session, Local } from '@/utils/storage';
|
|
|
+import { Session, Local, Cookie } from '@/utils/storage';
|
|
|
import setIntroduction from '@/utils/setIconfont';
|
|
|
import { loginPageInfo } from '@/api/login';
|
|
|
import { getImageUrl } from '@/utils/tools';
|
|
|
import { useKeepALiveNames } from '@/stores/keepAliveNames';
|
|
|
+import { busyOff, dutyOff } from '@/api/public/wex';
|
|
|
+import { ola } from '@/utils/ola_api';
|
|
|
+import signalR from '@/utils/signalR';
|
|
|
+import { useTelStatus } from '@/stores/telStatus';
|
|
|
// 引入组件
|
|
|
const LockScreen = defineAsyncComponent(() => import('@/layout/lockScreen/index.vue'));
|
|
|
const SetTings = defineAsyncComponent(() => import('@/layout/navBars/breadcrumb/setings.vue'));
|
|
@@ -82,6 +86,35 @@ onBeforeMount(async () => {
|
|
|
// 设置批量第三方 js
|
|
|
setIntroduction.jsCdn();
|
|
|
});
|
|
|
+const logOut = () => {
|
|
|
+ if (telStatusInfo.value.isRest === 'resting') {
|
|
|
+ // 小休中 结束小休(调用业务系统接口,统计需要)
|
|
|
+ busyOff(); // 结束小休(调用业务系统接口,统计需要)
|
|
|
+ }
|
|
|
+ // 执行退出登录
|
|
|
+ dutyOff(); // 呼叫中心签出
|
|
|
+ ola.logout(); // 呼叫中心退出登录
|
|
|
+ ola.close(); // 呼叫中心关闭
|
|
|
+ signalR.leaveAllGroupAndStop(); // 退出所有组
|
|
|
+ // 重置所有状态
|
|
|
+ useTelStatusStore.resetState();
|
|
|
+ // 清除缓存/token等
|
|
|
+ Local.clear();
|
|
|
+ Session.clear();
|
|
|
+ Cookie.clear();
|
|
|
+};
|
|
|
+const beforeunloadHandler = (e: BeforeUnloadEvent) => {
|
|
|
+ // 用户关闭标签页或者浏览器时
|
|
|
+ e.preventDefault();
|
|
|
+ e.returnValue = '';
|
|
|
+ console.log('21321')
|
|
|
+};
|
|
|
+// 用户关闭标签页或者浏览器时
|
|
|
+const useTelStatusStore = useTelStatus();
|
|
|
+const { telStatusInfo } = storeToRefs(useTelStatusStore);
|
|
|
+const unloadHandler = async () => {
|
|
|
+ logOut();
|
|
|
+};
|
|
|
// 页面加载时
|
|
|
onMounted(() => {
|
|
|
nextTick(async () => {
|
|
@@ -122,6 +155,8 @@ onMounted(() => {
|
|
|
console.log(error);
|
|
|
}
|
|
|
});
|
|
|
+ window.addEventListener('beforeunload', (e) => beforeunloadHandler(e));
|
|
|
+ window.addEventListener('unload', (e) => unloadHandler);
|
|
|
});
|
|
|
// 清除缓存 name
|
|
|
const clearCacheTagsView = async (routeName: string) => {
|
|
@@ -139,6 +174,8 @@ const clearCacheTagsView = async (routeName: string) => {
|
|
|
onUnmounted(() => {
|
|
|
mittBus.off('openSetTingsDrawer', () => {});
|
|
|
mittBus.off('clearCache', () => {});
|
|
|
+ window.removeEventListener('beforeunload', (e) => beforeunloadHandler(e));
|
|
|
+ window.removeEventListener('unload', (e) => unloadHandler);
|
|
|
});
|
|
|
// 监听路由的变化,设置网站标题
|
|
|
watch(
|