mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-21 04:50:14 +08:00
feat(message): add message destroyAll method (#687)
* feat: addd destroyAll * feat(message): add destroyAll method Co-authored-by: yugang.cao <yugang.cao@tusimple.ai>
This commit is contained in:
parent
d535a6497d
commit
2501817488
@ -1,5 +1,11 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
|
## Pending
|
||||||
|
|
||||||
|
### Feats
|
||||||
|
|
||||||
|
- `n-message` add `destroyAll` method.
|
||||||
|
|
||||||
## 2.15.8 (2021-07-27)
|
## 2.15.8 (2021-07-27)
|
||||||
|
|
||||||
### Feats
|
### Feats
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
|
## Pending
|
||||||
|
|
||||||
|
### Feats
|
||||||
|
|
||||||
|
- `n-message` 增加 `destroyAll` 方法
|
||||||
|
|
||||||
## 2.15.8 (2021-07-27)
|
## 2.15.8 (2021-07-27)
|
||||||
|
|
||||||
### Feats
|
### Feats
|
||||||
|
@ -62,6 +62,7 @@ multiple-line
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
|
| destroyAll | `() => void` | Destroy all popup messages. |
|
||||||
| error | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | Use error type message. |
|
| error | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | Use error type message. |
|
||||||
| info | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | Use info type message. |
|
| info | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | Use info type message. |
|
||||||
| loading | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | Use loading type message. |
|
| loading | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | Use loading type message. |
|
||||||
|
@ -62,6 +62,7 @@ multiple-line
|
|||||||
|
|
||||||
| 名称 | 类型 | 说明 |
|
| 名称 | 类型 | 说明 |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
|
| destroyAll | `() => void` | 销毁所有弹出的信息 |
|
||||||
| error | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | 调用 error 类型的信息 |
|
| error | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | 调用 error 类型的信息 |
|
||||||
| info | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | 调用 info 类型的信息 |
|
| info | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | 调用 info 类型的信息 |
|
||||||
| loading | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | 调用 loading 类型的信息 |
|
| loading | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | 调用 loading 类型的信息 |
|
||||||
|
@ -36,6 +36,7 @@ export interface MessageApiInjection {
|
|||||||
warning: (content: ContentType, options?: MessageOptions) => MessageReactive
|
warning: (content: ContentType, options?: MessageOptions) => MessageReactive
|
||||||
error: (content: ContentType, options?: MessageOptions) => MessageReactive
|
error: (content: ContentType, options?: MessageOptions) => MessageReactive
|
||||||
loading: (content: ContentType, options?: MessageOptions) => MessageReactive
|
loading: (content: ContentType, options?: MessageOptions) => MessageReactive
|
||||||
|
destroyAll: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export const messageApiInjectionKey: InjectionKey<MessageApiInjection> =
|
export const messageApiInjectionKey: InjectionKey<MessageApiInjection> =
|
||||||
@ -107,7 +108,8 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
loading (content: ContentType, options?: MessageOptions) {
|
loading (content: ContentType, options?: MessageOptions) {
|
||||||
return create(content, { ...options, type: 'loading' })
|
return create(content, { ...options, type: 'loading' })
|
||||||
}
|
},
|
||||||
|
destroyAll
|
||||||
}
|
}
|
||||||
provide(messageProviderInjectionKey, {
|
provide(messageProviderInjectionKey, {
|
||||||
props,
|
props,
|
||||||
@ -137,6 +139,11 @@ export default defineComponent({
|
|||||||
1
|
1
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
function destroyAll (): void {
|
||||||
|
Object.values(messageRefs.value).forEach((messageInstRef) => {
|
||||||
|
messageInstRef?.hide()
|
||||||
|
})
|
||||||
|
}
|
||||||
return Object.assign(
|
return Object.assign(
|
||||||
{
|
{
|
||||||
mergedClsPrefix: mergedClsPrefixRef,
|
mergedClsPrefix: mergedClsPrefixRef,
|
||||||
|
Loading…
Reference in New Issue
Block a user