开始获取
复制一个包含安装步骤和本插件的全 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 syncimport { KeepAwake } from '@capgo/capacitor-keep-awake';keepAwake
Section titled “keepAwake”防止设备屏幕自动熄屏
import { KeepAwake } from '@capgo/capacitor-keep-awake';
await KeepAwake.keepAwake();console.log('Screen will stay awake');allowSleep
Section titled “allowSleep”允许设备屏幕自动熄屏(关闭保持唤醒)
import { KeepAwake } from '@capgo/capacitor-keep-awake';
await KeepAwake.allowSleep();console.log('Screen can now dim');isSupported
Section titled “isSupported”检查当前平台是否支持保持唤醒功能
import { KeepAwake } from '@capgo/capacitor-keep-awake';
const { isSupported } = await KeepAwake.isSupported();if (isSupported) { console.log('Keep awake is supported');}isKeptAwake
Section titled “isKeptAwake”检查设备是否正在保持唤醒
import { KeepAwake } from '@capgo/capacitor-keep-awake';
const { isKeptAwake } = await KeepAwake.isKeptAwake();console.log('Is kept awake:', isKeptAwake);类型参考
类型参考部分IsSupportedResult
是否支持结果isSupported()方法的返回结果。
export interface IsSupportedResult { /** * Whether keep awake is supported on the current platform. * * @since 1.0.0 */ isSupported: boolean;}IsKeptAwakeResult
是否保持唤醒结果isKeptAwake()方法的返回结果。
export interface IsKeptAwakeResult { /** * Whether the device is currently being kept awake. * * @since 1.0.0 */ isKeptAwake: boolean;}真实来源
真实来源部分本页面由插件生成 src/definitions.ts. 当 upstream 的 API 变更时,请重新运行同步。
继续从 Getting Started
标题为“继续从 Getting Started”如果您正在使用 Getting Started 来规划仪表板和 API 操作,请将其连接到 使用 @capgo/capacitor-keep-awake 用于在 Using @capgo/capacitor-keep-awake 中实现的本机功能 API Overview 用于在 API Overview 中实现的详细信息 介绍 用于在介绍中实现的详细信息 API 键 用于实现细节的 API 键,和 设备 用于实现细节的设备。