feat: 完成 Web2App 核心功能实现

- Electron 主进程:窗口管理、IPC、项目读写、打包引擎
- Vue 3 前端:4 个视图页面、3 个组件、Pinia 状态管理
- 生成应用模板:Express 后端 + Electron 窗口
- 支持资源导入、应用配置、跨平台打包
This commit is contained in:
gmh01
2026-07-23 18:25:35 +08:00
parent b67e27beb1
commit 2f3ec636e0
26 changed files with 8455 additions and 0 deletions

30
electron/preload.js Normal file
View File

@@ -0,0 +1,30 @@
const { contextBridge, ipcRenderer } = require('electron')
contextBridge.exposeInMainWorld('api', {
dialog: {
selectDirectory: () => ipcRenderer.invoke('dialog:selectDirectory'),
selectFile: (options) => ipcRenderer.invoke('dialog:selectFile', options),
selectIcon: () => ipcRenderer.invoke('dialog:selectIcon'),
saveFile: (options) => ipcRenderer.invoke('dialog:saveFile', options)
},
dir: {
readTree: (dirPath) => ipcRenderer.invoke('dir:readTree', dirPath)
},
project: {
create: (name, dir) => ipcRenderer.invoke('project:create', name, dir),
load: (projectPath) => ipcRenderer.invoke('project:load', projectPath),
save: (projectPath, data) => ipcRenderer.invoke('project:save', projectPath, data),
importFiles: (projectPath, files) => ipcRenderer.invoke('project:importFiles', projectPath, files),
removeFile: (projectPath, relativePath) => ipcRenderer.invoke('project:removeFile', projectPath, relativePath),
setIcon: (projectPath, iconPath) => ipcRenderer.invoke('project:setIcon', projectPath, iconPath)
},
pack: {
start: (projectPath, outputPath) => ipcRenderer.invoke('pack:start', projectPath, outputPath),
cancel: () => ipcRenderer.invoke('pack:cancel'),
onProgress: (callback) => {
const handler = (_event, progress) => callback(progress)
ipcRenderer.on('pack:progress', handler)
return () => ipcRenderer.removeListener('pack:progress', handler)
}
}
})