开始使用
复制一个带有安装步骤和完整 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.
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
允许设备变暗(禁用keep awake)复制到剪贴板
import { KeepAwake } from '@capgo/capacitor-keep-awake';
await KeepAwake.allowSleep();console.log('Screen can now dim');isSupported
Section titled “allowSleep”检查当前平台是否支持保持屏幕唤醒功能.
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);类型参考
标题:类型参考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上游发生变化时,请重新同步。