__CAPGO_KEEP_0__ - 为 __CAPGO_KEEP_1__ 应用程序提供实时更新

开始使用

GitHub

您可以使用我们的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-reload
bunx cap sync
import { LiveReload } from '@capgo/capacitor-live-reload';

API 简介

API 简介

configureServer

配置服务器

存储远程开发服务器设置用于后续连接

import { LiveReload } from '@capgo/capacitor-live-reload';
await LiveReload.configureServer({} as ConfigureServerOptions);

复制到剪贴板

import { LiveReload } from '@capgo/capacitor-live-reload';
await LiveReload.connect();

configureServer

import { LiveReload } from '@capgo/capacitor-live-reload';
await LiveReload.disconnect();

获取当前连接状态。

import { LiveReload } from '@capgo/capacitor-live-reload';
await LiveReload.getStatus();

触发 Capacitor WebView 的全量重载。

import { LiveReload } from '@capgo/capacitor-live-reload';
await LiveReload.reload();

如果运行时支持,重载单个文件/模块(否则重载全量)。

import { LiveReload } from '@capgo/capacitor-live-reload';
await LiveReload.reloadFile({} as FileUpdatePayload);
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;
}
export interface LiveReloadStatus {
connected: boolean;
url?: string;
}
export interface FileUpdatePayload {
path: string;
hash?: string;
}

LiveReloadEventCallback

标题:LiveReload事件回调
export type LiveReloadEventCallback = (event: LiveReloadEventPayload) => void;

LiveReloadStatusCallback

标题:LiveReload状态回调
export type LiveReloadStatusCallback = (status: LiveReloadStatus) => void;

LiveReloadEventPayload

标题:LiveReload事件载荷
export interface LiveReloadEventPayload {
type: LiveReloadMessageType;
/** Populated when type === 'file-update'. */
file?: FileUpdatePayload;
/** Optional human-readable message for errors or status changes. */
message?: string;
}

LiveReloadMessageType

标题:LiveReload消息类型
export type LiveReloadMessageType = 'full-reload' | 'file-update' | 'error' | 'connected' | 'disconnected';

真实数据来源

标题:真实数据来源

该页面是从插件的 src/definitions.ts重新同步公共API时,API发生了变化。

如果您正在使用 开始 计划仪表板和API操作时,连接它到 使用@capgo/capacitor-live-reload 为使用@capgo/capacitor-live-reload中的本机功能 API 简介 为 API 简介 的实现细节 介绍 为介绍 的实现细节 API 密钥 为 API 密钥 的实现细节, 和 设备 为设备 的实现细节。