File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ export function install ( Vue , options = { } ) {
2+ if ( Vue . IkInstalled ) {
3+ throw new Error ( "Imagekit plugin already installed" ) ;
4+ }
5+
6+ Vue . IkInstalled = true ;
7+
8+ initComponents ( Vue , options ) ;
9+ }
10+
11+ function registerComponents ( Vue , components = { } , defaultConfigurations = { } ) {
12+ if ( ! components ) { throw new Error ( "No component found. " ) }
13+
14+ for ( let key in component ) {
15+ const component = components [ key ] ;
16+
17+ if ( component ) {
18+ Vue . component ( key , {
19+ ...component ,
20+ data ( ) {
21+ return {
22+ ...( component . data ? component . data ( ) : { } ) ,
23+ defaultConfigurations
24+ }
25+ }
26+
27+ } )
28+ }
29+ }
30+ }
31+
32+ function initComponents ( Vue ) {
33+ const components = Array . isArray ( options . components ) ? options . components . reduce ( ( obj , component ) => ( {
34+ ...obj ,
35+ [ component . name ] : component
36+ } ) , { } ) : options . components ;
37+
38+ registerComponents ( Vue , components ) ;
39+ }
You can’t perform that action at this time.
0 commit comments