diff --git a/apps/web-antd/src/layouts/basic.vue b/apps/web-antd/src/layouts/basic.vue index 2226c68a2..211ee7be3 100644 --- a/apps/web-antd/src/layouts/basic.vue +++ b/apps/web-antd/src/layouts/basic.vue @@ -147,6 +147,34 @@ function remove(id: number | string) { function handleMakeAll() { notifications.value.forEach((item) => (item.isRead = true)); } + +const viewAll = () => {}; + +const handleClick = (item: NotificationItem) => { + // 如果通知项有链接,点击时跳转 + if (item.link) { + navigateTo(item.link, item.query, item.state); + } +}; + +function navigateTo( + link: string, + query?: Record, + state?: Record, +) { + if (link.startsWith('http://') || link.startsWith('https://')) { + // 外部链接,在新标签页打开 + window.open(link, '_blank'); + } else { + // 内部路由链接,支持 query 参数和 state + router.push({ + path: link, + query: query || {}, + state, + }); + } +} + watch( () => ({ enable: preferences.app.watermark, @@ -189,6 +217,8 @@ watch( @read="(item) => item.id && markRead(item.id)" @remove="(item) => item.id && remove(item.id)" @make-all="handleMakeAll" + @on-click="handleClick" + @view-all="viewAll" />