Live Reload __CAPGO_KEEP_0__ 仓库
复制一个包含安装步骤和本插件的完整Markdown指南的设置命令。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-live-reload`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/live-reload/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
您可以使用我们的AI辅助设置来安装插件。使用以下命令将Capgo技能添加到您的AI工具中:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins然后使用以下提示:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-live-reload` plugin in my project.如果您更喜欢手动设置,请按照以下命令安装插件并遵循以下平台特定的说明:
bun add @capgo/capacitor-live-reloadbunx cap sync导入
导入部分import { LiveReload } from '@capgo/capacitor-live-reload';API概述
概述部分:APIconfigureServer
配置服务器用于后续连接的远程开发服务器设置
import { LiveReload } from '@capgo/capacitor-live-reload';
await LiveReload.configureServer({} as ConfigureServerOptions);connect
连接如果没有活动的 WebSocket 连接,则建立一个 WebSocket 连接
import { LiveReload } from '@capgo/capacitor-live-reload';
await LiveReload.connect();disconnect
断开关闭当前 WebSocket 连接并禁用自动重连
import { LiveReload } from '@capgo/capacitor-live-reload';
await LiveReload.disconnect();getStatus
获取当前连接状态复制到剪贴板
import { LiveReload } from '@capgo/capacitor-live-reload';
await LiveReload.getStatus();reload
Section titled “reload”触发 Capacitor WebView 的全局重载。
import { LiveReload } from '@capgo/capacitor-live-reload';
await LiveReload.reload();reloadFile
Section titled “reloadFile”如果运行时支持则重载单个文件/模块(否则重载全局)。
import { LiveReload } from '@capgo/capacitor-live-reload';
await LiveReload.reloadFile({} as FileUpdatePayload);Type Reference
Section titled “Type Reference”ConfigureServerOptions
Section titled “ConfigureServerOptions”export interface ConfigureServerOptions { /** * Base URL for the dev server (e.g. https://dev.local:5173). * When a connection is established the Capacitor WebView navigates to this URL. */ url: string; /** Optional WebSocket path override when different from /ws. */ websocketPath?: string; /** Extra headers sent when creating the WebSocket connection. */ headers?: Record<string, string>; /** Automatically reconnect when the socket closes unexpectedly. Default: true. */ autoReconnect?: boolean; /** Delay (ms) between reconnection attempts. Default: 2000. */ reconnectInterval?: number;}LiveReloadStatus
Section titled “LiveReloadStatus”export interface LiveReloadStatus { connected: boolean; url?: string;}FileUpdatePayload
文件更新载荷export interface FileUpdatePayload { path: string; hash?: string;}LiveReloadEventCallback
实时重载事件回调export type LiveReloadEventCallback = (event: LiveReloadEventPayload) => void;LiveReloadStatusCallback
实时重载状态回调export type LiveReloadStatusCallback = (status: LiveReloadStatus) => void;LiveReloadEventPayload
实时重载事件载荷export interface LiveReloadEventPayload { type: LiveReloadMessageType; /** Populated when type === 'file-update'. */ file?: FileUpdatePayload; /** Optional human-readable message for errors or status changes. */ message?: string;}LiveReloadMessageType
实时重载消息类型export type LiveReloadMessageType = 'full-reload' | 'file-update' | 'error' | 'connected' | 'disconnected';真实来源
文件更新载荷本页面由插件生成 src/definitions.ts. 重新同步时,公共 API 上游发生变化。
从 Getting Started 继续
标题为“从 Getting Started 继续”如果您正在使用 Getting Started 来规划仪表板和 API 操作,连接它到 使用 @capgo/capacitor-live-reload 为 native 能力在使用 @capgo/capacitor-live-reload 中,API Overview 为 API Overview 实现细节 介绍 在介绍中关于实现细节的 API 键 在 API 键中关于实现细节的, 和 设备 在设备中关于实现细节的。