desktop
提供桌面应用开发指南,基于Electron的主渲染器架构,涵盖应用生命周期、系统API和窗口管理,助力桌面应用开发。
npx skills add https://github.com/lobehub/lobehub --skill desktopBefore / After 效果对比
1 组独立开发Electron桌面应用时,开发者需自行摸索应用生命周期、系统API调用和窗口管理等复杂细节,容易遇到兼容性问题和性能瓶颈,开发效率较低。
桌面应用开发指南提供了基于Electron主渲染器架构的全面指导。它系统性地涵盖了应用生命周期、系统API和窗口管理,帮助开发者快速构建稳定高效的桌面应用。
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 Installs345Repositorylobehub/lobehubGitHub Stars73.9KFirst SeenJan 27, 2026Security AuditsGen Agent Trust HubPassSocketPassSnykPassInstalled oncodex305opencode302gemini-cli301github-copilot283cursor255claude-code250
用户评价 (0)
发表评价
暂无评价
统计数据
用户评分
为此 Skill 评分