跳过内容

开始使用

终端窗口
bun add @capgo/capacitor-keep-awake
bunx cap sync
import { KeepAwake } from '@capgo/capacitor-keep-awake';

防止设备降低屏幕亮度。

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

类型参考

类型参考

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当公共API在上游发生变化时,请重新同步