@leejungkiin/awkit 1.5.4 → 1.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/bin/awk.js +188 -8
  2. package/core/GEMINI.md +22 -14
  3. package/core/work-modes.json +45 -0
  4. package/package.json +1 -1
  5. package/skill-packs/cocos2d/pack.json +8 -0
  6. package/skill-packs/cocos2d/skills/cocos2d-x/LICENSE.txt +8 -0
  7. package/skill-packs/cocos2d/skills/cocos2d-x/SKILL.md +168 -0
  8. package/skill-packs/cocos2d/skills/cocos2d-x/examples/core/action.md +278 -0
  9. package/skill-packs/cocos2d/skills/cocos2d-x/examples/core/animation.md +220 -0
  10. package/skill-packs/cocos2d/skills/cocos2d-x/examples/core/event.md +133 -0
  11. package/skill-packs/cocos2d/skills/cocos2d-x/examples/core/input.md +291 -0
  12. package/skill-packs/cocos2d/skills/cocos2d-x/examples/core/label.md +184 -0
  13. package/skill-packs/cocos2d/skills/cocos2d-x/examples/core/node-scene.md +212 -0
  14. package/skill-packs/cocos2d/skills/cocos2d-x/examples/core/scene.md +228 -0
  15. package/skill-packs/cocos2d/skills/cocos2d-x/examples/core/sprite.md +206 -0
  16. package/skill-packs/cocos2d/skills/cocos2d-x/examples/core/texture.md +186 -0
  17. package/skill-packs/cocos2d/skills/cocos2d-x/examples/getting-started/about-engine.md +53 -0
  18. package/skill-packs/cocos2d/skills/cocos2d-x/examples/getting-started/installation.md +203 -0
  19. package/skill-packs/cocos2d/skills/cocos2d-x/examples/getting-started/quick-start.md +134 -0
  20. package/skill-packs/electron/pack.json +9 -0
  21. package/skill-packs/electron/skills/electron/LICENSE.txt +202 -0
  22. package/skill-packs/electron/skills/electron/SKILL.md +160 -0
  23. package/skill-packs/electron/skills/electron/api/app.md +83 -0
  24. package/skill-packs/electron/skills/electron/api/browser-window.md +84 -0
  25. package/skill-packs/electron/skills/electron/examples/advanced/packaging.md +140 -0
  26. package/skill-packs/electron/skills/electron/examples/api/browser-window.md +182 -0
  27. package/skill-packs/electron/skills/electron/examples/api/menu.md +187 -0
  28. package/skill-packs/electron/skills/electron/examples/getting-started/installation.md +88 -0
  29. package/skill-packs/electron/skills/electron/examples/getting-started/quick-start.md +104 -0
  30. package/skill-packs/electron/skills/electron/examples/processes/ipc-communication.md +140 -0
  31. package/skill-packs/electron/skills/electron/examples/processes/main-process.md +121 -0
  32. package/skill-packs/electron/skills/electron/templates/main-process.md +105 -0
  33. package/skill-packs/electron/skills/electron/templates/preload-script.md +84 -0
  34. package/skill-packs/electron/skills/electron-egg/LICENSE.txt +202 -0
  35. package/skill-packs/electron/skills/electron-egg/SKILL.md +154 -0
  36. package/skill-packs/electron/skills/electron-egg/api/config-api.md +62 -0
  37. package/skill-packs/electron/skills/electron-egg/api/ipc-api.md +55 -0
  38. package/skill-packs/electron/skills/electron-egg/api/main-api.md +54 -0
  39. package/skill-packs/electron/skills/electron-egg/api/renderer-api.md +62 -0
  40. package/skill-packs/electron/skills/electron-egg/api/window-api.md +64 -0
  41. package/skill-packs/electron/skills/electron-egg/examples/features/ipc-communication.md +84 -0
  42. package/skill-packs/electron/skills/electron-egg/examples/features/main-process.md +89 -0
  43. package/skill-packs/electron/skills/electron-egg/examples/features/renderer-process.md +74 -0
  44. package/skill-packs/electron/skills/electron-egg/examples/guide/build.md +77 -0
  45. package/skill-packs/electron/skills/electron-egg/examples/guide/configuration.md +88 -0
  46. package/skill-packs/electron/skills/electron-egg/examples/guide/installation.md +66 -0
  47. package/skill-packs/electron/skills/electron-egg/examples/guide/intro.md +47 -0
  48. package/skill-packs/electron/skills/electron-egg/examples/guide/project-structure.md +73 -0
  49. package/skill-packs/electron/skills/electron-egg/examples/guide/quick-start.md +78 -0
  50. package/skill-packs/electron/skills/electron-egg/templates/configuration.md +63 -0
  51. package/skill-packs/electron/skills/electron-egg/templates/installation.md +42 -0
  52. package/skill-packs/electron/skills/electron-egg/templates/project-setup.md +75 -0
  53. package/skill-packs/flutter/pack.json +9 -0
  54. package/skill-packs/flutter/skills/flutter/LICENSE.txt +202 -0
  55. package/skill-packs/flutter/skills/flutter/SKILL.md +127 -0
  56. package/skill-packs/flutter/skills/flutter-project-creater/LICENSE.txt +202 -0
  57. package/skill-packs/flutter/skills/flutter-project-creater/SKILL.md +106 -0
  58. package/skill-packs/threejs/pack.json +25 -0
  59. package/skill-packs/threejs/skills/README.md +95 -0
  60. package/skill-packs/threejs/skills/threejs-animation/SKILL.md +86 -0
  61. package/skill-packs/threejs/skills/threejs-animation/examples/workflow-mixer-action.md +20 -0
  62. package/skill-packs/threejs/skills/threejs-animation/references/official-sections.md +19 -0
  63. package/skill-packs/threejs/skills/threejs-audio/SKILL.md +112 -0
  64. package/skill-packs/threejs/skills/threejs-audio/examples/workflow-positional-audio.md +15 -0
  65. package/skill-packs/threejs/skills/threejs-audio/references/official-sections.md +16 -0
  66. package/skill-packs/threejs/skills/threejs-camera/SKILL.md +96 -0
  67. package/skill-packs/threejs/skills/threejs-camera/examples/workflow-perspective-resize.md +13 -0
  68. package/skill-packs/threejs/skills/threejs-controls/SKILL.md +101 -0
  69. package/skill-packs/threejs/skills/threejs-controls/examples/workflow-orbit-damping.md +15 -0
  70. package/skill-packs/threejs/skills/threejs-dev-setup/SKILL.md +102 -0
  71. package/skill-packs/threejs/skills/threejs-dev-setup/examples/workflow-scaffold.md +24 -0
  72. package/skill-packs/threejs/skills/threejs-geometries/SKILL.md +108 -0
  73. package/skill-packs/threejs/skills/threejs-geometries/examples/workflow-extrude-shape.md +13 -0
  74. package/skill-packs/threejs/skills/threejs-helpers/SKILL.md +103 -0
  75. package/skill-packs/threejs/skills/threejs-helpers/examples/workflow-light-camera-helpers.md +13 -0
  76. package/skill-packs/threejs/skills/threejs-lights/SKILL.md +103 -0
  77. package/skill-packs/threejs/skills/threejs-lights/examples/workflow-directional-shadow.md +17 -0
  78. package/skill-packs/threejs/skills/threejs-loaders/SKILL.md +89 -0
  79. package/skill-packs/threejs/skills/threejs-loaders/examples/workflow-gltf-draco.md +22 -0
  80. package/skill-packs/threejs/skills/threejs-loaders/references/official-sections.md +27 -0
  81. package/skill-packs/threejs/skills/threejs-materials/SKILL.md +102 -0
  82. package/skill-packs/threejs/skills/threejs-materials/examples/workflow-pbr-transparent.md +15 -0
  83. package/skill-packs/threejs/skills/threejs-math/SKILL.md +102 -0
  84. package/skill-packs/threejs/skills/threejs-math/examples/workflow-ray-aabb.md +11 -0
  85. package/skill-packs/threejs/skills/threejs-node-tsl/SKILL.md +83 -0
  86. package/skill-packs/threejs/skills/threejs-node-tsl/examples/workflow-tsl-entry.md +13 -0
  87. package/skill-packs/threejs/skills/threejs-node-tsl/references/official-links.md +8 -0
  88. package/skill-packs/threejs/skills/threejs-node-tsl/references/tsl-vs-classic.md +23 -0
  89. package/skill-packs/threejs/skills/threejs-objects/SKILL.md +111 -0
  90. package/skill-packs/threejs/skills/threejs-objects/examples/workflow-raycaster-pick.md +17 -0
  91. package/skill-packs/threejs/skills/threejs-postprocessing/SKILL.md +116 -0
  92. package/skill-packs/threejs/skills/threejs-postprocessing/examples/workflow-composer-bloom.md +15 -0
  93. package/skill-packs/threejs/skills/threejs-renderers/SKILL.md +91 -0
  94. package/skill-packs/threejs/skills/threejs-renderers/examples/workflow-renderer-resize.md +21 -0
  95. package/skill-packs/threejs/skills/threejs-renderers/references/official-sections.md +14 -0
  96. package/skill-packs/threejs/skills/threejs-scenes/SKILL.md +90 -0
  97. package/skill-packs/threejs/skills/threejs-scenes/examples/workflow-fog-background.md +13 -0
  98. package/skill-packs/threejs/skills/threejs-textures/SKILL.md +83 -0
  99. package/skill-packs/threejs/skills/threejs-textures/examples/workflow-pmrem-env.md +19 -0
  100. package/skill-packs/threejs/skills/threejs-webxr/SKILL.md +104 -0
  101. package/skill-packs/threejs/skills/threejs-webxr/examples/workflow-xr-button.md +15 -0
  102. package/skills/codex-conductor/SKILL.md +4 -4
  103. package/skills/gemini-conductor/SKILL.md +3 -2
  104. package/skills/telegram-notify/SKILL.md +1 -0
  105. package/skills/trello-sync/SKILL.md +7 -0
  106. package/templates/project-identity/android.json +26 -1
  107. package/templates/project-identity/backend-nestjs.json +26 -1
  108. package/templates/project-identity/expo.json +26 -1
  109. package/templates/project-identity/ios.json +26 -1
  110. package/templates/project-identity/web-nextjs.json +26 -1
@@ -0,0 +1,160 @@
1
+ ---
2
+ name: electron
3
+ description: "Build cross-platform desktop applications with Electron, covering main/renderer process architecture, IPC communication, BrowserWindow management, menus, tray icons, packaging, and security best practices. Use when the user asks about Electron, needs to create desktop applications, implement Electron features, or build cross-platform desktop apps."
4
+ license: Complete terms in LICENSE.txt
5
+ ---
6
+
7
+ ## When to use this skill
8
+
9
+ Use this skill whenever the user wants to:
10
+ - Build cross-platform desktop applications with Electron
11
+ - Understand Electron architecture (main process, renderer process, preload)
12
+ - Implement IPC (Inter-Process Communication) between processes
13
+ - Create and manage BrowserWindow instances
14
+ - Implement menus, tray icons, and native features
15
+ - Package and distribute Electron applications
16
+ - Use Electron Forge for project scaffolding and building
17
+ - Debug and test Electron applications
18
+ - Implement security best practices
19
+ - Use Electron APIs (app, BrowserWindow, ipcMain, ipcRenderer, etc.)
20
+
21
+ ## How to use this skill
22
+
23
+ This skill is organized to match the Electron official documentation structure (https://www.electronjs.org/zh/docs/latest/, https://www.electronjs.org/zh/docs/latest/api/app). When working with Electron:
24
+
25
+ 1. **Identify the topic** from the user's request:
26
+ - Getting started/快速开始 → `examples/getting-started/installation.md` or `examples/getting-started/quick-start.md`
27
+ - Main process/主进程 → `examples/processes/main-process.md`
28
+ - Renderer process/渲染进程 → `examples/processes/renderer-process.md`
29
+ - IPC communication/IPC 通信 → `examples/processes/ipc-communication.md`
30
+ - BrowserWindow/窗口 → `examples/api/browser-window.md`
31
+ - Menu/菜单 → `examples/api/menu.md`
32
+ - Packaging/打包 → `examples/advanced/packaging.md`
33
+ - Security/安全 → `examples/advanced/security.md`
34
+
35
+ 2. **Load the appropriate example file** from the `examples/` directory:
36
+
37
+ **Getting Started (快速开始) - `examples/getting-started/`**:
38
+ - `examples/getting-started/installation.md` - Installing Electron and basic setup
39
+ - `examples/getting-started/quick-start.md` - Quick start tutorial
40
+
41
+ **Processes (进程) - `examples/processes/`**:
42
+ - `examples/processes/main-process.md` - Main process concepts and usage
43
+ - `examples/processes/renderer-process.md` - Renderer process concepts
44
+ - `examples/processes/preload-scripts.md` - Preload scripts usage
45
+ - `examples/processes/ipc-communication.md` - IPC communication patterns
46
+
47
+ **API Examples (API 示例) - `examples/api/`**:
48
+ - `examples/api/browser-window.md` - BrowserWindow usage
49
+ - `examples/api/menu.md` - Menu and context menu
50
+ - `examples/api/tray.md` - System tray
51
+ - `examples/api/dialog.md` - File dialogs
52
+ - `examples/api/ipc-main.md` - ipcMain usage
53
+ - `examples/api/ipc-renderer.md` - ipcRenderer usage
54
+
55
+ **Advanced (高级) - `examples/advanced/`**:
56
+ - `examples/advanced/packaging.md` - Application packaging
57
+ - `examples/advanced/security.md` - Security best practices
58
+ - `examples/advanced/auto-updater.md` - Auto updater
59
+ - `examples/advanced/native-modules.md` - Native modules
60
+
61
+ **Tools (工具) - `examples/tools/`**:
62
+ - `examples/tools/electron-forge.md` - Electron Forge usage
63
+ - `examples/tools/electron-fiddle.md` - Electron Fiddle usage
64
+
65
+ 3. **Follow the specific instructions** in that example file for syntax, structure, and best practices
66
+
67
+ **Important Notes**:
68
+ - All examples follow Electron latest API
69
+ - Examples use both CommonJS (require) and ES modules (import)
70
+ - Each example file includes key concepts, code examples, and key points
71
+ - Always check the example file for best practices and common patterns
72
+ - Electron supports Windows, macOS, and Linux
73
+
74
+ 4. **Reference API documentation** in the `api/` directory when needed:
75
+ - `api/app.md` - app module API
76
+ - `api/browser-window.md` - BrowserWindow API
77
+ - `api/ipc-main.md` - ipcMain API
78
+ - `api/ipc-renderer.md` - ipcRenderer API
79
+ - `api/menu.md` - Menu API
80
+ - `api/tray.md` - Tray API
81
+
82
+ 5. **Use templates** from the `templates/` directory:
83
+ - `templates/main-process.md` - Main process template
84
+ - `templates/preload-script.md` - Preload script template
85
+ - `templates/renderer-process.md` - Renderer process template
86
+ - `templates/package-json.md` - package.json template
87
+
88
+
89
+ ### Doc mapping (one-to-one with official documentation)
90
+
91
+ - `examples/` → https://www.electronjs.org/zh/docs/latest/
92
+ - `api/` → https://www.electronjs.org/zh/docs/latest/api/app
93
+
94
+ ## Quick Start Example
95
+
96
+ ```javascript
97
+ // main.js
98
+ const { app, BrowserWindow, ipcMain } = require('electron')
99
+ const path = require('path')
100
+
101
+ function createWindow() {
102
+ const win = new BrowserWindow({
103
+ width: 800, height: 600,
104
+ webPreferences: {
105
+ preload: path.join(__dirname, 'preload.js'),
106
+ nodeIntegration: false, // Security: always disable
107
+ contextIsolation: true // Security: always enable
108
+ }
109
+ })
110
+ win.loadFile('index.html')
111
+ }
112
+
113
+ app.whenReady().then(createWindow)
114
+
115
+ // IPC handler example
116
+ ipcMain.handle('get-data', async () => {
117
+ return { message: 'Hello from main process' }
118
+ })
119
+ ```
120
+
121
+ ```javascript
122
+ // preload.js
123
+ const { contextBridge, ipcRenderer } = require('electron')
124
+ contextBridge.exposeInMainWorld('api', {
125
+ getData: () => ipcRenderer.invoke('get-data')
126
+ })
127
+ ```
128
+
129
+ ## API Reference (`api/`)
130
+
131
+ - `api/app.md` - app module API
132
+ - `api/browser-window.md` - BrowserWindow API
133
+ - `api/ipc-main.md` / `api/ipc-renderer.md` - IPC APIs
134
+ - `api/menu.md` / `api/tray.md` / `api/dialog.md` - UI APIs
135
+
136
+ ## Best Practices
137
+
138
+ 1. **Security**: Never enable nodeIntegration in renderer process, use preload scripts
139
+ 2. **Process separation**: Keep main and renderer processes separate
140
+ 3. **IPC communication**: Use IPC for safe communication between processes
141
+ 4. **Resource management**: Properly clean up resources (windows, listeners)
142
+ 5. **Error handling**: Implement proper error handling and crash reporting
143
+ 6. **Performance**: Optimize for performance, use webContents for debugging
144
+ 7. **Packaging**: Use Electron Forge or electron-builder for packaging
145
+ 8. **Auto updates**: Implement auto-updater for production apps
146
+ 9. **Native modules**: Handle native module compatibility
147
+ 10. **Cross-platform**: Test on all target platforms
148
+
149
+ ## Resources
150
+
151
+ - **Official Website**: https://www.electronjs.org/zh/
152
+ - **Documentation**: https://www.electronjs.org/zh/docs/latest/
153
+ - **API Reference**: https://www.electronjs.org/zh/docs/latest/api/app
154
+ - **Electron Forge**: https://www.electronforge.io
155
+ - **Electron Fiddle**: https://www.electronjs.org/zh/fiddle
156
+ - **GitHub Repository**: https://github.com/electron/electron
157
+
158
+ ## Keywords
159
+
160
+ Electron, desktop app, main process, renderer process, preload, IPC, BrowserWindow, Menu, Tray, Dialog, packaging, electron-builder, electron-forge, electron-fiddle, cross-platform, 桌面应用, 主进程, 渲染进程, IPC 通信, 窗口, 菜单, 托盘, 打包
@@ -0,0 +1,83 @@
1
+ # app Module API | app 模块 API
2
+
3
+ ## API Reference
4
+
5
+ Electron app module API for application lifecycle management.
6
+
7
+ ### app Methods
8
+
9
+ **Lifecycle:**
10
+ - `app.whenReady()` - Returns Promise when app is ready
11
+ - `app.quit()` - Quit the application
12
+ - `app.exit(exitCode)` - Exit immediately
13
+ - `app.relaunch([options])` - Relaunch the app
14
+
15
+ **Window Management:**
16
+ - `app.getPath(name)` - Get system path
17
+ - `app.setPath(name, path)` - Set system path
18
+ - `app.getVersion()` - Get app version
19
+ - `app.getName()` - Get app name
20
+ - `app.setName(name)` - Set app name
21
+
22
+ **Platform:**
23
+ - `app.getLocale()` - Get locale
24
+ - `app.getLocaleCountryCode()` - Get country code
25
+ - `app.isReady()` - Check if app is ready
26
+ - `app.isPackaged` - Check if app is packaged
27
+
28
+ ### app Events
29
+
30
+ - `ready` - Emitted when Electron has finished initializing
31
+ - `window-all-closed` - Emitted when all windows are closed
32
+ - `before-quit` - Emitted before app quits
33
+ - `will-quit` - Emitted when app will quit
34
+ - `quit` - Emitted when app quits
35
+ - `activate` - Emitted when app is activated (macOS)
36
+ - `second-instance` - Emitted when second instance is launched
37
+
38
+ ### Example: Basic Usage
39
+
40
+ ```javascript
41
+ const { app, BrowserWindow } = require('electron')
42
+
43
+ app.whenReady().then(() => {
44
+ createWindow()
45
+ })
46
+
47
+ app.on('window-all-closed', () => {
48
+ if (process.platform !== 'darwin') {
49
+ app.quit()
50
+ }
51
+ })
52
+
53
+ app.on('activate', () => {
54
+ if (BrowserWindow.getAllWindows().length === 0) {
55
+ createWindow()
56
+ }
57
+ })
58
+ ```
59
+
60
+ ### Example: Single Instance
61
+
62
+ ```javascript
63
+ const { app } = require('electron')
64
+
65
+ const gotTheLock = app.requestSingleInstanceLock()
66
+
67
+ if (!gotTheLock) {
68
+ app.quit()
69
+ } else {
70
+ app.on('second-instance', () => {
71
+ // Focus existing window
72
+ })
73
+ }
74
+ ```
75
+
76
+ ### Key Points
77
+
78
+ - Use app.whenReady() before creating windows
79
+ - Handle window-all-closed for proper quit
80
+ - macOS requires activate event handling
81
+ - Use requestSingleInstanceLock() for single instance
82
+ - app has full Node.js access
83
+ - Get system paths with app.getPath()
@@ -0,0 +1,84 @@
1
+ # BrowserWindow API | BrowserWindow API
2
+
3
+ ## API Reference
4
+
5
+ BrowserWindow API for creating and controlling application windows.
6
+
7
+ ### Constructor Options
8
+
9
+ **Basic:**
10
+ - `width`, `height` - Window size
11
+ - `minWidth`, `minHeight` - Minimum size
12
+ - `maxWidth`, `maxHeight` - Maximum size
13
+ - `resizable` - Whether window is resizable
14
+ - `movable` - Whether window is movable
15
+
16
+ **Display:**
17
+ - `show` - Show window when created
18
+ - `frame` - Show window frame
19
+ - `titleBarStyle` - Title bar style (macOS)
20
+ - `backgroundColor` - Background color
21
+ - `opacity` - Window opacity
22
+
23
+ **Behavior:**
24
+ - `alwaysOnTop` - Keep window on top
25
+ - `fullscreen` - Start fullscreen
26
+ - `skipTaskbar` - Skip taskbar (Linux/Windows)
27
+ - `kiosk` - Kiosk mode
28
+
29
+ **webPreferences:**
30
+ - `preload` - Preload script path
31
+ - `nodeIntegration` - Enable Node.js (not recommended)
32
+ - `contextIsolation` - Enable context isolation (recommended)
33
+ - `sandbox` - Enable sandbox
34
+
35
+ ### Instance Methods
36
+
37
+ **Content:**
38
+ - `loadURL(url[, options])` - Load URL
39
+ - `loadFile(filePath[, options])` - Load local file
40
+ - `reload()` - Reload window
41
+
42
+ **Window Control:**
43
+ - `show()` - Show window
44
+ - `hide()` - Hide window
45
+ - `close()` - Close window
46
+ - `focus()` - Focus window
47
+ - `blur()` - Remove focus
48
+
49
+ **Size/Position:**
50
+ - `setSize(width, height)` - Set size
51
+ - `getSize()` - Get size
52
+ - `setPosition(x, y)` - Set position
53
+ - `getPosition()` - Get position
54
+ - `center()` - Center window
55
+
56
+ **State:**
57
+ - `minimize()` - Minimize
58
+ - `maximize()` - Maximize
59
+ - `restore()` - Restore
60
+ - `setFullScreen(flag)` - Set fullscreen
61
+
62
+ **DevTools:**
63
+ - `webContents.openDevTools()` - Open DevTools
64
+ - `webContents.closeDevTools()` - Close DevTools
65
+
66
+ ### Instance Events
67
+
68
+ - `ready-to-show` - Emitted when window is ready
69
+ - `closed` - Emitted when window is closed
70
+ - `focus` - Emitted when window gains focus
71
+ - `blur` - Emitted when window loses focus
72
+ - `maximize` - Emitted when maximized
73
+ - `unmaximize` - Emitted when unmaximized
74
+ - `minimize` - Emitted when minimized
75
+ - `restore` - Emitted when restored
76
+
77
+ ### Key Points
78
+
79
+ - Always set contextIsolation: true
80
+ - Never set nodeIntegration: true
81
+ - Use preload script for IPC
82
+ - Handle ready-to-show for smooth loading
83
+ - Clean up window references on closed
84
+ - Use webContents for DevTools access
@@ -0,0 +1,140 @@
1
+ # Packaging | 打包
2
+
3
+ **官方文档**: https://www.electronjs.org/zh/docs/latest/,
4
+
5
+
6
+ ## Instructions
7
+
8
+ This example demonstrates how to package Electron applications for distribution.
9
+
10
+ ### Key Concepts
11
+
12
+ - Using Electron Forge
13
+ - Using electron-builder
14
+ - Platform-specific builds
15
+ - Code signing
16
+ - Auto-updater integration
17
+
18
+ ### Example: Electron Forge Setup
19
+
20
+ ```bash
21
+ # Initialize with Electron Forge
22
+ npm create electron-app@latest my-app
23
+
24
+ # Or add to existing project
25
+ npx @electron-forge/cli import
26
+ ```
27
+
28
+ ### Example: Electron Forge Configuration
29
+
30
+ ```json
31
+ // package.json
32
+ {
33
+ "name": "my-app",
34
+ "version": "1.0.0",
35
+ "main": ".vite/build/main.js",
36
+ "scripts": {
37
+ "start": "electron-forge start",
38
+ "package": "electron-forge package",
39
+ "make": "electron-forge make",
40
+ "publish": "electron-forge publish"
41
+ },
42
+ "config": {
43
+ "forge": {
44
+ "packagerConfig": {
45
+ "name": "My App",
46
+ "icon": "./assets/icon"
47
+ },
48
+ "makers": [
49
+ {
50
+ "name": "@electron-forge/maker-squirrel",
51
+ "config": {
52
+ "name": "my_app"
53
+ }
54
+ },
55
+ {
56
+ "name": "@electron-forge/maker-zip",
57
+ "platforms": ["darwin"]
58
+ },
59
+ {
60
+ "name": "@electron-forge/maker-deb",
61
+ "config": {}
62
+ },
63
+ {
64
+ "name": "@electron-forge/maker-rpm",
65
+ "config": {}
66
+ }
67
+ ]
68
+ }
69
+ }
70
+ }
71
+ ```
72
+
73
+ ### Example: electron-builder Setup
74
+
75
+ ```json
76
+ // package.json
77
+ {
78
+ "name": "my-app",
79
+ "version": "1.0.0",
80
+ "main": "main.js",
81
+ "scripts": {
82
+ "build": "electron-builder",
83
+ "build:win": "electron-builder --win",
84
+ "build:mac": "electron-builder --mac",
85
+ "build:linux": "electron-builder --linux"
86
+ },
87
+ "build": {
88
+ "appId": "com.example.myapp",
89
+ "productName": "My App",
90
+ "directories": {
91
+ "output": "dist"
92
+ },
93
+ "files": [
94
+ "main.js",
95
+ "preload.js",
96
+ "renderer/**/*",
97
+ "package.json"
98
+ ],
99
+ "win": {
100
+ "target": "nsis",
101
+ "icon": "build/icon.ico"
102
+ },
103
+ "mac": {
104
+ "target": "dmg",
105
+ "icon": "build/icon.icns",
106
+ "category": "public.app-category.utilities"
107
+ },
108
+ "linux": {
109
+ "target": "AppImage",
110
+ "icon": "build/icon.png"
111
+ }
112
+ }
113
+ }
114
+ ```
115
+
116
+ ### Example: Build Commands
117
+
118
+ ```bash
119
+ # Build for current platform
120
+ npm run build
121
+
122
+ # Build for specific platform
123
+ npm run build:win
124
+ npm run build:mac
125
+ npm run build:linux
126
+
127
+ # Build all platforms
128
+ npm run build -- --win --mac --linux
129
+ ```
130
+
131
+ ### Key Points
132
+
133
+ - Electron Forge is recommended for new projects
134
+ - electron-builder is popular and flexible
135
+ - Configure platform-specific settings
136
+ - Include only necessary files in build
137
+ - Set proper app ID and product name
138
+ - Use icons for each platform
139
+ - Code signing required for distribution
140
+ - Test builds on target platforms
@@ -0,0 +1,182 @@
1
+ # BrowserWindow | 窗口
2
+
3
+ **官方文档**: https://www.electronjs.org/zh/docs/latest/,
4
+
5
+
6
+ ## Instructions
7
+
8
+ This example demonstrates how to use BrowserWindow to create and manage application windows.
9
+
10
+ ### Key Concepts
11
+
12
+ - Creating windows
13
+ - Window options
14
+ - Loading content
15
+ - Window events
16
+ - Window methods
17
+
18
+ ### Example: Basic Window
19
+
20
+ ```javascript
21
+ const { BrowserWindow } = require('electron')
22
+ const path = require('path')
23
+
24
+ function createWindow() {
25
+ const win = new BrowserWindow({
26
+ width: 800,
27
+ height: 600,
28
+ webPreferences: {
29
+ preload: path.join(__dirname, 'preload.js'),
30
+ contextIsolation: true,
31
+ nodeIntegration: false
32
+ }
33
+ })
34
+
35
+ win.loadFile('index.html')
36
+ }
37
+
38
+ createWindow()
39
+ ```
40
+
41
+ ### Example: Window Options
42
+
43
+ ```javascript
44
+ const win = new BrowserWindow({
45
+ width: 1200,
46
+ height: 800,
47
+ minWidth: 400,
48
+ minHeight: 300,
49
+ maxWidth: 1920,
50
+ maxHeight: 1080,
51
+ resizable: true,
52
+ movable: true,
53
+ minimizable: true,
54
+ maximizable: true,
55
+ closable: true,
56
+ focusable: true,
57
+ alwaysOnTop: false,
58
+ fullscreen: false,
59
+ fullscreenable: true,
60
+ simpleFullscreen: false,
61
+ skipTaskbar: false,
62
+ kiosk: false,
63
+ title: 'My App',
64
+ icon: path.join(__dirname, 'icon.png'),
65
+ show: false, // Don't show until ready
66
+ frame: true,
67
+ titleBarStyle: 'default',
68
+ backgroundColor: '#ffffff',
69
+ webPreferences: {
70
+ preload: path.join(__dirname, 'preload.js'),
71
+ contextIsolation: true,
72
+ nodeIntegration: false
73
+ }
74
+ })
75
+
76
+ // Show when ready
77
+ win.once('ready-to-show', () => {
78
+ win.show()
79
+ })
80
+ ```
81
+
82
+ ### Example: Loading Content
83
+
84
+ ```javascript
85
+ const win = new BrowserWindow({ width: 800, height: 600 })
86
+
87
+ // Load local file
88
+ win.loadFile('index.html')
89
+
90
+ // Load URL
91
+ win.loadURL('https://example.com')
92
+
93
+ // Load with options
94
+ win.loadFile('index.html', {
95
+ query: { key: 'value' },
96
+ hash: 'section'
97
+ })
98
+ ```
99
+
100
+ ### Example: Window Events
101
+
102
+ ```javascript
103
+ const win = new BrowserWindow({ width: 800, height: 600 })
104
+
105
+ win.on('ready-to-show', () => {
106
+ win.show()
107
+ })
108
+
109
+ win.on('closed', () => {
110
+ win = null
111
+ })
112
+
113
+ win.on('focus', () => {
114
+ console.log('Window focused')
115
+ })
116
+
117
+ win.on('blur', () => {
118
+ console.log('Window blurred')
119
+ })
120
+
121
+ win.on('maximize', () => {
122
+ console.log('Window maximized')
123
+ })
124
+
125
+ win.on('unmaximize', () => {
126
+ console.log('Window unmaximized')
127
+ })
128
+
129
+ win.on('minimize', () => {
130
+ console.log('Window minimized')
131
+ })
132
+
133
+ win.on('restore', () => {
134
+ console.log('Window restored')
135
+ })
136
+ ```
137
+
138
+ ### Example: Window Methods
139
+
140
+ ```javascript
141
+ const win = new BrowserWindow({ width: 800, height: 600 })
142
+
143
+ // Show/Hide
144
+ win.show()
145
+ win.hide()
146
+
147
+ // Minimize/Maximize/Restore
148
+ win.minimize()
149
+ win.maximize()
150
+ win.restore()
151
+
152
+ // Close
153
+ win.close()
154
+
155
+ // Focus
156
+ win.focus()
157
+ win.blur()
158
+
159
+ // Position
160
+ win.setPosition(100, 100)
161
+ const [x, y] = win.getPosition()
162
+
163
+ // Size
164
+ win.setSize(1200, 800)
165
+ const [width, height] = win.getSize()
166
+
167
+ // Center
168
+ win.center()
169
+
170
+ // DevTools
171
+ win.webContents.openDevTools()
172
+ win.webContents.closeDevTools()
173
+ ```
174
+
175
+ ### Key Points
176
+
177
+ - BrowserWindow creates application windows
178
+ - Use show: false and ready-to-show event for smooth loading
179
+ - webPreferences should have contextIsolation: true
180
+ - Never set nodeIntegration: true in renderer
181
+ - Use loadFile() for local files, loadURL() for remote
182
+ - Handle closed event to clean up references