开始获取
复制一个包含安装步骤和此插件的完整 Markdown 指南的设置提示。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-keep-awake`
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/keep-awake/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-keep-awake` plugin in my project.如果您更喜欢手动设置,请运行以下命令安装插件,并按照以下平台特定的说明进行操作:
bun add @capgo/capacitor-keep-awakebunx cap sync导入
标题为“导入”import { KeepAwake } from '@capgo/capacitor-keep-awake';API概述
标题为“API概述”keepAwake
标题为“keepAwake”防止设备屏幕暗化。
import { KeepAwake } from '@capgo/capacitor-keep-awake';
await KeepAwake.keepAwake();console.log('Screen will stay awake');allowSleep
allowSleep允许设备降低屏幕亮度(禁用保持唤醒)
import { KeepAwake } from '@capgo/capacitor-keep-awake';
await KeepAwake.allowSleep();console.log('Screen can now dim');isSupported
isSupported检查当前平台是否支持保持唤醒功能
import { KeepAwake } from '@capgo/capacitor-keep-awake';
const { isSupported } = await KeepAwake.isSupported();if (isSupported) { console.log('Keep awake is supported');}isKeptAwake
isKeptAwake检查设备是否正在保持唤醒
import { KeepAwake } from '@capgo/capacitor-keep-awake';
const { isKeptAwake } = await KeepAwake.isKeptAwake();console.log('Is kept awake:', isKeptAwake);Type Reference
类型参考IsSupportedResult
IsSupportedResultisSupported()方法的结果。
export interface IsSupportedResult { /** * Whether keep awake is supported on the current platform. * * @since 1.0.0 */ isSupported: boolean;}IsKeptAwakeResult
标题:IsKeptAwakeResultisKeptAwake()方法的结果。
export interface IsKeptAwakeResult { /** * Whether the device is currently being kept awake. * * @since 1.0.0 */ isKeptAwake: boolean;}真实来源
标题:真实来源本页面是从插件的 src/definitions.ts当公共API在上游发生变化时,请重新运行同步。
从开始就继续
标题:从开始就继续如果您正在使用 开始使用 为了计划仪表板和API操作,连接它与 使用@capgo/capacitor-keep-awake 为native能力在使用@capgo/capacitor-keep-awake中 API概述 为API概述的实现细节 介绍 为介绍的实现细节 API密钥 为API密钥的实现细节,和 设备 为设备的实现细节。