跳过内容

开始使用

终端窗口
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');
}

检查设备是否当前保持屏幕唤醒.

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

isSupported()方法的返回结果.

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

isKeptAwake()方法的返回结果.

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

本页面由插件生成 src/definitions.ts当公共API上游发生变化时,请重新同步。