开始入门
复制一个设置提示,包括安装步骤和此插件的完整 Markdown 指南。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-flash`
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/flash/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-flash` plugin in my project.如果您更喜欢手动设置,请按照以下命令安装插件并遵循以下平台特定的说明:
bun add @capgo/capacitor-flashbunx cap syncimport { CapacitorFlash } from '@capgo/capacitor-flash';API概述
名为“API概述”的部分isAvailable
名为“isAvailable”的部分检查设备上是否可用闪光灯功能。
import { CapacitorFlash } from '@capgo/capacitor-flash';
const { value } = await CapacitorFlash.isAvailable();if (value) { console.log('Flashlight is available');}switchOn
名为“switchOn”的部分打开闪光灯。
import { CapacitorFlash } from '@capgo/capacitor-flash';
// Turn on at full brightnessawait CapacitorFlash.switchOn({ intensity: 1.0 });
// Turn on at half brightnessawait CapacitorFlash.switchOn({ intensity: 0.5 });switchOff
Section titled “switchOff”熄灭手电筒。
import { CapacitorFlash } from '@capgo/capacitor-flash';
await CapacitorFlash.switchOff();isSwitchedOn
Section titled “isSwitchedOn”检查手电筒是否处于开启或关闭状态。
import { CapacitorFlash } from '@capgo/capacitor-flash';
const { value } = await CapacitorFlash.isSwitchedOn();console.log('Flashlight is on:', value);toggle
Section titled “toggle”切换手电筒开启或关闭。
import { CapacitorFlash } from '@capgo/capacitor-flash';
const { value } = await CapacitorFlash.toggle();console.log('Flashlight toggled, now on:', value);真实数据来源
Section titled “真实数据来源”本页面由插件生成。 src/definitions.ts. 当 public API 在上游发生变化时,请重新同步。
继续从 Getting Started
标题为“继续从 Getting Started”如果您正在使用 Getting Started 来规划仪表板和 API 操作,请将其连接到 使用 @capgo/capacitor-flash 为在 Using @capgo/capacitor-flash 中的原生功能 API Overview 为在 API Overview 中的实现细节 Introduction 为在 Introduction 中的实现细节 API 键 用于API 键的实现细节,以及 设备 用于设备的实现细节。