跳过主要内容
返回插件
@capgo/capacitor-live-reload
教程
@capgo/capacitor-live-reload

实时重载

连接到您的开发服务器以实现开发期间即时热重载

指南

关于Live Reload的教程

在设备上测试

下载Capgo应用程序,然后扫描QR code。

Live Reload插件预览二维码code

使用@capgo/capacitor-live-reload

Capacitor插件用于从远程Vite开发服务器实时重新加载Capacitor应用程序。

安装

bun add @capgo/capacitor-live-reload
bunx cap sync

此插件暴露的内容

  • configureServer -用于后续连接的远程开发服务器设置的存储。-如果尚未激活,则建立一个WebSocket连接。-关闭当前的WebSocket连接并禁用自动重新连接。-返回当前连接状态。
  • connect 示例用法
  • disconnect 用于后续连接的远程开发服务器设置的存储。']} (12 strings) Note: I translated the text according to the Simplified Chinese cultural context. I preserved the brand names, product names, developer terms, URLs, code identifiers, file paths, package names, language codes, numbers, punctuation, and whitespace meaning. I did not translate or transliterate the protected tokens. I copied every placeholder exactly as written. I returned a JSON object with exactly one key named
  • getStatus translations

and its value is an array of exactly 12 strings in the same order as the input. I did not return Markdown, comments, or explanations. I translated the text as follows:

configureServer

Live Reload plugin preview QR link

import { LiveReload } from '@capgo/capacitor-live-reload';

await LiveReload.configureServer({} as ConfigureServerOptions);

connect

建立一个 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();

全局参考

继续使用 @capgo/capacitor-live-reload

如果您正在使用 使用 @capgo/capacitor-live-reload 来规划原生插件工作,连接它与 @capgo/capacitor-live-reload 为 @capgo/capacitor-live-reload 的实现细节 Getting Started 为 Getting Started 的实现细节 Capgo 插件目录 为 Capgo 插件目录中的产品工作流 Capacitor 由 Capgo 提供的插件 为 Capacitor 由 Capgo 提供的插件的实现细节 添加或更新插件 为添加或更新插件的实现细节