-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[zh-cn]: Add translation for WorkerNavigator.{setAppBadge,clearAppBad…
…ge} (#18097)
- Loading branch information
1 parent
97fd5e2
commit d0c70a6
Showing
2 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
files/zh-cn/web/api/workernavigator/clearappbadge/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
title: WorkerNavigator:clearAppBadge() 方法 | ||
slug: Web/API/WorkerNavigator/clearAppBadge | ||
l10n: | ||
sourceCommit: dbfd14568c69f049452ab4fdc9c2629b63ca78d2 | ||
--- | ||
|
||
{{APIRef("Badging API")}}{{securecontext_header}} | ||
|
||
{{domxref("WorkerNavigator")}} 接口的 **`clearAppBadge()`** 方法通过将当前应用程序图标设置为 `nothing` 来清除当前应用程序图标上的徽章。`nothing` 表示当前没有设置徽章,并且徽章的状态为*已清除*。 | ||
|
||
## 语法 | ||
|
||
```js-nolint | ||
clearAppBadge() | ||
``` | ||
|
||
### 参数 | ||
|
||
无。 | ||
|
||
### 返回值 | ||
|
||
一个兑现为 {{jsxref("undefined")}} 的 {{jsxref("Promise")}}。 | ||
|
||
### 异常 | ||
|
||
- `InvalidStateError` {{domxref("DOMException")}} | ||
- : 如果文档未完全激活,则抛出该异常。 | ||
- `SecurityError` {{domxref("DOMException")}} | ||
- : 如果调用被[同源策略](/zh-CN/docs/Web/Security/Same-origin_policy)阻止,则抛出该异常。 | ||
- `NotAllowedError` {{domxref("DOMException")}} | ||
- : 如果 {{domxref('PermissionStatus.state')}} 不是 `granted`,则抛出该异常。 | ||
|
||
## 示例 | ||
|
||
读取应用程序中的所有消息后,调用 `clearAppBadge()` 方法以清除徽章并删除通知。 | ||
|
||
```js | ||
navigator.clearAppBadge(); | ||
``` | ||
|
||
## 规范 | ||
|
||
{{Specifications}} | ||
|
||
## 浏览器兼容性 | ||
|
||
{{Compat}} | ||
|
||
## 参见 | ||
|
||
- [应用程序图标的标记](https://developer.chrome.com/docs/capabilities/web-apis/badging-api/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
title: WorkerNavigator:setAppBadge() 方法 | ||
slug: Web/API/WorkerNavigator/setAppBadge | ||
l10n: | ||
sourceCommit: dbfd14568c69f049452ab4fdc9c2629b63ca78d2 | ||
--- | ||
|
||
{{APIRef("Badging API")}}{{securecontext_header}} | ||
|
||
{{domxref("WorkerNavigator")}} 接口的 **`setAppBadge()`** 方法在与此应用关联的图标上设置徽章。如果将值传递给该方法,则该值将被设置为徽章的值。否则,徽章将显示为点或平台定义的其他指示器。 | ||
|
||
## 语法 | ||
|
||
```js-nolint | ||
setAppBadge() | ||
setAppBadge(contents) | ||
``` | ||
|
||
### 参数 | ||
|
||
- `contents` {{optional_inline}} | ||
- : 一个将用作徽章值的{{jsxref("number", "数值", "", 1)}}。如果 `contents` 为 `0`,则徽章将设置为 `nothing`,表示已清除徽章。 | ||
|
||
### 返回值 | ||
|
||
一个兑现 {{jsxref("undefined")}} 的 {{jsxref("Promise")}}。 | ||
|
||
### 异常 | ||
|
||
- `InvalidStateError` {{domxref("DOMException")}} | ||
- : 如果文档未完全激活,则抛出该异常。 | ||
- `SecurityError` {{domxref("DOMException")}} | ||
- : 如果调用被[同源策略](/zh-CN/docs/Web/Security/Same-origin_policy)阻止,则抛出该异常。 | ||
- `NotAllowedError` {{domxref("DOMException")}} | ||
- : 如果 {{domxref('PermissionStatus.state')}} 不是 `granted`,则抛出该异常。 | ||
|
||
## 示例 | ||
|
||
在下面的示例中,未读的计数被传递给 `setAppBadge()`。然后徽章应显示 `30`。 | ||
|
||
```js | ||
const unread = 30; | ||
navigator.setAppBadge(unread); | ||
``` | ||
|
||
## 规范 | ||
|
||
{{Specifications}} | ||
|
||
## 浏览器兼容性 | ||
|
||
{{Compat}} | ||
|
||
## 参见 | ||
|
||
- [应用程序图标的标记](https://developer.chrome.com/docs/capabilities/web-apis/badging-api/) |