跳过内容

入门

GitHub

您可以使用我们的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-awake
bunx 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

允许睡眠

允许设备屏幕自动熄屏(关闭保持唤醒)

import { KeepAwake } from '@capgo/capacitor-keep-awake';
await KeepAwake.allowSleep();
console.log('Screen can now dim');

isSupported

是否支持

Section titled “isKeptAwake”

import { KeepAwake } from '@capgo/capacitor-keep-awake';
const { isSupported } = await KeepAwake.isSupported();
if (isSupported) {
console.log('Keep awake is supported');
}

复制到剪贴板

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

IsKeptAwakeResult

是否保持唤醒结果

export interface IsKeptAwakeResult {
/**
* Whether the device is currently being kept awake.
*
* @since 1.0.0
*/
isKeptAwake: boolean;
}

保持唤醒()方法的返回结果

真实来源

类型标题 “真实来源” src/definitions.ts本页面是由插件的源代码生成的。重新同步公共API时,源代码会从上游更新。

继续从 Getting Started

标题:继续从 Getting Started

如果您正在使用 开始使用 来规划仪表板和 API 操作,连接它与 使用 @capgo/capacitor-keep-awake 为使用 @capgo/capacitor-keep-awake 的原生能力 API 概述 为 API 概述 的实现细节 介绍 为介绍 的实现细节 API 密钥 为 API 的实现细节 设备 为 __CAPGO_KEEP_0__ 的实现细节