feat(electron): 添加Electron桌面应用支持
- 新增Electron主进程、预加载脚本和构建配置 - 修改前端配置以支持Electron打包 - 更新项目文档和依赖 - 重构API调用使用统一axios实例
This commit is contained in:
14
app/preload.js
Normal file
14
app/preload.js
Normal file
@@ -0,0 +1,14 @@
|
||||
const { contextBridge, ipcRenderer } = require('electron');
|
||||
|
||||
/**
|
||||
* 预加载脚本,用于在渲染进程和主进程之间通信
|
||||
* 提供安全的API给渲染进程访问主进程功能
|
||||
*/
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
/**
|
||||
* 获取环境变量值
|
||||
* @param {string} key - 环境变量名称
|
||||
* @returns {Promise<string>} - 环境变量值
|
||||
*/
|
||||
getEnv: (key) => ipcRenderer.invoke('get-env', key),
|
||||
});
|
||||
Reference in New Issue
Block a user