30 lines
874 B
TypeScript
30 lines
874 B
TypeScript
/**
|
||
* HoloLake Desktop · Preload 脚本
|
||
*
|
||
* 在渲染进程和主进程之间建立安全桥梁。
|
||
* 渲染进程不能直接访问 Node.js API,只能通过这个桥梁通信。
|
||
*/
|
||
|
||
import { contextBridge, ipcRenderer } from 'electron';
|
||
|
||
// 暴露给渲染进程的安全 API
|
||
contextBridge.exposeInMainWorld('hololake', {
|
||
// 应用信息
|
||
platform: process.platform,
|
||
version: '0.5.1',
|
||
|
||
// 数据目录
|
||
getDataPath: () => ipcRenderer.invoke('get-data-path'),
|
||
|
||
knowledge: {
|
||
importFolder: () => ipcRenderer.invoke('knowledge:import-folder'),
|
||
},
|
||
|
||
agent: {
|
||
getConfig: () => ipcRenderer.invoke('agent:get-config'),
|
||
saveConfig: (config: { baseUrl: string; model: string; apiKey?: string }) =>
|
||
ipcRenderer.invoke('agent:save-config', config),
|
||
},
|
||
|
||
// Forgejo 通过本地知识库 API 管理;此桥只保留非敏感应用信息。
|
||
});
|