优化消息通知

This commit is contained in:
zjl 2024-12-19 10:24:08 +08:00
parent 2f4dcd0a09
commit 03856c123a
2 changed files with 34 additions and 16 deletions

View File

@ -20,18 +20,21 @@
import { useProjectSetting } from '@/hooks/setting/useProjectSetting'; import { useProjectSetting } from '@/hooks/setting/useProjectSetting';
import Watermark from '@/utils/wartermark'; import Watermark from '@/utils/wartermark';
/**
* 定义参数
*/
const route = useRoute(); const route = useRoute();
const useLockscreen = useLockscreenStore(); const useLockscreen = useLockscreenStore();
const isLock = computed(() => useLockscreen.isLock); const isLock = computed(() => useLockscreen.isLock);
const lockTime = computed(() => useLockscreen.lockTime); const lockTime = computed(() => useLockscreen.lockTime);
const zIndex = ref(3000); const zIndex = ref(3000);
const { getIsWaterMark } = useProjectSetting(); const { getIsWaterMark } = useProjectSetting();
const LoginName = PageEnum.BASE_LOGIN_NAME; const LoginName = PageEnum.BASE_LOGIN_NAME;
let timer; let timer;
/**
* 定义锁屏
*/
const timekeeping = () => { const timekeeping = () => {
clearInterval(timer); clearInterval(timer);
if (route.name === LoginName || isLock.value) return; if (route.name === LoginName || isLock.value) return;
@ -49,6 +52,10 @@
} }
}, 1000); }, 1000);
}; };
/**
* 钩子函数
*/
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;

View File

@ -74,6 +74,7 @@
</el-icon> </el-icon>
</div> </div>
</template> </template>
<!-- 全局WebSocket通讯组件 -->
<global-websocket :uri="'/api/websocket/' + userInfo.id" @rollback="rollback" /> <global-websocket :uri="'/api/websocket/' + userInfo.id" @rollback="rollback" />
</template> </template>
@ -95,9 +96,11 @@
import { useDesignSettingStore } from '@/store/modules/designSetting'; import { useDesignSettingStore } from '@/store/modules/designSetting';
import { SettingOutlined } from '@vicons/antd'; import { SettingOutlined } from '@vicons/antd';
import Sider from './components/Sider/Sider.vue'; import Sider from './components/Sider/Sider.vue';
import { initWebSocket,sendWebSocket } from '@/components/Websocket/index';
const GlobalWebsocket = defineAsyncComponent(() => import('@/components/Websocket/index.vue'));
/**
* 定义参数
*/
const GlobalWebsocket = defineAsyncComponent(() => import('@/components/Websocket/index.vue'));
const { getDarkTheme } = useDesignSetting(); const { getDarkTheme } = useDesignSetting();
const { const {
getNavMode, getNavMode,
@ -109,16 +112,12 @@
getMultiTabsSetting, getMultiTabsSetting,
getIsProjectSetting, getIsProjectSetting,
} = useProjectSetting(); } = useProjectSetting();
const settingStore = useProjectSettingStore(); const settingStore = useProjectSettingStore();
const designStore = useDesignSettingStore(); const designStore = useDesignSettingStore();
const navMode = getNavMode; const navMode = getNavMode;
const drawerSetting = ref(); const drawerSetting = ref();
const collapsed = ref<boolean>(false); const collapsed = ref<boolean>(false);
const adminBodyRef = ref<HTMLElement | null>(null); const adminBodyRef = ref<HTMLElement | null>(null);
const { isFullscreen, toggle } = useFullscreen(adminBodyRef); const { isFullscreen, toggle } = useFullscreen(adminBodyRef);
const userStore = useUserStore(); const userStore = useUserStore();
const userInfo: object = userStore.getUserInfo || {}; const userInfo: object = userStore.getUserInfo || {};
@ -127,6 +126,9 @@
provide('collapsed', collapsed); provide('collapsed', collapsed);
provide('openSetting', openSetting); provide('openSetting', openSetting);
/**
* 侦听器
*/
watch( watch(
() => collapsed.value, () => collapsed.value,
(to) => { (to) => {
@ -230,6 +232,11 @@
collapsed.value = true; collapsed.value = true;
} }
}; };
/**
* 消息通知回调
* @param msg 消息
*/
const rollback = (msg) => { const rollback = (msg) => {
ElNotification({ ElNotification({
type: 'info', type: 'info',
@ -237,7 +244,11 @@
message: h('div', msg), message: h('div', msg),
duration: 5000, duration: 5000,
}); });
} };
/**
* 钩子函数
*/
onMounted(() => { onMounted(() => {
const { themeColorChange } = drawerSetting.value; const { themeColorChange } = drawerSetting.value;
themeColorChange('#165DFF'); themeColorChange('#165DFF');
@ -436,7 +447,7 @@
.el-menu { .el-menu {
--el-menu-bg-color: #fff; --el-menu-bg-color: #fff;
--el-menu-text-color: rgb(51, 54, 57); --el-menu-text-color: rgb(51, 54, 57);
--el-menu-hover-bg-color: #165DFF; --el-menu-hover-bg-color: #165dff;
--el-menu-hover-text-color: #fff; --el-menu-hover-text-color: #fff;
} }
} }