Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoCorrect files/zh-cn/web/api/serviceworker/ #5899

Merged
merged 1 commit into from
Jun 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions files/zh-cn/web/api/serviceworker/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,41 @@
---
<div>{{SeeCompatTable}} {{APIRef("Service Workers API")}}</div>

<div>ServiceWorker API 的<a href="https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker_API"> ServiceWorker接口</a> 提供一个对一个服务工作者的引用。 多个浏览上下文(例如页面,工作者等)可以与相同的服务工作者相关联,每个都通过唯一的ServiceWorker对象。</div>
<div>ServiceWorker API 的<a href="https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker_API"> ServiceWorker 接口</a> 提供一个对一个服务工作者的引用。 多个浏览上下文(例如页面,工作者等)可以与相同的服务工作者相关联,每个都通过唯一的 ServiceWorker 对象。</div>

<div> </div>

<p>一个ServiceWorker对象在 {{domxref("ServiceWorkerRegistration.active")}} 属性和 {{domxref("ServiceWorkerContainer.controller")}} 属性中可用 — 这是一个激活并在控制页面的service worker(service worker成功注册,被控页面已经重新加载完毕.)</p>
<p>一个 ServiceWorker 对象在 {{domxref("ServiceWorkerRegistration.active")}} 属性和 {{domxref("ServiceWorkerContainer.controller")}} 属性中可用 — 这是一个激活并在控制页面的 service worker(service worker 成功注册,被控页面已经重新加载完毕.)</p>

<p>ServiceWorker接口被分配了一系列生命周期事件 --- 安装和激活 --- 以及功能型的事件,包括 fetch.一个ServiceWorker对象有一个与之关联的 {{domxref("ServiceWorker.state")}},指示着它的生命周期.</p>
<p>ServiceWorker 接口被分配了一系列生命周期事件 --- 安装和激活 --- 以及功能型的事件包括 fetch.一个 ServiceWorker 对象有一个与之关联的 {{domxref("ServiceWorker.state")}},指示着它的生命周期</p>

<h2 id="属性">属性</h2>

<p><em>ServiceWorker 接口继承它父类{{domxref("Worker")}}的属性.</em></p>
<p><em>ServiceWorker 接口继承它父类{{domxref("Worker")}}的属性</em></p>

<dl>
<dt>{{domxref("ServiceWorker.scriptURL")}} {{readonlyinline}}</dt>
<dd>返回作为 {{domxref("ServiceWorkerRegistration")}} 一部分所定义的ServiceWorker序列化脚本URL.这个URL必须和注册该ServiceWorker的文档处于同一域.</dd>
<dd>返回作为 {{domxref("ServiceWorkerRegistration")}} 一部分所定义的 ServiceWorker 序列化脚本 URL.这个 URL 必须和注册该 ServiceWorker 的文档处于同一域。</dd>
<dt>{{domxref("ServiceWorker.state")}} {{readonlyinline}}</dt>
<dd>返回service worker的状态.其值可能是如下之一:installing,installed,activating,activated或者是redundant.</dd>
<dd>返回 service worker 的状态。其值可能是如下之一:installing,installed,activating,activated 或者是 redundant.</dd>
</dl>

<h3 id="Event_handlers">Event handlers</h3>

<dl>
<dt>{{domxref("ServiceWorker.onstatechange")}} {{readonlyinline}}</dt>
<dd>一个一旦 {{domxref("ServiceWorker.state")}} 发生改变时,即一个类型为statechange事件触发时就会被调用的 {{domxref("EventListener")}} 属性.</dd>
<dd>一个一旦 {{domxref("ServiceWorker.state")}} 发生改变时,即一个类型为 statechange 事件触发时就会被调用的 {{domxref("EventListener")}} 属性</dd>
</dl>

<h2 id="方法">方法</h2>

<dl>
<dd><em>ServiceWorker 接口继承它父类 {{domxref("Worker")}} 的方法 ,并带有一个 {{domxref("Worker.terminate")}} 的异常 --- 它不应该从service workers.ServiceWorker中访问.</em></dd>
<dd><em>ServiceWorker 接口继承它父类 {{domxref("Worker")}} 的方法 ,并带有一个 {{domxref("Worker.terminate")}} 的异常 --- 它不应该从 service workers.ServiceWorker 中访问。</em></dd>
</dl>

<h2 id="例子">例子</h2>

<p>代码段来自<a href="https://github.com/GoogleChrome/samples/blob/gh-pages/service-worker/registration-events/index.html">service worker registration-events sample</a> (<a href="https://googlechrome.github.io/samples/service-worker/registration-events/">live demo</a>). 这段代码监听了{{domxref("ServiceWorker.state")}} 的变化并且返回它的值.</p>
<p>代码段来自<a href="https://github.com/GoogleChrome/samples/blob/gh-pages/service-worker/registration-events/index.html">service worker registration-events sample</a> (<a href="https://googlechrome.github.io/samples/service-worker/registration-events/">live demo</a>). 这段代码监听了{{domxref("ServiceWorker.state")}} 的变化并且返回它的值</p>

<pre class="brush: js">if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('service-worker.js', {
Expand Down
2 changes: 1 addition & 1 deletion files/zh-cn/web/api/serviceworker/scripturl/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
---
<div>{{SeeCompatTable}}{{APIRef("Service Workers API")}}</div>

<p>作为<code><a href="https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration" title="ServiceWorkerRegistion is an interface object representing the service worker registration. You register a service worker to control one or more pages that share the same origin.">ServiceWorkerRegistration</a>的一部分定义,会返回该ServiceWorker的序列化脚本url</code>. 必须与document注册<code>ServiceWorker的地址同源</code>.</p>
<p>作为<code><a href="https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration" title="ServiceWorkerRegistion is an interface object representing the service worker registration. You register a service worker to control one or more pages that share the same origin.">ServiceWorkerRegistration</a>的一部分定义,会返回该 ServiceWorker 的序列化脚本 url</code>. 必须与 document 注册<code>ServiceWorker 的地址同源</code>.</p>

<h2 id="Syntax" name="Syntax">语法</h2>

Expand Down
4 changes: 2 additions & 2 deletions files/zh-cn/web/api/serviceworker/state/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
---
<div>{{SeeCompatTable}}{{APIRef("Service Workers API")}}</div>

<div>ServiceWorker接口的这个只读的<strong>state</strong>属性返回一个代表service worker当前状态的字符串。值可以是以下这些:installing, installed, activating, activated, 或者是redundant.</div>
<div>ServiceWorker 接口的这个只读的<strong>state</strong>属性返回一个代表 service worker 当前状态的字符串。值可以是以下这些:installing, installed, activating, activated,或者是 redundant.</div>

<h2 id="Syntax" name="Syntax">语法</h2>

Expand All @@ -18,7 +18,7 @@ <h3 id="值">值</h3>

<h2 id="示例">示例</h2>

<p>这块代码出自 <a href="https://github.com/GoogleChrome/samples/blob/gh-pages/service-worker/registration-events/index.html">service worker registration-events sample</a> (<a href="https://googlechrome.github.io/samples/service-worker/registration-events/">live demo</a>). 代码监听了任何{{domxref("ServiceWorker.state")}}中的改变,并返回它的值.</p>
<p>这块代码出自 <a href="https://github.com/GoogleChrome/samples/blob/gh-pages/service-worker/registration-events/index.html">service worker registration-events sample</a> (<a href="https://googlechrome.github.io/samples/service-worker/registration-events/">live demo</a>). 代码监听了任何{{domxref("ServiceWorker.state")}}中的改变,并返回它的值</p>

<pre class="brush: js">var serviceWorker;
if (registration.installing) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
---
<div>{{SeeCompatTable}}{{APIRef("Service Workers API")}}</div>

<p>一个 {{domxref("EventListener")}} 联动的属性,其会被任何stagechange类型事件抛出时联动; 它也基本上能在任何时候{{domxref("ServiceWorker.state")}} 改变时被抛出.</p>
<p>一个 {{domxref("EventListener")}} 联动的属性,其会被任何 stagechange 类型事件抛出时联动; 它也基本上能在任何时候{{domxref("ServiceWorker.state")}} 改变时被抛出</p>

<h2 id="语法">语法</h2>

Expand All @@ -15,7 +15,7 @@ <h2 id="语法">语法</h2>

<h2 id="示例">示例</h2>

<p>这段代码出自 <a href="https://github.com/GoogleChrome/samples/blob/gh-pages/service-worker/registration-events/index.html">service worker registration-events sample</a> (<a href="https://googlechrome.github.io/samples/service-worker/registration-events/">live demo</a>). 它会监听 {{domxref("ServiceWorker.state")}} 的改变并返回它的值.</p>
<p>这段代码出自 <a href="https://github.com/GoogleChrome/samples/blob/gh-pages/service-worker/registration-events/index.html">service worker registration-events sample</a> (<a href="https://googlechrome.github.io/samples/service-worker/registration-events/">live demo</a>). 它会监听 {{domxref("ServiceWorker.state")}} 的改变并返回它的值</p>

<pre class="brush: js">var serviceWorker;
if (registration.installing) {
Expand All @@ -36,7 +36,7 @@ <h2 id="示例">示例</h2>
});
}</pre>

<p>注意当<code>statechange</code> 抛出时, service worker的引用可能已经改变。例如:</p>
<p>注意当<code>statechange</code> 抛出时service worker 的引用可能已经改变。例如</p>

<pre class="brush: js">navigator.serviceWorker.register(..).then(function(swr) {
swr.installing.state == "installing"
Expand Down