File tree Expand file tree Collapse file tree 1 file changed +19
-23
lines changed Expand file tree Collapse file tree 1 file changed +19
-23
lines changed Original file line number Diff line number Diff line change @@ -42,37 +42,33 @@ const NotificationStore = {
42
42
clear ( ) {
43
43
this . state = [ ]
44
44
}
45
+ } ;
46
+
47
+ function initStore ( Vue ) {
48
+ return new Vue ( {
49
+ data ( ) {
50
+ return {
51
+ notificationStore : NotificationStore
52
+ }
53
+ } ,
54
+ methods : {
55
+ notify ( notification ) {
56
+ this . notificationStore . notify ( notification ) ;
57
+ }
58
+ }
59
+ } ) ;
45
60
}
46
61
47
62
const NotificationsPlugin = {
48
63
install ( Vue , options ) {
49
- Vue . mixin ( {
50
- data ( ) {
51
- return {
52
- notificationStore : NotificationStore
53
- }
54
- } ,
55
- methods : {
56
- notify ( notification ) {
57
- this . notificationStore . notify ( notification ) ;
58
- }
59
- }
60
- } )
61
- Object . defineProperty ( Vue . prototype , '$notify' , {
62
- get ( ) {
63
- return this . $root . notify
64
- }
65
- } )
66
- Object . defineProperty ( Vue . prototype , '$notifications' , {
67
- get ( ) {
68
- return this . $root . notificationStore
69
- }
70
- } )
64
+ let store = initStore ( Vue ) ;
65
+ Vue . prototype . $notify = store . notify ;
66
+ Vue . prototype . $notifications = store . notificationStore ;
71
67
Vue . component ( 'Notifications' , Notifications )
72
68
if ( options ) {
73
69
NotificationStore . setOptions ( options )
74
70
}
75
71
}
76
- }
72
+ } ;
77
73
78
74
export default NotificationsPlugin
You can’t perform that action at this time.
0 commit comments