Skip to content

Commit

Permalink
[zh-cn]: sync the translation of Notification (#18121)
Browse files Browse the repository at this point in the history
  • Loading branch information
skyclouds2001 authored Feb 2, 2024
1 parent e547576 commit 8a0e960
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions files/zh-cn/web/api/notification/index.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
---
title: Notification
slug: Web/API/Notification
l10n:
sourceCommit: e97f2c3cca98616a37003005ddc149d370c40fd0
---

{{APIRef("Web Notifications")}}{{AvailableInWorkers}}{{securecontext_header}}
{{APIRef("Web Notifications")}}{{securecontext_header}}

[Notifications API](/zh-CN/docs/Web/API/Notifications_API) 的接口 `Notification` 用于配置以向用户显示桌面通知
{{domxref("Notifications API", "", "", "nocode")}} 的 **`Notification`** 接口用于向用户配置和显示桌面通知

这些通知的外观和功能因平台而异,但通常它们会提供一种异步向用户提供信息的方式。
这些通知的外观和功能因平台而异,但通常它们提供了一种异步向用户提供信息的方式。

{{AvailableInWorkers}}

{{InheritanceDiagram}}

Expand All @@ -18,7 +22,7 @@ slug: Web/API/Notification

## 静态属性

这些属性只能用于 `Notification` 对象自身。
_还继承了其父接口 {{domxref("EventTarget")}} 的属性。_

- {{domxref("Notification.permission_static", "Notification.permission")}} {{ReadOnlyInline}}

Expand All @@ -28,60 +32,62 @@ slug: Web/API/Notification
- `granted`——用户接受显示通知。
- `default`——用户选择是未知的,因此浏览器的行为类似于值是 denied。

- {{domxref("Notification.maxActions_static")}} {{ReadOnlyInline}} {{Experimental_Inline}}
- {{domxref("Notification.maxActions_static", "Notification.maxActions")}} {{ReadOnlyInline}} {{Experimental_Inline}}
- : 设备和用户代理支持的最大的操作数量。

## 实例属性

这些属性仅用于 `Notification` 实例对象上。
_还继承了其父接口 {{domxref("EventTarget")}} 的属性。_

- {{domxref("Notification.actions")}} {{ReadOnlyInline}} {{Experimental_Inline}}
- : 在构造函数的 `options` 参数中指定的通知的操作数组
- : 在构造函数的 `options` 参数中指定的通知的操作的数组
- {{domxref("Notification.badge")}} {{ReadOnlyInline}}
- : 当没有足够的空间去显示通知自身(例如 Android 通知栏)时,用于表示通知图像的 URL。在安卓设备上,徽章的分辨率应达到 4x(约 96 x 96 px),图片会被自动屏蔽
- : 返回一个包含图像 URL 的字符串,在没有足够的空间来显示通知本身(例如 Android 通知栏)时表示通知。在 Android 设备上,徽章应适应高达 4 倍分辨率(约 96 x 96 像素)的设备,并且图像将自动屏蔽
- {{domxref("Notification.body")}} {{ReadOnlyInline}}
- : 在构造函数的 `options` 参数中指定的通知的正文字符串。
- {{domxref("Notification.data")}} {{ReadOnlyInline}}
- : 返回一个通知数据的结构化克隆
- : 返回一个通知的结构化克隆的数据
- {{domxref("Notification.dir")}} {{ReadOnlyInline}}
- : 在构造函数的 `options` 参数中指定的通知的文本方向。
- {{domxref("Notification.lang")}} {{ReadOnlyInline}}
- : 在构造函数的 `options` 参数中指定的通知的语言。
- {{domxref("Notification.tag")}} {{ReadOnlyInline}}
- : 在构造函数的 `options` 参数中指定的通知的 ID(如果有的话)。
- {{domxref("Notification.icon")}} {{ReadOnlyInline}}
- : 在构造函数的 `options` 参数中用作指定通知图标的图像 URL。
- {{domxref("Notification.image")}} {{ReadOnlyInline}} {{Experimental_Inline}}
- : 作为通知的一部分显示的图像 URL,在构造函数的选项参数中指定。
- : 在构造函数的 `options` 参数中用作指定作为通知的一部分显示的图像 URL。
- {{domxref("Notification.lang")}} {{ReadOnlyInline}}
- : 在构造函数的 `options` 参数中指定的通知的语言代码。
- {{domxref("Notification.renotify")}} {{ReadOnlyInline}} {{Experimental_Inline}}
- : 指定在新通知取代旧通知后,是否应该通知用户。
- {{domxref("Notification.requireInteraction")}} {{ReadOnlyInline}}
- : 一个布尔值,表示通知应该保持活动状态,直到用户点击或者关掉它,而不是自动关闭。
- {{domxref("Notification.silent")}} {{ReadOnlyInline}}
- : 指定通知是否应该静音——即,无论设备的设置如何,都不应发出声音和振动。
- {{domxref("Notification.tag")}} {{ReadOnlyInline}}
- : 在构造函数的 `options` 参数中指定的通知的 ID(如果有的话)。
- {{domxref("Notification.timestamp")}} {{ReadOnlyInline}} {{Experimental_Inline}}
- : 指定通知创建或者应用时(过去、现在或者未来)的时间。
- {{domxref("Notification.title")}} {{ReadOnlyInline}}
- : 在构造函数第一个参数中指定的通知标题
- : 在构造函数的第一个参数中指定的通知标题
- {{domxref("Notification.vibrate")}} {{ReadOnlyInline}} {{Experimental_Inline}}
- : 为拥有振动硬件的终端设备指定振动模式。

## 静态方法

这些属性只能用于 `Notification` 对象自身。
_还继承了其父接口 {{domxref("EventTarget")}} 的方法。_

- {{domxref("Notification.requestPermission_static", "Notification.requestPermission()")}}
- : 请求用户允许显示通知
- : 请求用户显示通知的权限

## 实例方法

这些属性仅用于 `Notification` 实例对象或者通过 [`prototype`](/zh-CN/docs/Web/JavaScript/Inheritance_and_the_prototype_chain) 提供。`Notification` 对象也继承自 {{domxref("EventTarget")}} 接口。
_还继承了其父接口 {{domxref("EventTarget")}} 的方法。_

- {{domxref("Notification.close()")}}
- : 以编程方式关闭通知实例。

## 事件

_还继承了其父接口 {{domxref("EventTarget")}} 的事件。_

- {{domxref("Notification.click_event", "click")}}
- : 当用户点击通知时触发。
- {{domxref("Notification.close_event", "close")}}
Expand Down

0 comments on commit 8a0e960

Please sign in to comment.