安防大屏
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled

This commit is contained in:
2025-08-16 17:58:59 +08:00
parent 7edbeca307
commit 97dc93f3aa
14 changed files with 1027 additions and 56 deletions

View File

@@ -24,7 +24,7 @@ export const useNotifyStore = defineStore(
* return才会被持久化 存储全部消息
*/
const notificationList = ref<NotificationItem[]>([]);
const sseList = ref<string[]>(["111"]);
const userStore = useUserStore();
const userId = computed(() => {
return userStore.userInfo?.userId || '0';
@@ -65,24 +65,33 @@ export const useNotifyStore = defineStore(
if (!message) return;
console.log(`接收到消息: ${message}`);
notification.success({
description: message,
duration: 3,
message: $t('component.notice.received'),
});
try {
// 尝试解析JSON
const obj = JSON.parse(message);
// 检查解析结果是否为对象且不为null
if (obj.getType() ==="yvjin"){
sseList.value.join(message)
}
} catch (e) {
notification.success({
description: message,
duration: 3,
message: $t('component.notice.received'),
});
notificationList.value.unshift({
// avatar: `https://api.multiavatar.com/${random(0, 10_000)}.png`, 随机头像
avatar: SvgMessageUrl,
date: dayjs().format('YYYY-MM-DD HH:mm:ss'),
isRead: false,
message,
title: $t('component.notice.title'),
userId: userId.value,
});
notificationList.value.unshift({
// avatar: `https://api.multiavatar.com/${random(0, 10_000)}.png`, 随机头像
avatar: SvgMessageUrl,
date: dayjs().format('YYYY-MM-DD HH:mm:ss'),
isRead: false,
message,
title: $t('component.notice.title'),
userId: userId.value,
});
// 需要手动置空 vue3在值相同时不会触发watch
data.value = null;
// 需要手动置空 vue3在值相同时不会触发watch
data.value = null;
}
});
}
@@ -96,6 +105,10 @@ export const useNotifyStore = defineStore(
item.isRead = true;
});
}
function getsseList(){
console.log(sseList.value)
return sseList.value
}
/**
* 设置单条消息已读
@@ -134,6 +147,8 @@ export const useNotifyStore = defineStore(
$reset,
clearAllMessage,
notificationList,
sseList,
getsseList,
notifications,
setAllRead,
setRead,