示例工程 05-preload-and-contextbridge
05-preload-and-contextbridge/app/shared/ipc.ts
/**
* 三端唯一来源:通道名与类型。
* 本文件不 import electron,渲染进程也能安全引用。
*/
export const CH = {
config: "bridge:config",
ping: "bridge:ping",
} as const;
export type BridgeConfig = {
contextIsolation: boolean;
sandbox: boolean;
nodeIntegration: boolean;
preload: string;
};
export type BridgeProbe = {
hasApi: boolean;
hasPing: boolean;
hasRequire: boolean;
hasIpcRenderer: boolean;
};
export type Api = {
config(): Promise<BridgeConfig>;
ping(message: string): Promise<string>;
};