File tree Expand file tree Collapse file tree 2 files changed +9
-19
lines changed
src/plugins/a-toast-plugin Expand file tree Collapse file tree 2 files changed +9
-19
lines changed Original file line number Diff line number Diff line change 1+ import { AToastWrapper } from '@/components/molecules/a-toast' ;
2+
13/* eslint-disable consistent-return */
24const AToastAPI = ( Render , globalOptions ) => {
35 const { InstanceLocal, tagId } = globalOptions ;
@@ -25,23 +27,13 @@ const AToastAPI = (Render, globalOptions) => {
2527 if ( InstanceLocal . $toastInstance ) return ;
2628 this . setupContainer ( tagId ) ;
2729
28- if ( ( Render . name === 'Vue' || Render . name === 'VueComponent' ) && ! globalOptions . create ) {
29- const propsData = Render . observable ( { ...globalOptions , ...options } ) ;
30- const { AToastWrapper : Component } = await import ( '@/components/molecules/a-toast' ) ;
31- const ComponentClass = Render . extend ( Component ) ;
32- InstanceLocal . $toastInstance = new ComponentClass ( {
33- el : `#${ tagId } ` ,
34- propsData,
35- } ) ;
36- return true ;
37- }
38-
39- if ( globalOptions . create ) {
40- globalOptions . create ( tagId ) ;
41- return true ;
42- }
30+ const propsData = Render . observable ( { ...globalOptions , ...options } ) ;
4331
44- return false ;
32+ const ComponentClass = Render . extend ( AToastWrapper ) ;
33+ InstanceLocal . $toastInstance = await new ComponentClass ( {
34+ el : `#${ tagId } ` ,
35+ propsData,
36+ } ) ;
4537 } ,
4638 async setupContainer ( elementId ) {
4739 this . parent = document . getElementById ( elementId ) ;
Original file line number Diff line number Diff line change @@ -3,9 +3,7 @@ import { AToastAPI } from './a-toast-api';
33
44class AToastPlugin {
55 static install ( Render , globalOptions = { } ) {
6- const isVue = ( Render . name === 'Vue' || Render . name === 'VueComponent' ) ;
7-
8- const defaultInstanceLocal = isVue ? Render . prototype : Window ;
6+ const defaultInstanceLocal = Render . prototype ;
97 const defaultTagId = 'a-toast' ;
108 if ( ! globalOptions . InstanceLocal ) Object . defineProperty ( globalOptions , 'InstanceLocal' , { value : defaultInstanceLocal } ) ;
119 if ( ! globalOptions . tagId ) Object . defineProperty ( globalOptions , 'tagId' , { value : defaultTagId } ) ;
You can’t perform that action at this time.
0 commit comments