mirror of
https://github.com/rubickCenter/rubick
synced 2025-12-20 10:05:40 +08:00
✨ 支持 setSubInput API
This commit is contained in:
@@ -1,8 +1,16 @@
|
||||
import { BrowserWindow, ipcMain, dialog } from "electron";
|
||||
import { BrowserWindow, ipcMain, dialog, webContents } from "electron";
|
||||
import { runner } from "../browsers";
|
||||
|
||||
const runnerInstance = runner();
|
||||
|
||||
function getWorkWebContentsBySender(sender, mainWindow) {
|
||||
const window = BrowserWindow.fromWebContents(sender);
|
||||
console.log(window);
|
||||
|
||||
if (!window) return null;
|
||||
return window.webContents;
|
||||
}
|
||||
|
||||
const API: any = {
|
||||
openPlugin({ plugin }, window) {
|
||||
runnerInstance.removeView(window);
|
||||
@@ -24,8 +32,15 @@ const API: any = {
|
||||
const targetHeight = height;
|
||||
window.setSize(window.getSize()[0], targetHeight);
|
||||
},
|
||||
setSubInput() {
|
||||
|
||||
setSubInput({ data }, window) {
|
||||
window.webContents.executeJavaScript(
|
||||
`window.setSubInput(${JSON.stringify({
|
||||
placeholder: data.placeholder,
|
||||
})})`
|
||||
);
|
||||
},
|
||||
sendSubInputChangeEvent({ data }) {
|
||||
runnerInstance.executeHooks("SubInputChange", data);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -34,7 +49,7 @@ export default (mainWindow: BrowserWindow) => {
|
||||
ipcMain.on("msg-trigger", async (event, arg) => {
|
||||
const window = arg.winId ? BrowserWindow.fromId(arg.winId) : mainWindow;
|
||||
|
||||
const data = await API[arg.type](arg, window);
|
||||
const data = await API[arg.type](arg, window, event);
|
||||
event.returnValue = data;
|
||||
// event.sender.send(`msg-back-${arg.type}`, data);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user