跳过内容

Getting Started

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-flash` plugin in my project.

如果您prefer Manual Setup,安装插件并运行以下命令并遵循以下平台特定的说明:

Terminal 窗口
bun add @capgo/capacitor-flash
bunx cap sync
import { CapacitorFlash } from '@capgo/capacitor-flash';

isAvailable

__CAPGO_KEEP_1__

检查设备上是否可用闪光灯功能.

import { CapacitorFlash } from '@capgo/capacitor-flash';
const { value } = await CapacitorFlash.isAvailable();
if (value) {
console.log('Flashlight is available');
}

打开闪光灯.

import { CapacitorFlash } from '@capgo/capacitor-flash';
// Turn on at full brightness
await CapacitorFlash.switchOn({ intensity: 1.0 });
// Turn on at half brightness
await CapacitorFlash.switchOn({ intensity: 0.5 });

关闭手电筒。

import { CapacitorFlash } from '@capgo/capacitor-flash';
await CapacitorFlash.switchOff();

检查手电筒当前是否打开或关闭。

import { CapacitorFlash } from '@capgo/capacitor-flash';
const { value } = await CapacitorFlash.isSwitchedOn();
console.log('Flashlight is on:', value);

切换手电筒的开关。

import { CapacitorFlash } from '@capgo/capacitor-flash';
const { value } = await CapacitorFlash.toggle();
console.log('Flashlight toggled, now on:', value);

本页面由插件生成 src/definitions.ts. 当上游的公共 API 变更时,请重新同步。

如果您正在使用 Getting Started 来规划仪表板和 API 操作,请将其与 使用 @capgo/capacitor-flash for the native capability in Using @capgo/capacitor-flash, 使用 @API/__CAPGO_KEEP_1__-flash for the implementation detail in API Overview, 在使用 @__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-flash 的实现细节中, 为《介绍》中的实现细节 API 键 为《API 键》中的实现细节,以及 设备 为《设备》中的实现细节