跳过内容

Getting Started

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

复制到剪贴板

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

检查设备是否正在保持唤醒状态。

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

keepAwake

import { KeepAwake } from '@capgo/capacitor-keep-awake';
const { isKeptAwake } = await KeepAwake.isKeptAwake();
console.log('Is kept awake:', isKeptAwake);

类型参考

类型参考

IsSupportedResult

是否支持结果

是否支持方法的返回结果

export interface IsSupportedResult {
/**
* Whether keep awake is supported on the current platform.
*
* @since 1.0.0
*/
isSupported: boolean;
}

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

如果您正在使用 Getting Started 来规划仪表板和API操作,请将其连接到 使用@capgo/capacitor-keep-awake 为native能力在使用@capgo/capacitor-keep-awake 中API概述 为API概述中的实现细节 中__CAPGO_KEEP_0__概述 为实现细节中的介绍 API 键 了解API 键的实现细节,以及 设备 了解设备的实现细节。