Blame view

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