@@ -54,27 +54,37 @@ const defaultOptions = {
5454
5555export default {
5656 alert ( options : DialogAlertOptionsType ) {
57- const { context, selector = '#t-dialog' , ...otherOptions } = { ...defaultOptions , ... options } ;
57+ const { context, selector = '#t-dialog' , ...otherOptions } = { ...options } ;
5858 const instance = getInstance ( context , selector ) ;
5959 if ( ! instance ) return Promise . reject ( ) ;
6060
6161 return new Promise ( ( resolve ) => {
62+ const mergedOptions = {
63+ ...defaultOptions ,
64+ ...instance . properties ,
65+ ...otherOptions ,
66+ } ;
6267 instance . setData ( {
6368 cancelBtn : '' ,
64- ...otherOptions ,
69+ ...mergedOptions ,
6570 visible : true ,
6671 } ) ;
6772 instance . _onConfirm = resolve ;
6873 } ) ;
6974 } ,
7075 confirm ( options : DialogConfirmOptionsType ) {
71- const { context, selector = '#t-dialog' , ...otherOptions } = { ...defaultOptions , ... options } ;
76+ const { context, selector = '#t-dialog' , ...otherOptions } = { ...options } ;
7277 const instance = getInstance ( context , selector ) ;
7378 if ( ! instance ) return Promise . reject ( ) ;
7479
7580 return new Promise ( ( resolve , reject ) => {
76- instance . setData ( {
81+ const mergedOptions = {
82+ ...defaultOptions ,
83+ ...instance . properties ,
7784 ...otherOptions ,
85+ } ;
86+ instance . setData ( {
87+ ...mergedOptions ,
7888 visible : true ,
7989 } ) ;
8090 instance . _onConfirm = resolve ;
@@ -91,19 +101,23 @@ export default {
91101 return Promise . reject ( ) ;
92102 } ,
93103 action ( options : DialogActionOptionsType ) : Promise < { index : number } > {
94- const { context, selector = '#t-dialog' , actions , ...otherOptions } = { ... defaultOptions , ...options } ;
104+ const { context, selector = '#t-dialog' , ...otherOptions } = { ...options } ;
95105 const instance = getInstance ( context , selector ) ;
96106 if ( ! instance ) return Promise . reject ( ) ;
97- const { buttonLayout = 'vertical' } = options ;
107+ const { buttonLayout = 'vertical' , actions = instance . properties . actions } = options ;
98108 const maxLengthSuggestion = buttonLayout === 'vertical' ? 7 : 3 ;
99109 if ( ! actions || ( typeof actions === 'object' && ( actions . length === 0 || actions . length > maxLengthSuggestion ) ) ) {
100110 console . warn ( `action 数量建议控制在1至${ maxLengthSuggestion } 个` ) ;
101111 }
102112
103113 return new Promise ( ( resolve ) => {
104- instance . setData ( {
105- actions,
114+ const mergedOptions = {
115+ ...defaultOptions ,
116+ ...instance . properties ,
106117 ...otherOptions ,
118+ } ;
119+ instance . setData ( {
120+ ...mergedOptions ,
107121 buttonLayout,
108122 visible : true ,
109123 } ) ;
0 commit comments