项目文件夹

文件
caorushizi 8224c68f66 refactor(ui): optimize source-extract page and browser navigation flow
Extract shared navigation logic into useBrowserActions hook, fix race conditions
in sniffing helper, add event listener cleanup in webview service, split store
selectors for granular re-renders, memoize list items, throttle ResizeObserver,
and add loading/error states to favorites list. Also remove unused getMachineId
IPC handler and fix IPC callback type signatures.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-13 00:19:14 +08:00
..
2025-11-01 16:23:35 +08:00
2025-11-03 03:50:35 +08:00
2026-04-02 00:15:20 +08:00

@mediago/electron-preload

Electron preload script package for MediaGo application.

Overview

This package contains the preload script that bridges the communication between the Electron main process and renderer process. It exposes safe APIs to the frontend through Electron's contextBridge.

Features

  • Safe IPC communication between main and renderer processes
  • Type-safe API definitions
  • Centralized preload logic for better maintainability
  • Optimized build with esbuild

Usage

In your Electron main process:

import { join } from "path";
import { BrowserWindow } from "electron";

const win = new BrowserWindow({
  webPreferences: {
    nodeIntegration: false,
    contextIsolation: true,
    preload: join(
      __dirname,
      "../node_modules/@mediago/electron-preload/dist/preload.js",
    ),
  },
});

Development

# Build the package
pnpm build

# Watch mode for development
pnpm dev

# Type checking
pnpm types

API

The preload script exposes all Electron APIs through window.electron object, providing type-safe access to:

  • File system operations
  • Download management
  • Browser window controls
  • Settings management
  • And much more...

See the MediaGoApi type definition for complete API reference.