chore: 完善注释,添加 JSDoc

This commit is contained in:
2026-07-19 23:08:58 +08:00
parent 089bfaacf7
commit b23cf4d854
15 changed files with 846 additions and 59 deletions
+13 -2
View File
@@ -2,15 +2,26 @@ import { ipcMain, BrowserWindow } from 'electron';
import mqttManager from './mqtt-manager.js';
/**
* 注册所有 IPC 处理器
* 将渲染进程的请求转发给 MQTT 管理器,并把 MQTT 事件推送给渲染进程
*/
export function registerIpcHandlers() {
// 获取主窗口(用于推送事件)
/**
* 获取当前所有窗口中的第一个主窗口
* @returns {BrowserWindow|null} 主窗口实例或 null
*/
function getMainWindow() {
const windows = BrowserWindow.getAllWindows();
return windows.length > 0 ? windows[0] : null;
}
// 向渲染进程发送事件
/**
* 向渲染进程发送事件
* @param {string} channel - IPC 通道名称
* @param {*} data - 要发送的数据
*/
function sendToRenderer(channel, data) {
const win = getMainWindow();
if (win && !win.isDestroyed()) {