铸渊 2026-08-08 开发,冰朔架构决策: - 知识库放桌面,不放服务器 - Forgejo 是 Git 引擎,光湖自己维护更新,不接上游 - 不部署 Forgejo 源码,只引用 MANIFEST + 离线包 架构: - Electron v35(Mac arm64)+ Vite + React 19 - 复用 guanghu-knowledge-base 前端组件 - Electron 主进程自动启动 Express + Git 引擎后端 - 数据存储:~/Library/Application Support/HoloLake Era/data/ - Forgejo 离线包(桌面)作为 Git 远程仓库对接 构建: - npx electron-builder --mac --dir → HoloLake Era.app - 签名后续用 Developer ID 补(CSC_IDENTITY_AUTO_DISCOVERY=false) 文件: - electron/main.ts(Electron 主进程:窗口+服务器+生命周期) - electron/preload.ts(IPC 安全桥梁:Forgejo 远程管理接口) - forgejo/INTEGRATION.md(Forgejo 集成声明 + 更新策略) - forgejo/MANIFEST.sha256(离线包校验清单) - forgejo/icon.icns(应用图标,来自 HoloLake Era v0.4.6) - vite.config.ts(复用知识库前端,构建到 dist/) - tsconfig.electron.json(Electron TypeScript 配置)
26 lines
796 B
TypeScript
26 lines
796 B
TypeScript
/**
|
||
* HoloLake Desktop · Preload 脚本
|
||
*
|
||
* 在渲染进程和主进程之间建立安全桥梁。
|
||
* 渲染进程不能直接访问 Node.js API,只能通过这个桥梁通信。
|
||
*/
|
||
|
||
import { contextBridge, ipcRenderer } from 'electron';
|
||
|
||
// 暴露给渲染进程的安全 API
|
||
contextBridge.exposeInMainWorld('hololake', {
|
||
// 应用信息
|
||
platform: process.platform,
|
||
version: '0.5.0',
|
||
|
||
// 数据目录
|
||
getDataPath: () => ipcRenderer.invoke('get-data-path'),
|
||
|
||
// Forgejo 远程仓库管理(预留接口)
|
||
forgejo: {
|
||
getRemotes: () => ipcRenderer.invoke('forgejo:get-remotes'),
|
||
addRemote: (url: string) => ipcRenderer.invoke('forgejo:add-remote', url),
|
||
push: () => ipcRenderer.invoke('forgejo:push'),
|
||
pull: () => ipcRenderer.invoke('forgejo:pull'),
|
||
},
|
||
});
|