docs/archives/103-desktop-architecture/desktop-implementation.md
将现有的 Prompt Optimizer Web 应用改造为桌面端应用,解决 API 调用的 CORS 跨域问题。
// core 包中的环境检测
if (isRunningInElectron()) {
// 注入自定义 fetch 实现
globalThis.fetch = electronFetch;
}
// 主进程
ipcMain.handle('fetch', async (event, url, options) => {
// 使用 Node.js 的 fetch 处理请求
});
// 预加载脚本
contextBridge.exposeInMainWorld('electronAPI', {
fetch: (url, options) => ipcRenderer.invoke('fetch', url, options)
});
核心目标 100% 达成:
技术实现:
验证状态:
任务状态: ✅ 完全成功
完成度: 100%
最后更新: 2025-07-01