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,
|
2026-08-09 10:43:56 +08:00
|
|
|
|
version: '0.7.1',
|
2026-08-08 07:21:04 +08:00
|
|
|
|
|
|
|
|
|
|
// 数据目录
|
|
|
|
|
|
getDataPath: () => ipcRenderer.invoke('get-data-path'),
|
|
|
|
|
|
|
2026-08-08 11:15:34 +08:00
|
|
|
|
knowledge: {
|
|
|
|
|
|
importFolder: () => ipcRenderer.invoke('knowledge:import-folder'),
|
|
|
|
|
|
},
|
|
|
|
|
|
|
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-09 03:37:41 +08:00
|
|
|
|
testConfig: () => ipcRenderer.invoke('agent:test-config'),
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
server: {
|
|
|
|
|
|
list: () => ipcRenderer.invoke('server:list'),
|
|
|
|
|
|
connect: (nodeId: string) => ipcRenderer.invoke('server:connect', nodeId),
|
|
|
|
|
|
domainRegistry: () => ipcRenderer.invoke('server:domain-registry'),
|
|
|
|
|
|
session: (nodeId?: string) => ipcRenderer.invoke('server:session', nodeId),
|
|
|
|
|
|
login: (input: { nodeId: string; username: string; password: string }) =>
|
|
|
|
|
|
ipcRenderer.invoke('server:login', input),
|
|
|
|
|
|
logout: () => ipcRenderer.invoke('server:logout'),
|
|
|
|
|
|
repositories: () => ipcRenderer.invoke('server:repositories'),
|
|
|
|
|
|
createRepository: (input: { name: string; description?: string }) =>
|
|
|
|
|
|
ipcRenderer.invoke('server:create-repository', input),
|
|
|
|
|
|
gitRemote: (fullName: string) => ipcRenderer.invoke('server:git-remote', fullName),
|
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
|
|
|
|
});
|