From 7124e550f589d7e1361fe0e2eaf3243db05abec6 Mon Sep 17 00:00:00 2001 From: linyuchen Date: Thu, 2 Nov 2023 11:21:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A0=94=E7=A9=B6=E6=B6=88=E6=81=AF=E5=8F=B3?= =?UTF-8?q?=E9=94=AE=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/global.d.ts | 1 + src/main.ts | 6 +++++- src/preload.ts | 5 ++++- src/renderer.ts | 16 ++++++++++++++-- tsconfig.json | 2 +- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/global.d.ts b/src/global.d.ts index 9857aab..c5eb14b 100644 --- a/src/global.d.ts +++ b/src/global.d.ts @@ -17,6 +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 }; diff --git a/src/main.ts b/src/main.ts index 87f7ab3..50f5852 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,6 +1,10 @@ // 运行在 Electron 主进程 下的插件入口 -import {Group, PostDataSendMsg, User} from "./types"; +// import {Group, PostDataSendMsg, User} from "./types"; +// type {Group, PostDataSendMsg, User} = import( "./types"); +type Group = import( "./types").Group; +type PostDataSendMsg = import( "./types").PostDataSendMsg; +type User = import( "./types").User; const express = require("express") const {ipcMain, webContents} = require('electron'); diff --git a/src/preload.ts b/src/preload.ts index affb87f..13e394b 100644 --- a/src/preload.ts +++ b/src/preload.ts @@ -1,6 +1,9 @@ // Electron 主进程 与 渲染进程 交互的桥梁 -import {Group, PostDataSendMsg, User} from "./types"; +// import {Group, PostDataSendMsg, User} from "./types"; +// type Group = import( "./types").Group; +// type PostDataSendMsg = import( "./types").PostDataSendMsg; +// type User = import( "./types").User; const {contextBridge} = require("electron"); const {ipcRenderer} = require('electron'); diff --git a/src/renderer.ts b/src/renderer.ts index 76dee79..55d09bb 100644 --- a/src/renderer.ts +++ b/src/renderer.ts @@ -203,9 +203,21 @@ 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", `获取群成员列表`) + }) + }catch (e){ + log(e) + } window.LLAPI.on("context-msg-menu", (event, target, msgIds) => { - console.log(event); + console.log("msg menu", event, target, msgIds); + // 消息右键菜单添加一个获取群成员列表的按钮 + window.LLAPI.getPeer().then(peer => { // console.log("current peer", peer) if (peer && peer.chatType == "group") { @@ -251,7 +263,7 @@ function onLoad() { } } - getChatListEle(); + // getChatListEle(); } // 打开设置界面时触发 diff --git a/tsconfig.json b/tsconfig.json index 011a96a..5cf5d45 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,7 @@ "target": "es6", "module": "es6", "outDir": "./dist", - "strict": true, + "strict": false, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "moduleResolution": "node",