Convert web app to Electron desktop application
- Add Electron main process with developer tools support - Create preload script for secure context bridge - Configure electron-builder for packaging - Update Vite config for Electron compatibility (base: './') - Add environment variable support for API host configuration - Fix i18n to use relative paths for Electron file protocol - Restore multi-port backend architecture (8081-8085) - Add enhanced backend startup script with port checking - Update package.json with Electron dependencies and build scripts 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
17
electron/preload-simple.cjs
Normal file
17
electron/preload-simple.cjs
Normal file
@@ -0,0 +1,17 @@
|
||||
const { contextBridge, ipcRenderer } = require('electron');
|
||||
|
||||
// 暴露简化的 API 给渲染进程
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
// 获取应用版本
|
||||
getAppVersion: () => ipcRenderer.invoke('get-app-version'),
|
||||
|
||||
// 获取平台信息
|
||||
getPlatform: () => ipcRenderer.invoke('get-platform'),
|
||||
|
||||
// 环境检测
|
||||
isElectron: true,
|
||||
isDev: process.env.NODE_ENV === 'development',
|
||||
});
|
||||
|
||||
// 添加一个标识,让渲染进程知道这是 Electron 环境
|
||||
window.IS_ELECTRON = true;
|
||||
Reference in New Issue
Block a user