refactor(web): 注释通知相关代码并添加临时注释说明
注释右上角通知铃铛及实时推送相关代码,添加说明后续恢复时取消注释
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
.DS_Store
|
||||
node_modules
|
||||
.pnpm-store
|
||||
/screenshots
|
||||
/dist
|
||||
dist.zip
|
||||
|
||||
@@ -196,7 +196,7 @@
|
||||
ref,
|
||||
computed,
|
||||
unref,
|
||||
watch,
|
||||
// watch, // 随右上角弹窗推送暂时注释
|
||||
h,
|
||||
onMounted,
|
||||
} from 'vue';
|
||||
@@ -206,12 +206,12 @@
|
||||
NDialogProvider,
|
||||
useDialog,
|
||||
useMessage,
|
||||
NAvatar,
|
||||
NTag,
|
||||
// NAvatar, // 随右上角弹窗推送暂时注释
|
||||
// NTag,
|
||||
// useNotification,
|
||||
// NotificationReactive,
|
||||
// NButton,
|
||||
NIcon,
|
||||
useNotification,
|
||||
NotificationReactive,
|
||||
NButton,
|
||||
NText,
|
||||
} from 'naive-ui';
|
||||
import { TABS_ROUTES } from '@/store/mutation-types';
|
||||
@@ -223,7 +223,7 @@
|
||||
import { NotificationsOutline as NotificationsIcon } from '@vicons/ionicons5';
|
||||
import SystemMessage from './SystemMessage.vue';
|
||||
import { notificationStoreWidthOut } from '@/store/modules/notification';
|
||||
import { getIcon } from '@/enums/systemMessageEnum';
|
||||
// import { getIcon } from '@/enums/systemMessageEnum'; // 随右上角弹窗推送暂时注释
|
||||
import { availableLocales, useI18nStore } from '@/store/modules/i18n';
|
||||
import Search from './Search.vue';
|
||||
|
||||
@@ -392,10 +392,10 @@
|
||||
click: () => window.open('https://github.com/bufanyun/hotgo'),
|
||||
},
|
||||
},
|
||||
{
|
||||
icon: 'BellOutlined',
|
||||
tips: '我的消息',
|
||||
},
|
||||
// {
|
||||
// icon: 'BellOutlined',
|
||||
// tips: '我的消息',
|
||||
// },
|
||||
{
|
||||
icon: 'LockOutlined',
|
||||
tips: '锁屏',
|
||||
@@ -470,88 +470,90 @@
|
||||
openDrawer();
|
||||
}
|
||||
|
||||
const notification = useNotification();
|
||||
const getMessages = computed(() => {
|
||||
return notificationStore.newMessage;
|
||||
});
|
||||
const nRef = ref<NotificationReactive | null>(null);
|
||||
// 通知铃铛已暂时隐藏,暂停右上角实时弹窗推送;后续恢复时取消注释(连同下方 import)
|
||||
// const notification = useNotification();
|
||||
// const getMessages = computed(() => {
|
||||
// return notificationStore.newMessage;
|
||||
// });
|
||||
// const nRef = ref<NotificationReactive | null>(null);
|
||||
// 监听新消息,推送通知
|
||||
watch(
|
||||
getMessages,
|
||||
(newVal, _oldVal) => {
|
||||
if (newVal === null || newVal === undefined) {
|
||||
return;
|
||||
}
|
||||
// watch(
|
||||
// getMessages,
|
||||
// (newVal, _oldVal) => {
|
||||
// if (newVal === null || newVal === undefined) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
nRef.value = notification.create({
|
||||
title: newVal.title,
|
||||
description:
|
||||
newVal.tagTitle === '' || newVal.tagTitle === undefined
|
||||
? undefined
|
||||
: () =>
|
||||
h(
|
||||
NTag,
|
||||
{
|
||||
style: {
|
||||
marginRight: '6px',
|
||||
},
|
||||
type: newVal.tagProps?.type,
|
||||
bordered: false,
|
||||
},
|
||||
{
|
||||
default: () => newVal.tagTitle,
|
||||
}
|
||||
),
|
||||
// nRef.value = notification.create({
|
||||
// title: newVal.title,
|
||||
// description:
|
||||
// newVal.tagTitle === '' || newVal.tagTitle === undefined
|
||||
// ? undefined
|
||||
// : () =>
|
||||
// h(
|
||||
// NTag,
|
||||
// {
|
||||
// style: {
|
||||
// marginRight: '6px',
|
||||
// },
|
||||
// type: newVal.tagProps?.type,
|
||||
// bordered: false,
|
||||
// },
|
||||
// {
|
||||
// default: () => newVal.tagTitle,
|
||||
// }
|
||||
// ),
|
||||
|
||||
content: () =>
|
||||
newVal.content === '' || newVal.content === undefined
|
||||
? undefined
|
||||
: h('div', { innerHTML: '<div>' + newVal.content + '</div>' }),
|
||||
meta: newVal.createdAt,
|
||||
avatar: () =>
|
||||
newVal.senderAvatar !== '' || newVal.senderAvatar === undefined
|
||||
? h(NAvatar, {
|
||||
size: 'small',
|
||||
round: true,
|
||||
src: newVal.senderAvatar,
|
||||
})
|
||||
: h(NIcon, null, { default: () => h(getIcon(newVal)) }),
|
||||
action: () =>
|
||||
h(
|
||||
NButton,
|
||||
{
|
||||
text: true,
|
||||
type: 'info',
|
||||
onClick: () => {
|
||||
(nRef.value as NotificationReactive).destroy();
|
||||
router.push({
|
||||
name: 'home_message',
|
||||
query: {
|
||||
type: newVal.type,
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
default: () => '查看详情',
|
||||
}
|
||||
),
|
||||
onClose: () => {
|
||||
nRef.value = null;
|
||||
},
|
||||
});
|
||||
},
|
||||
{ immediate: true, deep: true }
|
||||
);
|
||||
// content: () =>
|
||||
// newVal.content === '' || newVal.content === undefined
|
||||
// ? undefined
|
||||
// : h('div', { innerHTML: '<div>' + newVal.content + '</div>' }),
|
||||
// meta: newVal.createdAt,
|
||||
// avatar: () =>
|
||||
// newVal.senderAvatar !== '' || newVal.senderAvatar === undefined
|
||||
// ? h(NAvatar, {
|
||||
// size: 'small',
|
||||
// round: true,
|
||||
// src: newVal.senderAvatar,
|
||||
// })
|
||||
// : h(NIcon, null, { default: () => h(getIcon(newVal)) }),
|
||||
// action: () =>
|
||||
// h(
|
||||
// NButton,
|
||||
// {
|
||||
// text: true,
|
||||
// type: 'info',
|
||||
// onClick: () => {
|
||||
// (nRef.value as NotificationReactive).destroy();
|
||||
// router.push({
|
||||
// name: 'home_message',
|
||||
// query: {
|
||||
// type: newVal.type,
|
||||
// },
|
||||
// });
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// default: () => '查看详情',
|
||||
// }
|
||||
// ),
|
||||
// onClose: () => {
|
||||
// nRef.value = null;
|
||||
// },
|
||||
// });
|
||||
// },
|
||||
// { immediate: true, deep: true }
|
||||
// );
|
||||
|
||||
const updateMenu = () => {
|
||||
emit('update:collapsed', !props.collapsed);
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
if (notificationStore.getUnreadCount() === 0) {
|
||||
notificationStore.pullMessages();
|
||||
}
|
||||
// 通知铃铛已暂时隐藏,暂停首屏未读拉取;后续恢复铃铛时取消注释
|
||||
// if (notificationStore.getUnreadCount() === 0) {
|
||||
// notificationStore.pullMessages();
|
||||
// }
|
||||
});
|
||||
return {
|
||||
...toRefs(state),
|
||||
|
||||
Reference in New Issue
Block a user