Blame view

src/components/base/notification/index.js 906 Bytes
7c15ac9e   梁灏   add Message compo...
1
2
  import Notification from './notification.vue';
  import Vue from 'vue';
7c15ac9e   梁灏   add Message compo...
3
4
5
6
  
  Notification.newInstance = properties => {
      const _props = properties || {};
  
e8e1677b   Aresn   Message & Notice ...
7
      const Instance = new Vue({
e8e1677b   Aresn   Message & Notice ...
8
9
10
          render (h) {
              return h(Notification, {
                  props: _props
dd28e57f   Aresn   update Notice
11
              });
e8e1677b   Aresn   Message & Notice ...
12
13
14
15
16
17
          }
      });
  
      const component = Instance.$mount();
      document.body.appendChild(component.$el);
      const notification = Instance.$children[0];
7c15ac9e   梁灏   add Message compo...
18
19
20
21
22
  
      return {
          notice (noticeProps) {
              notification.add(noticeProps);
          },
6cadeba4   梁灏   support Message
23
24
          remove (name) {
              notification.close(name);
47e58396   梁灏   message component...
25
          },
7c15ac9e   梁灏   add Message compo...
26
          component: notification,
1c82a9ab   Lawrence Lee   bugfix: notice & ...
27
          destroy (element) {
17628aab   Lawrence Lee   bugfix on message
28
29
              notification.closeAll();
              setTimeout(function() {
1c82a9ab   Lawrence Lee   bugfix: notice & ...
30
                  document.body.removeChild(document.getElementsByClassName(element)[0]);
17628aab   Lawrence Lee   bugfix on message
31
              }, 500);
7c15ac9e   梁灏   add Message compo...
32
          }
b0893113   jingsam   :art: add eslint
33
      };
7c15ac9e   梁灏   add Message compo...
34
35
36
  };
  
  export default Notification;