优化Socket消息

This commit is contained in:
zjl 2024-12-19 09:33:30 +08:00
parent de591ede38
commit b61840fa9f
3 changed files with 34 additions and 27 deletions

View File

@ -19,11 +19,12 @@
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { useProjectSetting } from '@/hooks/setting/useProjectSetting'; import { useProjectSetting } from '@/hooks/setting/useProjectSetting';
import Watermark from '@/utils/wartermark'; import Watermark from '@/utils/wartermark';
import { initWebSocket,sendWebSocket } from '@/components/Websocket/index';
const GlobalWebsocket = defineAsyncComponent(() => import('@/components/Websocket/index.vue'));
import 'dayjs/locale/zh-cn'; import 'dayjs/locale/zh-cn';
dayjs.locale('zh-cn'); dayjs.locale('zh-cn');
/**
* 定义参数
*/
const route = useRoute(); const route = useRoute();
const locale = zhCN; const locale = zhCN;
const useLockscreen = useLockscreenStore(); const useLockscreen = useLockscreenStore();
@ -32,8 +33,12 @@
const isLock = computed(() => useLockscreen.isLock); const isLock = computed(() => useLockscreen.isLock);
const lockTime = computed(() => useLockscreen.lockTime); const lockTime = computed(() => useLockscreen.lockTime);
const { getIsWaterMark } = useProjectSetting(); const { getIsWaterMark } = useProjectSetting();
const GlobalWebsocket = defineAsyncComponent(() => import('@/components/Websocket/index.vue'));
let timer; let timer;
/**
* 定义锁屏
*/
const timekeeping = () => { const timekeeping = () => {
clearInterval(timer); clearInterval(timer);
if (route.name == 'login' || isLock.value) return; if (route.name == 'login' || isLock.value) return;
@ -51,19 +56,26 @@
} }
}, 1000); }, 1000);
}; };
/**
* 通知回调
*/
const rollback = (msg) => { const rollback = (msg) => {
notification.info({ notification.info({
message: '通知', message: '通知',
description: () => description: () => h('div', msg),
h('div', msg),
}); });
} };
/**
* 钩子函数
*/
onMounted(() => { onMounted(() => {
if (getIsWaterMark.value) { if (getIsWaterMark.value) {
const waterText = import.meta.env.VITE_GLOB_APP_TITLE; const waterText = import.meta.env.VITE_GLOB_APP_TITLE;
Watermark.set(waterText) Watermark.set(waterText);
} else { } else {
Watermark.del() Watermark.del();
} }
// document.addEventListener('mousedown', timekeeping); // document.addEventListener('mousedown', timekeeping);
}); });

View File

@ -139,7 +139,7 @@
DownloadOutlined, DownloadOutlined,
UploadOutlined, UploadOutlined,
PrinterOutlined, PrinterOutlined,
CommentOutlined CommentOutlined,
} from '@ant-design/icons-vue'; } from '@ant-design/icons-vue';
import { useForm } from '@/components/Form/index'; import { useForm } from '@/components/Form/index';
import { import {

View File

@ -1,10 +1,5 @@
<template> <template>
<a-modal <a-modal v-model:visible="props.visible" title="发送消息" width="800px" @cancel="dialogClose">
v-model:visible="props.visible"
title="发送消息"
width="800px"
@cancel="dialogClose"
>
<a-form :model="formData" :label-col="{ style: { width: '10-0px' } }" ref="formRef"> <a-form :model="formData" :label-col="{ style: { width: '10-0px' } }" ref="formRef">
<a-form-item <a-form-item
label="消息内容" label="消息内容"