阻止提及文本点击事件冒泡

This commit is contained in:
CrescentLeaf
2025-11-21 21:38:15 +08:00
parent d524304b29
commit b32f60d94d

View File

@@ -34,14 +34,16 @@ customElements.define('chat-mention', class extends HTMLElement {
if (chatId) { if (chatId) {
const chat = await DataCaches.getChatInfo(chatId) const chat = await DataCaches.getChatInfo(chatId)
this.link.textContent = chat?.title this.link.textContent = chat?.title
this.link.onclick = () => { this.link.onclick = (e) => {
e.stopPropagation()
// deno-lint-ignore no-window // deno-lint-ignore no-window
window.openChatInfoDialog(chat) window.openChatInfoDialog(chat)
} }
} else if (userId) { } else if (userId) {
const user = await DataCaches.getUserProfile(userId) const user = await DataCaches.getUserProfile(userId)
this.link.textContent = user?.nickname this.link.textContent = user?.nickname
this.link.onclick = () => { this.link.onclick = (e) => {
e.stopPropagation()
// deno-lint-ignore no-window // deno-lint-ignore no-window
window.openUserInfoDialog(user) window.openUserInfoDialog(user)
} }
@@ -51,7 +53,8 @@ customElements.define('chat-mention', class extends HTMLElement {
if (!(userId || chatId)) { if (!(userId || chatId)) {
this.link.textContent = "无效的提及" this.link.textContent = "无效的提及"
this.link.style.fontStyle = 'italic' this.link.style.fontStyle = 'italic'
this.link.onclick = () => { this.link.onclick = (e) => {
e.stopPropagation()
snackbar({ snackbar({
message: "该提及没有指定用户或者对话!", message: "该提及没有指定用户或者对话!",
placement: 'top', placement: 'top',