1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
---
title: idle
slug: Mozilla/Add-ons/WebExtensions/API/idle
tags:
- API
- Idle
- WebExtensions
- requestIdleCallback
- 性能优化
translation_of: Mozilla/Add-ons/WebExtensions/API/idle
---
<div>{{AddonSidebar}}</div>
<p>找出用户系统何时处于空闲,锁定或活动状态。</p>
<p>要使用此API,您需要具有“空闲”<a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">权限</a>。</p>
<h2 id="类型">类型</h2>
<dl>
<dt>{{WebExtAPIRef("idle.IdleState")}}</dt>
<dd>
<p>描述设备空闲状态的字符串。</p>
</dd>
</dl>
<h2 id="函数">函数</h2>
<dl>
<dt>{{WebExtAPIRef("idle.queryState()")}}</dt>
<dd>如果系统被锁定则返回“已锁定”,如果用户未在指定的秒数内生成任何输入,则返回“空闲”,否则返回“活动”。</dd>
<dt>{{WebExtAPIRef("idle.setDetectionInterval()")}}</dt>
<dd>设置用于确定系统何时处于 {{WebExtAPIRef("idle.onStateChanged")}} 事件的空闲状态的时间间隔。</dd>
</dl>
<h2 id="事件">事件</h2>
<dl>
<dt>{{WebExtAPIRef("idle.onStateChanged")}}</dt>
<dd>当系统改变状态时触发。</dd>
</dl>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p>{{Compat("webextensions.api.idle")}}</p>
<p>{{WebExtExamples("h2")}}</p>
<div class="note"><strong>确认</strong>
<p>此 API基于 Chromium 的 <a href="https://developer.chrome.com/extensions/idle"><code>chrome.idle</code></a> API。本文档源自 Chromium代码中的 <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/idle.json"><code>idle.json</code></a> 。</p>
<p>Microsoft Edge 兼容性数据由 Microsoft Corporation提供,并包含在Creative Commons Attribution 3.0 United States License下。</p>
</div>
<div class="hidden">
<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</pre>
</div>
<h3 id="了解更多">了解更多:</h3>
<div><a href="https://developer.mozilla.org/zh-CN/docs/Web/API/Window/requestIdleCallback">https://developer.mozilla.org/zh-CN/docs/Web/API/Window/requestIdleCallback </a></div>
<div>...</div>
|