Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions plugins/cafe-notice/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 1.0.1 - 2026-11-12

### 修复

- 修复开启卡片通知后,卡片窗口的透明区域会挡住鼠标点击的问题:卡片窗默认整窗穿透,只有指针位于卡片上时才接收点击,卡片之间的间隙、内边距与圆角外的区域不再挡下方操作
- 修复卡片全部消失后仍残留一条透明窗(宽 380 高 8)常驻在角落挡点击的问题:无卡片时销毁卡片窗,来新通知时按需重建

## 1.0.0 - 2026-10-29

### 新增
Expand Down
5 changes: 4 additions & 1 deletion plugins/cafe-notice/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

## 更新日志

### v1.0.1 - 2026-11-12
- 修复卡片通知的透明区域挡住鼠标点击的问题:卡片窗默认整窗穿透,只有卡片区域接收点击,卡片间隙、内边距与无卡片时的空窗都不再挡下方操作

### v1.0.0 - 2026-10-29
- 首次发布:系统通知采集 + 弹幕/卡片双形态重展示、按应用配置与接管原生横幅、历史留存与导出

Expand All @@ -30,7 +33,7 @@

- **采集**:增量轮询 Windows 通知库(wpndatabase.db 三件套副本),不依赖包身份/WinRT 授权;通知仍保留在系统通知中心
- **弹幕**:速度、方向(左→右 / 右→左)、位置(上/中/下)、跨所有显示器连续飘屏、轨道数、字号、底色/透明度、边框、emoji 挂件;恒定速度 + 轨道占用调度,同轨不追尾
- **卡片**:显示器与四角位置、停留时长、宽度、同时上限(超出排队等位不丢弃)、底色/透明度;悬停暂停计时、点击展开完整正文、手动关闭
- **卡片**:显示器与四角位置、停留时长、宽度、同时上限(超出排队等位不丢弃)、底色/透明度;悬停暂停计时、点击展开完整正文、手动关闭;卡片窗默认穿透,只有卡片区域接收点击,不挡下方操作
- **内容**:应用名/时间开关、字体颜色(留空按底色自动反色)
- **按应用**:显示名、颜色、形态(弹幕+卡片/仅弹幕/仅卡片)、静音、接管原生横幅(写 ShowBanner=0,关闭开关即恢复原值)
- **应用名解析**:内置表 → 注册表 AppUserModelId DisplayName(覆盖 IntelliJ IDEA 等生成 AUMID)→ 推导兜底
Expand Down
2 changes: 1 addition & 1 deletion plugins/cafe-notice/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cafe-notice",
"version": "1.0.0",
"version": "1.0.1",
"description": "A ZTools plugin",
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion plugins/cafe-notice/src-ztools/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "通知美化(弹幕/卡片)",
"description": "把 Windows 系统通知重新展示为跨屏弹幕或角落卡片,支持按应用静音/接管原生横幅、历史留存与导出",
"author": "咖啡八杯",
"version": "1.0.0",
"version": "1.0.1",
"categories": ["productivity", "system"],
"main": "dist/index.html",
"preload": "preload/services.js",
Expand Down
52 changes: 50 additions & 2 deletions plugins/cafe-notice/src-ztools/preload/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ const overlayIds = new Set()
const messageListeners = []
let hostId = null
let lastPong = Date.now()
// 卡片窗是否处于「可点」状态(指针在卡片上);默认整窗穿透,避免透明区域挡住下方内容
let listHit = false

if (ipcRenderer) {
ipcRenderer.on(CHANNEL, (event, msg) => {
Expand Down Expand Up @@ -399,6 +401,7 @@ if (ipcRenderer) {
return
}
if (msg && msg.t === 'listHeight') applyListHeight(msg.h)
if (msg && msg.t === 'listHit') applyListHit(!!msg.on)
})
}

Expand Down Expand Up @@ -512,8 +515,15 @@ function createOverlay(mode) {
bornAt[mode] = Date.now()
pingAt[mode] = Date.now()
overlayIds.add(win.webContents.id)
if (mode === 'danmaku') win.setIgnoreMouseEvents(true)
if (mode === 'list') listReady = false
if (mode === 'danmaku') {
win.setIgnoreMouseEvents(true)
} else {
// 卡片窗整窗默认穿透,只有指针位于卡片上时才接收鼠标:
// 卡片间隙、内边距、圆角与阴影外都属于窗口矩形,不能挡住下方内容
listHit = false
win.setIgnoreMouseEvents(true, { forward: true })
listReady = false
}
return win
}

Expand All @@ -532,6 +542,7 @@ function destroyListWindow() {
overlayIdByMode.list = null
overlays.list = null
listReady = false
listHit = false
}

// 卡片窗按需创建、空闲销毁:省一个常驻渲染进程(约 60MB)
Expand Down Expand Up @@ -602,6 +613,28 @@ function applyListHeight(h) {
}
}

/**
* 开关卡片窗的点击接收:on=true 时整窗可点(指针在卡片上);
* on=false 时整窗穿透,且 forward:true 让窗口继续收到 mousemove,渲染器才能判断指针何时移回卡片。
*/
function applyListHit(on) {
const win = overlays.list
if (!win) return
try {
if (win.isDestroyed()) return
} catch (e) {
return
}
if (on === listHit) return
listHit = on
try {
if (on) win.setIgnoreMouseEvents(false)
else win.setIgnoreMouseEvents(true, { forward: true })
} catch (e) {
/* 窗已销毁 */
}
}

/** 同应用 mergeWindowMs 内第 mergeAfter+1 条起合并成「+N 条」;mergeAfter=0 关闭 */
const recentByApp = new Map()
function throttled(entry) {
Expand Down Expand Up @@ -631,6 +664,8 @@ function broadcast(entry) {
ensureListWindow()
}
for (const id of Array.from(overlayIds)) {
// 卡片窗还没 hello 时不再直发:该条已在 backlog 里,由 hello 补发,避免直发与补发各一次
if (modeById.get(id) === 'list' && !listReady) continue
try {
ipcRenderer.sendTo(id, CHANNEL, { t: 'notice', entry: payload })
} catch (e) {
Expand Down Expand Up @@ -866,6 +901,19 @@ window.services = {
}
applyListHeight(h)
},
setListClickable(on) {
// 同上:窗口句柄只在主窗的 preload 实例里
if (window.ztools.getWindowType() !== 'main') {
try {
if (hostId && ipcRenderer) ipcRenderer.sendTo(hostId, CHANNEL, { t: 'listHit', on: !!on })
else window.ztools.sendToParent(CHANNEL, { t: 'listHit', on: !!on })
} catch (e) {
/* 主窗缺席时保持整窗穿透,不挡下方内容 */
}
return
}
applyListHit(!!on)
},
setSuppressBanner,
ensureOverlays,
collectOnce: pollOnce,
Expand Down
60 changes: 57 additions & 3 deletions plugins/cafe-notice/src/Overlay/CardStack.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<script setup lang="ts">
import { nextTick, onUnmounted, ref } from 'vue'
import { nextTick, onMounted, onUnmounted, ref } from 'vue'

const props = defineProps<{ cfg: Record<string, string> }>()
const emit = defineEmits<{ (e: 'height', h: number): void }>()
const emit = defineEmits<{
(e: 'height', h: number): void
(e: 'clickable', on: boolean): void
}>()

interface Card {
key: number
Expand Down Expand Up @@ -44,6 +47,11 @@ function hhmm(ms: number) {

function reportHeight() {
nextTick(() => {
// 空列表上报 0:主窗据此销毁卡片窗,避免留一条透明窗挡住角落的点击
if (!cards.value.length) {
emit('height', 0)
return
}
emit('height', stack.value ? stack.value.offsetHeight : 0)
})
}
Expand Down Expand Up @@ -90,7 +98,53 @@ const timer = setInterval(() => {
if (cards.value.length !== before) reportHeight()
}, 200)

onUnmounted(() => clearInterval(timer))
// 卡片窗整窗默认穿透,只有指针位于卡片上时才让窗口接收鼠标:
// 卡片间隙(10px)、内边距(4px)、圆角与阴影外都属于窗口矩形,不能挡住下方内容
let overCard = false
let moveRaf = 0
let lastX = 0
let lastY = 0

function hitCard(x: number, y: number) {
const el = document.elementFromPoint(x, y) as HTMLElement | null
return !!(el && el.closest('.card'))
}

function setClickable(on: boolean) {
if (on === overCard) return
overCard = on
emit('clickable', on)
}

function onMove(e: MouseEvent) {
lastX = e.clientX
lastY = e.clientY
if (moveRaf) return
moveRaf = requestAnimationFrame(() => {
moveRaf = 0
setClickable(hitCard(lastX, lastY))
})
}

// 穿透状态下 mousemove 依赖宿主转发,未必每次都送达;用真实光标位置定时兜底,
// 这样卡片恰好出现在静止的指针下方时也能变成可点
const watchdog = setInterval(() => {
try {
const p = window.ztools.getCursorScreenPoint()
setClickable(hitCard(p.x - window.screenX, p.y - window.screenY))
} catch (e) {
/* 宿主不支持光标查询时只依赖 mousemove */
}
}, 500)

onMounted(() => window.addEventListener('mousemove', onMove, { passive: true }))

onUnmounted(() => {
clearInterval(timer)
clearInterval(watchdog)
window.removeEventListener('mousemove', onMove)
if (moveRaf) cancelAnimationFrame(moveRaf)
})

defineExpose({ push })
</script>
Expand Down
6 changes: 5 additions & 1 deletion plugins/cafe-notice/src/Overlay/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ function onHeight(h: number) {
notice().reportListHeight(h)
}

function onClickable(on: boolean) {
notice().setListClickable(on)
}

onMounted(() => {
notice().helloOverlay(mode)
setInterval(() => notice().pingOverlay(mode), 2000)
Expand All @@ -30,5 +34,5 @@ onMounted(() => {

<template>
<Danmaku v-if="mode === 'danmaku'" ref="danmaku" :cfg="cfg" />
<CardStack v-else ref="stack" :cfg="cfg" @height="onHeight" />
<CardStack v-else ref="stack" :cfg="cfg" @height="onHeight" @clickable="onClickable" />
</template>
2 changes: 2 additions & 0 deletions plugins/cafe-notice/src/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ declare global {
helloOverlay(mode: string): void
onMessage(fn: (entry: NoticeEntry) => void): void
reportListHeight(height: number): void
setListClickable(on: boolean): void
pingOverlay(mode: string): void
bumpOverlays(): void
ensureOverlays(): void
Expand All @@ -53,6 +54,7 @@ declare global {

interface Window {
services: Services
ztools: typeof ztools
}
}

Expand Down
Loading