index.ts 783 B

1234567891011121314151617181920
  1. import { contextBridge, ipcRenderer } from 'electron';
  2. import { ElectronEnum } from '../../src/enums/jeecgEnum';
  3. contextBridge.exposeInMainWorld(ElectronEnum.ELECTRON_API, {
  4. openInBrowser: (url: string) => ipcRenderer.send('open-in-browser', url),
  5. // 发送消息通知
  6. sendNotification: (title: string, body: string, path: string) => {
  7. ipcRenderer.send('notify-with-path', { title, body, path });
  8. },
  9. // 绑定路由跳转
  10. onNavigate: (cb: (path: string) => void) => {
  11. ipcRenderer.on('navigate-to', (_, path) => cb(path));
  12. },
  13. // 任务栏闪
  14. sendNotifyFlash: () => ipcRenderer.send('notify-flash'),
  15. // 托盘闪动
  16. trayFlash: () => ipcRenderer.send('tray-flash'),
  17. // 托盘停止闪动
  18. trayFlashStop: () => ipcRenderer.send('tray-flash-stop'),
  19. });