11import EasterEggComponent from './components/EasterEggComponent.vue' ;
22import EasterEggTriggerCore from './plugin/index' ;
33
4- console . group ( 'index.js' ) ;
5- console . log ( { EasterEggTriggerCore } ) ;
6-
7- let globalOptions = { } ;
4+ const globalOptions = {
5+ delay : 500 ,
6+ } ;
87
98const EasterEggTrigger = {
109 install ( Vue , options = { } ) {
@@ -13,37 +12,18 @@ const EasterEggTrigger = {
1312 }
1413
1514 // Set the Global options //
16- globalOptions = options ;
15+ globalOptions . delay = options . delay || globalOptions . delay ;
1716
17+ // Add Component //
1818 Vue . component ( EasterEggComponent . name , EasterEggComponent ) ;
1919
20- // 1. Add global method or property
21- Vue . globalEasterEggMethod = function ( ) {
22- // some logic ...
23- } ;
24-
25- // 2. Add a global asset
26- Vue . directive ( 'easter-egg-trigger-directive' , {
27- bind ( el , binding , vnode , oldVnode ) {
28- // some logic ...
29- } ,
30- } ) ;
31-
32- // 3. Inject some component options
33- Vue . mixin ( {
34- created ( ) {
35- // some logic ...
36- } ,
37- } ) ;
38-
39- // 4. add an instance method
20+ // Add Instance Methods //
4021 Vue . prototype . $easterEgg = function ( methodOptions ) {
41- console . log ( '$easterEgg instance method loaded' ) ;
42- EasterEggTriggerCore . init ( globalOptions , methodOptions ) ;
22+ EasterEggTriggerCore . init ( Vue , globalOptions , methodOptions ) ;
4323 } ;
4424
4525 Vue . prototype . $easterEggTrigger = function ( methodOptions ) {
46- EasterEggTriggerCore . init ( globalOptions , methodOptions ) ;
26+ EasterEggTriggerCore . init ( Vue , globalOptions , methodOptions ) ;
4727 } ;
4828 } ,
4929} ;
@@ -54,5 +34,3 @@ if (typeof window !== 'undefined' && window.Vue) {
5434}
5535
5636export default EasterEggTrigger ;
57-
58- console . groupEnd ( 'index.js' ) ;
0 commit comments