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

feat(Message & Notification): global configuration and global events #333

Closed
cnguu opened this issue Jun 30, 2021 · 2 comments · Fixed by #375 or #1685
Closed

feat(Message & Notification): global configuration and global events #333

cnguu opened this issue Jun 30, 2021 · 2 comments · Fixed by #375 or #1685
Assignees
Labels
feature request New feature or request

Comments

@cnguu
Copy link

cnguu commented Jun 30, 2021

This function solves the problem (这个功能解决的问题)

More convenient configuration and operation

Expected API (期望的 API)

global configuration

  • duration
  • maxVisible: The maximum number of messages to be displayed beyond the automatic closing time for earlier messages
  • placement: notification pop up from topRight or bottomRight or bottomLeft or topLeft.
<!-- App.vue -->

<n-message-provider :duration="3" :maxVisible="1">
  <content />
</n-message-provider>

<n-notification-provider :duration="3" placement="bottomRight">
  <content />
</n-notification-provider>

global events

  • destroyAll(): destroy all
// vue-router guard
import type { Router } from "vue-router";

import { useMessage, useNotification } from "naive-ui";

const message = useMessage();
const notification= useNotification();

export default function messageGuard(router: Router) {
  router.beforeEach(() => {
    try {
      message.destroyAll();
      notification.destroyAll();
    } catch (error) {
      console.error("message guard error:"   error);
    }

    return true;
  });
}
@Fnzero Fnzero added the feature request New feature or request label Jun 30, 2021
@Fnzero Fnzero linked a pull request Jul 5, 2021 that will close this issue
@ue360
Copy link

ue360 commented Sep 29, 2021

只解决了message的个别配置,notification的呢?destroyAll呢?咋就给关了

@07akioni 07akioni reopened this Sep 29, 2021
@07akioni
Copy link
Collaborator

只解决了message的个别配置,notification的呢?destroyAll呢?咋就给关了

Notification 的话 placement 计划搞,不过 maxVisible 和 duration 没有计划

@Fnzero Fnzero linked a pull request Nov 26, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
4 participants