mirror of
https://github.com/rubickCenter/rubick
synced 2025-12-20 18:15:43 +08:00
✨ 主界面开发&插件运行容器开发&菜单开发
This commit is contained in:
25
src/main/common/api.ts
Normal file
25
src/main/common/api.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { BrowserWindow, ipcMain } from "electron";
|
||||
import { runner } from "../browsers";
|
||||
|
||||
const runnerInstance = runner();
|
||||
|
||||
const API: any = {
|
||||
setExpendHeight({ height }: { height: number }, win: BrowserWindow): void {
|
||||
win.setSize(800, height || 60);
|
||||
},
|
||||
openPlugin({plugin}) {
|
||||
console.log(plugin);
|
||||
runnerInstance.init(plugin);
|
||||
},
|
||||
};
|
||||
|
||||
export default (mainWindow: BrowserWindow) => {
|
||||
// 响应 preload.js 事件
|
||||
ipcMain.on("msg-trigger", async (event, arg) => {
|
||||
const window = arg.winId ? BrowserWindow.fromId(arg.winId) : mainWindow;
|
||||
|
||||
const data = await API[arg.type](arg, window);
|
||||
event.returnValue = data;
|
||||
// event.sender.send(`msg-back-${arg.type}`, data);
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user