hololake-system-architecture/product-source/hololake-desktop/electron/preload.ts
冰朔 047f37e87e feat(product-source): HoloLake Desktop v0.5.0 — Electron 桌面知识库应用
铸渊 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 配置)
2026-08-08 07:21:04 +08:00

26 lines
796 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 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'),
},
});