---
id: sm-desktop
name: "desktop"
url: https://skills.yangsir.net/skill/sm-desktop
author: lobehub
domain: ai-app-building-integration
tags: ["desktop-applications", "electron.js", "cross-platform-development", "backend-services", "lobehub"]
install_count: 4200
rating: 4.40 (80 reviews)
github: https://github.com/lobehub/lobehub
---

# desktop

> 提供桌面应用开发指南，基于Electron的主渲染器架构，涵盖应用生命周期、系统API和窗口管理，助力桌面应用开发。

**Stats**: 4,200 installs · 4.4/5 (80 reviews)

## Before / After 对比

### 优化Electron桌面应用开发流程

## Readme

# desktop

# Desktop Development Guide

## Architecture Overview

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

- **Main Process** (`apps/desktop/src/main`): App lifecycle, system APIs, window management

- **Renderer Process**: Reuses web code from `src/`

- **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/`

```
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.ts`

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

```

### 3. Create Renderer Service

Location: `src/services/electron/`

```
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`

## Best Practices

- **Security**: Validate inputs, limit exposed APIs

- **Performance**: Use async methods, batch data transfers

- **UX**: Add progress indicators, provide error feedback

- **Code organization**: Follow existing patterns, add documentation

Weekly Installs345Repository[lobehub/lobehub](https://github.com/lobehub/lobehub)GitHub Stars73.9KFirst SeenJan 27, 2026Security Audits[Gen Agent Trust HubPass](/lobehub/lobehub/desktop/security/agent-trust-hub)[SocketPass](/lobehub/lobehub/desktop/security/socket)[SnykPass](/lobehub/lobehub/desktop/security/snyk)Installed oncodex305opencode302gemini-cli301github-copilot283cursor255claude-code250

---
*Source: https://skills.yangsir.net/skill/sm-desktop*
*Markdown mirror: https://skills.yangsir.net/api/skill/sm-desktop/markdown*