mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00

# Conflicts: # src/common/utils.ts # src/global.d.ts # src/main/ipcsend.ts # src/main/main.ts # src/ntqqapi/hook.ts # src/onebot11/action/SendMsg.ts # src/onebot11/action/TestForwdMsg.ts # src/onebot11/action/types.ts # src/onebot11/server.ts # src/preload.ts
23 lines
696 B
TypeScript
23 lines
696 B
TypeScript
// Electron 主进程 与 渲染进程 交互的桥梁
|
|
|
|
import {Config} from "./common/types";
|
|
import {CHANNEL_GET_CONFIG, CHANNEL_LOG, CHANNEL_SET_CONFIG,} from "./common/channels";
|
|
const {contextBridge} = require("electron");
|
|
const {ipcRenderer} = require('electron');
|
|
|
|
const llonebot = {
|
|
log: (data: any) => {
|
|
ipcRenderer.send(CHANNEL_LOG, data);
|
|
},
|
|
setConfig: (config: Config) => {
|
|
ipcRenderer.send(CHANNEL_SET_CONFIG, config);
|
|
},
|
|
getConfig: async () => {
|
|
return ipcRenderer.invoke(CHANNEL_GET_CONFIG);
|
|
},
|
|
}
|
|
|
|
export type LLOneBot = typeof llonebot;
|
|
|
|
// 在window对象下导出只读对象
|
|
contextBridge.exposeInMainWorld("llonebot", llonebot); |