跳过内容

开始

GitHub

安装

安装

您可以使用我们的AI辅助设置来安装插件。将Capgo技能添加到您的AI工具中,使用以下命令:

终端窗口
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

context

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-flash` plugin in my project.

如果您更喜欢手动设置,请运行以下命令安装插件,并按照以下平台特定的说明进行操作:

终端窗口
bun add @capgo/capacitor-flash
bunx cap sync

Import

导入
import { CapacitorFlash } from '@capgo/capacitor-flash';

API 简介

API概述

isAvailable

导入

__CAPGO_KEEP_0__概述

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();

isSwitchedOn

关闭手电筒

检查手电筒是否开启或关闭

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

标题:继续从Getting Started

如果您正在使用 开始使用 来规划仪表板和API操作,请将其与 使用@capgo/capacitor-flash 使用@capgo/capacitor-flash API概述 API概述 简介 为简介中的实现细节 API 键 为API 键中的实现细节 设备 context