2026-08-08 07:21:04 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 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'),
|
|
|
|
|
|
|
2026-08-08 10:39:18 +08:00
|
|
|
|
agent: {
|
|
|
|
|
|
getConfig: () => ipcRenderer.invoke('agent:get-config'),
|
|
|
|
|
|
saveConfig: (config: { baseUrl: string; model: string; apiKey?: string }) =>
|
|
|
|
|
|
ipcRenderer.invoke('agent:save-config', config),
|
2026-08-08 07:21:04 +08:00
|
|
|
|
},
|
2026-08-08 10:39:18 +08:00
|
|
|
|
|
|
|
|
|
|
// Forgejo 通过本地知识库 API 管理;此桥只保留非敏感应用信息。
|
2026-08-08 07:21:04 +08:00
|
|
|
|
});
|