mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
feat: try to send poke by context menu
This commit is contained in:
parent
ff952956de
commit
99693abd06
@ -1,6 +1,10 @@
|
|||||||
//LiteLoader需要提供部分IPC接口,以便于其他插件调用
|
//LiteLoader需要提供部分IPC接口,以便于其他插件调用
|
||||||
const { ipcMain } = require('electron');
|
const { ipcMain } = require('electron');
|
||||||
const napcat = require('./napcat.cjs');
|
const napcat = require('./napcat.cjs');
|
||||||
|
require('./poke/main.js');
|
||||||
|
|
||||||
ipcMain.handle('napcat_get_webtoken', async (event, arg) => {
|
ipcMain.handle('napcat_get_webtoken', async (event, arg) => {
|
||||||
return napcat.NCgetWebUiUrl();
|
return napcat.NCgetWebUiUrl();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
20
src/framework/poke/main.js
Normal file
20
src/framework/poke/main.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
const { ipcMain } = require('electron');
|
||||||
|
const napcat = require('../napcat.cjs');
|
||||||
|
|
||||||
|
|
||||||
|
ipcMain.handle('napcat_group_poke', async (event, { messageId, groupName }) => {
|
||||||
|
const framework = await napcat.napcatFramework;
|
||||||
|
const groups = await framework.core.apis.getGroups();
|
||||||
|
for (const group of groups) {
|
||||||
|
if (groupName === group.groupName) {
|
||||||
|
const { msgList } = await framework.core.apis.getMsgsByMsgId({
|
||||||
|
peerUid: group.groupCode,
|
||||||
|
chatType: 2
|
||||||
|
}, [messageId]);
|
||||||
|
if (msgList) {
|
||||||
|
framework.core.apis.PacketApi.sendPokePacket(msgList[0].senderUin, +group.groupCode);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
11
src/framework/poke/renderer.js
Normal file
11
src/framework/poke/renderer.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
function onLoad() {
|
||||||
|
document.getElementsByClassName("avatar").forEach(e => e.addEventListener("contextmenu", (ee) => {
|
||||||
|
let messageEle = ee.target.parentElement.parentElement.parentElement.parentElement;
|
||||||
|
let messageId = messageEle.getAttribute("id");
|
||||||
|
let groupName = document.getElementsByClassName("chat-header__contact-name")[0].firstElementChild.textContent.trim();
|
||||||
|
// todo: 右键菜单添加戳一戳
|
||||||
|
window.napcat.groupPoke(groupName, messageId);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
onLoad();
|
@ -5,6 +5,9 @@ const napcat = {
|
|||||||
getWebUiUrl: async () => {
|
getWebUiUrl: async () => {
|
||||||
return ipcRenderer.invoke('napcat_get_webtoken');
|
return ipcRenderer.invoke('napcat_get_webtoken');
|
||||||
},
|
},
|
||||||
|
groupPoke: async (groupName, messageId) =>{
|
||||||
|
return ipcRenderer.invoke('napcat_group_poke', {groupName, messageId});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
// 在window对象下导出只读对象
|
// 在window对象下导出只读对象
|
||||||
contextBridge.exposeInMainWorld('napcat', napcat);
|
contextBridge.exposeInMainWorld('napcat', napcat);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
require('./poke/renderer.js');
|
||||||
export const onSettingWindowCreated = async (view) => {
|
export const onSettingWindowCreated = async (view) => {
|
||||||
|
|
||||||
// view.style.width = "100%";
|
// view.style.width = "100%";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user