From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/wakelocksentinel/index.html | 73 +++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 files/zh-cn/web/api/wakelocksentinel/index.html (limited to 'files/zh-cn/web/api/wakelocksentinel/index.html') diff --git a/files/zh-cn/web/api/wakelocksentinel/index.html b/files/zh-cn/web/api/wakelocksentinel/index.html new file mode 100644 index 0000000000..4dc7f06435 --- /dev/null +++ b/files/zh-cn/web/api/wakelocksentinel/index.html @@ -0,0 +1,73 @@ +--- +title: WakeLockSentinel +slug: Web/API/WakeLockSentinel +translation_of: Web/API/WakeLockSentinel +--- +

{{APIRef("Screen Wake Lock API")}}{{SeeCompatTable}}{{securecontext_header}}

+ +

The WakeLockSentinel interface of Screen Wake Lock API provides a handle to a platform wake lock used to prevent screen from turning off, dimming, or displaying a screen saver.

+ +

属性

+ +
+
{{DOMxRef("WakeLockSentinel.type")}} {{readonlyInline}}
+
Wake lock type. Currently it is always "screen".
+
+ +

方法

+ +
+
{{DOMxRef("WakeLockSentinel.release","WakeLockSentinel.release()")}}
+
Returns a {{JSxRef("Promise")}} that resolves without a value after requesting the underlying wake lock is released.
+
+ +

事件处理程序

+ +
+
{{DOMxRef("WakeLockSentinel.onrelease")}}
+
Event handler for release event type which occurs when WakeLockSentinel object's handle has been releases due to either a release() method being called or because {{Glossary("User Agent")}} releases the lock.
+
+ +

示例

+ +

The following example acquires a screen wake lock and then releases it in 10 minutes:

+ +
function tryKeepScreenAlive(minutes) {
+  navigator.wakeLock.request("screen").then(lock => {
+    setTimeout(() => lock.release(), minutes * 60 * 1000);
+  });
+}
+
+tryKeepScreenAlive(10);
+
+ +

规范

+ + + + + + + + + + + + + + + + +
规范状态Comment
Screen Wake Lock APIEditor's DraftInitial specification.
+ +

浏览器兼容性

+ + + +

{{Compat("api.WakeLockSentinel")}}

+ +

相关链接

+ + -- cgit v1.2.3-54-g00ecf