desktop について
Electron で LobeHub のデスクトップ機能を開発するコントリビューター向けガイドです。メイン・レンダラープロセスの構成と、機能実装やテストの手順を説明します。
主な機能
- 01Electron のプロセス構成の説明
- 02コントローラーの作成と登録
- 03IPC 型定義の案内
- 04レンダラーサービスとストアアクション
- 05分野別デスクトップガイド
活用シーン
- 01新しいデスクトップ機能の計画
- 02メインプロセスとレンダラーの機能連携
- 03コントローラーテストの追加
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ lobehub/ lobehub --skill desktopインストール後、Claude Code で/desktopを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
agents/openai.yamlreferences/feature-implementation.mdlocal-tools.mdmenu-config.mdwindow-management.md詳細
デスクトップ開発ガイド
アーキテクチャの概要
LobeHub デスクトップは、メインプロセスとレンダラープロセスのアーキテクチャを採用した Electron で構築されています。
- メインプロセス(
apps/desktop/src/main):アプリのライフサイクル、システム API、ウィンドウ管理 - レンダラープロセス:
src/の Web コードを再利用します - プリロードスクリプト(
apps/desktop/src/preload):メインプロセスをレンダラープロセスに安全に公開します
新しいデスクトップ機能の追加
1. コントローラーを作成する
場所:apps/desktop/src/main/controllers/
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 };
}
}
apps/desktop/src/main/controllers/registry.ts に登録します。
2. IPC 型を定義する
場所:packages/electron-client-ipc/src/types/<domain>.ts。types/index.ts から再エクスポートされます
export interface SomeParams {
/* ... */
}
export interface SomeResult {
success: boolean;
error?: string;
}
3. レンダラーサービスを作成する
場所:src/services/electron/
import { ensureElectronIpc } from '@/utils/electron/ipc';
const ipc = ensureElectronIpc();
export const newFeatureService = async (params: SomeParams) => {
return ipc.newFeature.doSomething(params);
};
4. ストアのアクションを実装する
場所:src/store/
5. テストを追加する
コントローラーと同じ場所に配置します。apps/desktop/src/main/controllers/<Name>Ctr.test.ts(source-layout §2)
詳細ガイド
各トピックの詳細は references/ を参照してください。
- 機能の実装:
references/feature-implementation.md - ローカルツールのワークフロー:
references/local-tools.md - メニューの設定:
references/menu-config.md - ウィンドウ管理:
references/window-management.md
コメント
Markdown 対応