From 5b6086bb5cc84baacc1d2f31395e3b7a0a6f8ba3 Mon Sep 17 00:00:00 2001 From: Wendell Date: Wed, 23 Oct 2019 18:23:38 +0800 Subject: [PATCH] docs(module:message,notification): use global configuration service (#4327) * docs(module:message,notification): use global configuration service * docs: add notification --- components/message/doc/index.en-US.md | 21 +++------------- components/message/doc/index.zh-CN.md | 25 +++++-------------- components/message/nz-message-base.service.ts | 4 ++- components/notification/doc/index.en-US.md | 24 +++--------------- components/notification/doc/index.zh-CN.md | 22 +++------------- 5 files changed, 20 insertions(+), 76 deletions(-) diff --git a/components/message/doc/index.en-US.md b/components/message/doc/index.en-US.md index 837c71ea4db..e341bbfee6c 100644 --- a/components/message/doc/index.en-US.md +++ b/components/message/doc/index.en-US.md @@ -20,21 +20,6 @@ You can get more detail [here](/docs/getting-started/en#import-a-component-indiv import { NzMessageModule } from 'ng-zorro-antd/message'; ``` -## How To Use - -If you want to modify the global default configuration, you can modify the value of provider `NZ_MESSAGE_CONFIG`. -(eg, add `{ provide: NZ_MESSAGE_CONFIG, useValue: { nzDuration: 3000 }}` to `providers` of your module, `NZ_MESSAGE_CONFIG` can be imported from `ng-zorro-antd`) - -The default global configuration is: -```js -{ - nzDuration: 3000, - nzMaxStack: 7, - nzPauseOnHover: true, - nzAnimate: true -} -``` - ## API ### NzMessageService @@ -64,12 +49,14 @@ Methods for destruction are also provided: - `message.remove(id)` // Remove the message with the specified id. When the id is empty, remove all messages (the message id is returned by the above method) -### Global configuration (NZ_MESSAGE_CONFIG) +### Global Configuration + +You can use `NzConfigService` to configure this component globally. Please check the Global Configuration chapter for more information. | Argument | Description | Type | Default | | -------- | ----------- | ---- | ------- | | nzDuration | Duration (milliseconds), does not disappear when set to 0 | `number` | `3000` | -| nzMaxStack | The maximum number of messages that can be displayed at the same time | `number` | `8` | +| nzMaxStack | The maximum number of messages that can be displayed at the same time | `number` | `7` | | nzPauseOnHover | Do not remove automatically when mouse is over while setting to `true` | `boolean` | `true` | | nzAnimate | Whether to turn on animation | `boolean` | `true` | | nzTop | Distance from top | `number \| string` | `24` | diff --git a/components/message/doc/index.zh-CN.md b/components/message/doc/index.zh-CN.md index 156fd2368db..dd58fca3fc4 100644 --- a/components/message/doc/index.zh-CN.md +++ b/components/message/doc/index.zh-CN.md @@ -21,21 +21,6 @@ title: Message import { NzMessageModule } from 'ng-zorro-antd/message'; ``` -## 如何使用 - -如果要修改全局默认配置,你可以设置提供商 `NZ_MESSAGE_CONFIG` 的值来修改。 -(如:在你的模块的`providers`中加入 `{ provide: NZ_MESSAGE_CONFIG, useValue: { nzDuration: 3000 }}`,`NZ_MESSAGE_CONFIG` 可以从 `ng-zorro-antd` 中导入) - -默认全局配置为: -```js -{ - nzDuration: 3000, - nzMaxStack: 7, - nzPauseOnHover: true, - nzAnimate: true -} -``` - ## API ### NzMessageService @@ -65,12 +50,14 @@ import { NzMessageModule } from 'ng-zorro-antd/message'; - `NzMessageService.remove(id)` // 移除特定id的消息,当id为空时,移除所有消息(该消息id通过上述方法返回值中得到) -### 全局配置(NZ_MESSAGE_CONFIG) +### 全局配置 + +可以通过 `NzConfigService` 进行全局配置,详情请见文档中“全局配置项”章节。 | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | -| nzDuration | 持续时间(毫秒),当设置为0时不消失 | `number` | `3000` | -| nzMaxStack | 同一时间可展示的最大提示数量 | `number` | `8` | +| nzDuration | 持续时间(毫秒),当设置为 0 时不消失 | `number` | `3000` | +| nzMaxStack | 同一时间可展示的最大提示数量 | `number` | `7` | | nzPauseOnHover | 鼠标移上时禁止自动移除 | `boolean` | `true` | | nzAnimate | 开关动画效果 | `boolean` | `true` | | nzTop | 消息距离顶部的位置 | `number \| string` | `24` | @@ -83,4 +70,4 @@ import { NzMessageModule } from 'ng-zorro-antd/message'; export interface NzMessageDataFilled { onClose: Subject; // 当 message 关闭时它会派发一个事件 } -``` +``` \ No newline at end of file diff --git a/components/message/nz-message-base.service.ts b/components/message/nz-message-base.service.ts index 06f5444347b..8cae65b7977 100644 --- a/components/message/nz-message-base.service.ts +++ b/components/message/nz-message-base.service.ts @@ -8,7 +8,7 @@ import { Overlay } from '@angular/cdk/overlay'; import { ApplicationRef, ComponentFactoryResolver, EmbeddedViewRef, Injector, Type } from '@angular/core'; -import { NzSingletonService } from 'ng-zorro-antd/core'; +import { warnDeprecation, NzSingletonService } from 'ng-zorro-antd/core'; import { NzMessageConfigLegacy } from './nz-message-config'; import { NzMessageContainerComponent } from './nz-message-container.component'; @@ -59,6 +59,8 @@ export class NzMessageBaseService< } config(config: MessageConfig): void { + warnDeprecation(`'config' of 'NzMessageService' and 'NzNotificationService' is deprecated and will be removed in 9.0.0. Please use 'set' of 'NzConfigService' instead.`); + this._container.setConfig(config); } diff --git a/components/notification/doc/index.en-US.md b/components/notification/doc/index.en-US.md index 1b1ecdda33e..1dc12378e81 100644 --- a/components/notification/doc/index.en-US.md +++ b/components/notification/doc/index.en-US.md @@ -25,24 +25,6 @@ You can get more detail [here](/docs/getting-started/en#import-a-component-indiv import { NzNotificationModule } from 'ng-zorro-antd/notification'; ``` -## How To Use - -Similar to `NzMessage`, if you want to modify the global default configuration, you can modify the value of provider `NZ_NOTIFICATION_CONFIG`. -(Example: Add `{ provide: NZ_NOTIFICATION_CONFIG, useValue: { nzDuration: 3000 }}` to `providers` of your module, `NZ_NOTIFICATION_CONFIG` can be imported from `ng-zorro-antd`) - -The default global configuration is: -```js -{ - nzTop : '24px', - nzBottom : '24px', - nzPlacement : 'topRight', - nzDuration : 4500, - nzMaxStack : 7, - nzPauseOnHover: true, - nzAnimate : true - } -``` - ## API ### NzNotificationService @@ -77,9 +59,11 @@ Methods for destruction are also provided: - `NzNotificationService.remove(id)` // Remove the notification with the specified id. When the id is empty, remove all notifications (the notification id is returned by the above method) -### Global configuration (NZ_MESSAGE_CONFIG) +### Global Configuration + +You can use `NzConfigService` to configure this component globally. -| 参数 | 说明 | 类型 | 默认值 | +| Parameter | Description | Type | Default | | --- | --- | --- | --- | | nzDuration | Duration (milliseconds), does not disappear when set to 0 | `number` | 4500 | | nzMaxStack | The maximum number of notifications that can be displayed at the same time | `number` | 8 | diff --git a/components/notification/doc/index.zh-CN.md b/components/notification/doc/index.zh-CN.md index 6eb585e26d6..d3f2e601dd4 100644 --- a/components/notification/doc/index.zh-CN.md +++ b/components/notification/doc/index.zh-CN.md @@ -24,24 +24,6 @@ subtitle: 通知提醒框 import { NzNotificationModule } from 'ng-zorro-antd/notification'; ``` -## 如何使用 - -与`NzMessage`类似,如果要修改全局默认配置,你可以设置提供商 `NZ_NOTIFICATION_CONFIG` 的值来修改。 -(如:在你的模块的`providers`中加入 `{ provide: NZ_NOTIFICATION_CONFIG, useValue: { nzDuration: 3000 }}`,`NZ_NOTIFICATION_CONFIG` 可以从 `ng-zorro-antd` 中导入) - -默认全局配置为: -```js -{ - nzTop : '24px', - nzBottom : '24px', - nzPlacement : 'topRight', - nzDuration : 4500, - nzMaxStack : 7, - nzPauseOnHover: true, - nzAnimate : true - } -``` - ## API ### NzNotificationService @@ -77,7 +59,9 @@ import { NzNotificationModule } from 'ng-zorro-antd/notification'; - `NzNotificationService.remove(id)` // 移除特定id的消息,当id为空时,移除所有消息(该消息id通过上述方法返回值中得到) -### 全局配置(NZ_MESSAGE_CONFIG) +### 全局配置 + +可以通过 `NzConfigService` 进行全局配置。 | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- |