Desktop

作者 lobehub6a3eba96b010無授權條款83K 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫今天更新

Electron desktop development guide — IPC handlers, controllers, preload scripts, window/menu management.

AI 產生的概覽

指導 LobeHub 的 Electron 桌面開發:IPC 處理常式、控制器、預載指令碼以及視窗和選單管理。

功能
此技能提供架構概觀和逐步說明,用於為 Electron 應用程式加入桌面功能,涵蓋控制器、IPC 型別定義、渲染程式服務、store 動作和測試。它指向關於功能實作、本機工具、選單設定和視窗管理的參考文件。它產出的是指引和程式碼模式,而不是產生的檔案。
適用情境
在實作或擴充 Electron 桌面功能時使用,例如新的 IPC 方法、控制器、預載暴露、選單或視窗。它面向在 LobeHub 桌面程式碼庫中工作的開發者。
執行需求
不附帶指令碼,僅為說明文件。它假定存在具有所述目錄結構的 Electron 專案和 TypeScript 工具鏈。

Desktop Development Guide

Architecture Overview

LobeHub desktop is built on Electron with main-renderer architecture:

  1. Main Process (apps/desktop/src/main): App lifecycle, system APIs, window management
  2. Renderer Process: Reuses web code from src/
  3. Preload Scripts (apps/desktop/src/preload): Securely expose main process to renderer

Adding New Desktop Features

1. Create Controller

Location: apps/desktop/src/main/controllers/

typescript
import { ControllerModule, IpcMethod } from '@/controllers';
export default class NewFeatureCtr extends ControllerModule {  static override readonly groupName = 'newFeature';
  @IpcMethod()  async doSomething(params: SomeParams): Promise<SomeResult> {    // Implementation    return { success: true };  }}

Register in apps/desktop/src/main/controllers/registry.ts.

2. Define IPC Types

Location: packages/electron-client-ipc/src/types/<domain>.ts, re-exported from types/index.ts

typescript
export interface SomeParams {  /* ... */}export interface SomeResult {  success: boolean;  error?: string;}

3. Create Renderer Service

Location: src/services/electron/

typescript
import { ensureElectronIpc } from '@/utils/electron/ipc';
const ipc = ensureElectronIpc();
export const newFeatureService = async (params: SomeParams) => {  return ipc.newFeature.doSomething(params);};

4. Implement Store Action

Location: src/store/

5. Add Tests

Location: apps/desktop/src/main/controllers/__tests__/

Detailed Guides

See references/ for specific topics:

  • Feature implementation: references/feature-implementation.md
  • Local tools workflow: references/local-tools.md
  • Menu configuration: references/menu-config.md
  • Window management: references/window-management.md

來源與署名

來源:lobehub/lobehub位於.agents/skills/desktop提交6a3eba9

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架