From f7ac8ec6bc8b343c377e4ffd7c635e66f9a2868c Mon Sep 17 00:00:00 2001 From: linyuchen Date: Thu, 2 Nov 2023 17:44:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=BE=A4=E6=88=90=E5=91=98?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/global.d.ts | 2 +- src/renderer.ts | 43 ++++++++++++++++++++++++++++--------------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/global.d.ts b/src/global.d.ts index c5eb14b..76301a4 100644 --- a/src/global.d.ts +++ b/src/global.d.ts @@ -17,7 +17,7 @@ declare var LLAPI: { getFriendsList(forced: boolean): Promise getGroupMemberList(group_id: string, num: number): Promise<{result: { infos: Map }}> getPeer(): Promise - add_qmenu(func: (qContextMenu: {insertAdjacentHTML: (location: string, ele: string)=>void})=>void): void + add_qmenu(func: (qContextMenu: Node)=>void): void }; diff --git a/src/renderer.ts b/src/renderer.ts index 55d09bb..139bee3 100644 --- a/src/renderer.ts +++ b/src/renderer.ts @@ -108,7 +108,7 @@ async function forwardMessage(message: MessageElement) { } for (let element of message.raw.elements) { let message_data: any = { - data: {} + data: {"type": "unknown"} } if (element.textElement?.atType == 2) { @@ -203,27 +203,40 @@ function onLoad() { } window.LLAPI.on("new-messages", onNewMessages); - function test(){ - console.log("test") - } + try { - window.LLAPI.add_qmenu((qContextMenu: { insertAdjacentHTML: (location: string, ele: string) => void }) => { - qContextMenu.insertAdjacentHTML("beforeend", `获取群成员列表`) + window.LLAPI.add_qmenu((qContextMenu: Node) => { + let btn = document.createElement("a") + btn.className = "q-context-menu-item q-context-menu-item--normal vue-component" + btn.setAttribute("aria-disabled", "false") + btn.setAttribute("role", "menuitem") + btn.setAttribute("tabindex", "-1") + btn.onclick = ()=>{ + // window.LLAPI.getPeer().then(peer => { + // // console.log("current peer", peer) + // if (peer && peer.chatType == "group") { + // getGroupMembers(peer.uid, true).then(()=> { + // console.log("获取群成员列表成功", groups); + // alert("获取群成员列表成功") + // }) + // } + // }) + window.LLAPI.getGroupMemberList("164461995", 5000).then(res =>{ + console.log("获取群成员列表结果", res) + }) + } + btn.innerText = "获取群成员列表" + console.log(qContextMenu) + // qContextMenu.appendChild(btn) + // qContextMenu.insertAdjacentHTML("beforeend", btn) }) }catch (e){ - log(e) + console.log(e) } window.LLAPI.on("context-msg-menu", (event, target, msgIds) => { - console.log("msg menu", event, target, msgIds); + // console.log("msg menu", event, target, msgIds); // 消息右键菜单添加一个获取群成员列表的按钮 - - window.LLAPI.getPeer().then(peer => { - // console.log("current peer", peer) - if (peer && peer.chatType == "group") { - getGroupMembers(peer.uid, false).then() - } - }) }) // console.log("getAccountInfo", LLAPI.getAccountInfo());