@@ -54,27 +54,37 @@ const defaultOptions = {
54
54
55
55
export default {
56
56
alert ( options : DialogAlertOptionsType ) {
57
- const { context, selector = '#t-dialog' , ...otherOptions } = { ...defaultOptions , ... options } ;
57
+ const { context, selector = '#t-dialog' , ...otherOptions } = { ...options } ;
58
58
const instance = getInstance ( context , selector ) ;
59
59
if ( ! instance ) return Promise . reject ( ) ;
60
60
61
61
return new Promise ( ( resolve ) => {
62
+ const mergedOptions = {
63
+ ...defaultOptions ,
64
+ ...instance . properties ,
65
+ ...otherOptions ,
66
+ } ;
62
67
instance . setData ( {
63
68
cancelBtn : '' ,
64
- ...otherOptions ,
69
+ ...mergedOptions ,
65
70
visible : true ,
66
71
} ) ;
67
72
instance . _onConfirm = resolve ;
68
73
} ) ;
69
74
} ,
70
75
confirm ( options : DialogConfirmOptionsType ) {
71
- const { context, selector = '#t-dialog' , ...otherOptions } = { ...defaultOptions , ... options } ;
76
+ const { context, selector = '#t-dialog' , ...otherOptions } = { ...options } ;
72
77
const instance = getInstance ( context , selector ) ;
73
78
if ( ! instance ) return Promise . reject ( ) ;
74
79
75
80
return new Promise ( ( resolve , reject ) => {
76
- instance . setData ( {
81
+ const mergedOptions = {
82
+ ...defaultOptions ,
83
+ ...instance . properties ,
77
84
...otherOptions ,
85
+ } ;
86
+ instance . setData ( {
87
+ ...mergedOptions ,
78
88
visible : true ,
79
89
} ) ;
80
90
instance . _onConfirm = resolve ;
@@ -91,19 +101,23 @@ export default {
91
101
return Promise . reject ( ) ;
92
102
} ,
93
103
action ( options : DialogActionOptionsType ) : Promise < { index : number } > {
94
- const { context, selector = '#t-dialog' , actions , ...otherOptions } = { ... defaultOptions , ...options } ;
104
+ const { context, selector = '#t-dialog' , ...otherOptions } = { ...options } ;
95
105
const instance = getInstance ( context , selector ) ;
96
106
if ( ! instance ) return Promise . reject ( ) ;
97
- const { buttonLayout = 'vertical' } = options ;
107
+ const { buttonLayout = 'vertical' , actions = instance . properties . actions } = options ;
98
108
const maxLengthSuggestion = buttonLayout === 'vertical' ? 7 : 3 ;
99
109
if ( ! actions || ( typeof actions === 'object' && ( actions . length === 0 || actions . length > maxLengthSuggestion ) ) ) {
100
110
console . warn ( `action 数量建议控制在1至${ maxLengthSuggestion } 个` ) ;
101
111
}
102
112
103
113
return new Promise ( ( resolve ) => {
104
- instance . setData ( {
105
- actions,
114
+ const mergedOptions = {
115
+ ...defaultOptions ,
116
+ ...instance . properties ,
106
117
...otherOptions ,
118
+ } ;
119
+ instance . setData ( {
120
+ ...mergedOptions ,
107
121
buttonLayout,
108
122
visible : true ,
109
123
} ) ;
0 commit comments