aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/wakelocksentinel/index.html
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/wakelocksentinel/index.html
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/wakelocksentinel/index.html')
-rw-r--r--files/zh-cn/web/api/wakelocksentinel/index.html73
1 files changed, 73 insertions, 0 deletions
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
+---
+<p>{{APIRef("Screen Wake Lock API")}}{{SeeCompatTable}}{{securecontext_header}}</p>
+
+<p><span class="seoSummary">The <strong><code>WakeLockSentinel</code></strong> 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.</span></p>
+
+<h2 id="属性">属性</h2>
+
+<dl>
+ <dt>{{DOMxRef("WakeLockSentinel.type")}} {{readonlyInline}}</dt>
+ <dd>Wake lock type. Currently it is always <code>"screen"</code>.</dd>
+</dl>
+
+<h2 id="方法">方法</h2>
+
+<dl>
+ <dt>{{DOMxRef("WakeLockSentinel.release","WakeLockSentinel.release()")}}</dt>
+ <dd>Returns a {{JSxRef("Promise")}} that resolves without a value after requesting the underlying wake lock is released.</dd>
+</dl>
+
+<h2 id="事件处理程序">事件处理程序</h2>
+
+<dl>
+ <dt>{{DOMxRef("WakeLockSentinel.onrelease")}}</dt>
+ <dd>Event handler for <code>release</code> event type which occurs when <code>WakeLockSentinel</code> object's handle has been releases due to either a <code>release()</code> method being called or because {{Glossary("User Agent")}} releases the lock.</dd>
+</dl>
+
+<h2 id="示例">示例</h2>
+
+<p>The following example acquires a screen wake lock and then releases it in 10 minutes:</p>
+
+<pre class="notranslate">function tryKeepScreenAlive(minutes) {
+ navigator.wakeLock.request("screen").then(lock =&gt; {
+ setTimeout(() =&gt; lock.release(), minutes * 60 * 1000);
+ });
+}
+
+tryKeepScreenAlive(10);
+</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">规范</th>
+ <th scope="col">状态</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><a href="https://w3c.github.io/screen-wake-lock/#dom-wakelocksentinel">Screen Wake Lock API</a></td>
+ <td>Editor's Draft</td>
+ <td>Initial specification.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+
+
+<p>{{Compat("api.WakeLockSentinel")}}</p>
+
+<h2 id="相关链接">相关链接</h2>
+
+<ul>
+ <li>{{DOMxRef("WakeLock.request", "navigator.wakeLock.request()")}}</li>
+</ul>