@@ -9,6 +9,8 @@ import './index.less';
99const defaultParams = '{\n \t "testKey":123 \n}' ;
1010// 模板变量占位
1111const tempPlaceHolder = '${extParams}' ;
12+ const tempPlaceHolderReg = / \$ \{ e x t P a r a m s \} / g;
13+
1214const defaultEditorOption = {
1315 style : { width : '100%' , height : '319px' } ,
1416 readOnly : false ,
@@ -179,7 +181,7 @@ export default class EventBindDialog extends Component<PluginProps> {
179181
180182 onSearchEvent = ( ) => { } ;
181183
182- onChange = ( checked ) => {
184+ onChange = ( checked : boolean ) => {
183185 this . setState ( {
184186 useParams : checked ,
185187 } ) ;
@@ -196,22 +198,23 @@ export default class EventBindDialog extends Component<PluginProps> {
196198 }
197199 } ;
198200
199- pickupFunctionName = ( codeStr ) => {
201+ pickupFunctionName = ( codeStr : string ) => {
200202 return codeStr . substr ( 0 , codeStr . indexOf ( '(' ) ) ;
201203 } ;
202204
203- removeSpace = ( str ) => {
205+ removeSpace = ( str : string ) => {
204206 return str . replace ( / \s * / g, '' ) ;
205207 } ;
206208
207- formatTemplate = ( template , eventName , useParams ) => {
209+ formatTemplate = ( template : string , eventName : string , useParams : boolean ) => {
208210 let formatTemp ;
209211 if ( template ) {
210212 const functionName = this . pickupFunctionName ( template ) ;
211213
212214 formatTemp = template . replace ( new RegExp ( '^s*' + functionName ) , eventName ) ;
213215 if ( useParams ) {
214- formatTemp = formatTemp . replace ( / t e m p P l a c e H o l d e r / g, 'extParams' ) ;
216+ formatTemp = formatTemp . replace ( tempPlaceHolderReg , 'extParams' ) ;
217+
215218 } else {
216219 const leftIndex = formatTemp . indexOf ( '(' ) ;
217220 const rightIndex = formatTemp . indexOf ( ')' ) ;
@@ -240,7 +243,7 @@ export default class EventBindDialog extends Component<PluginProps> {
240243 return formatTemp ;
241244 } ;
242245
243- formatEventName = ( eventName ) => {
246+ formatEventName = ( eventName : string ) => {
244247 const newEventNameArr = eventName . split ( '' ) ;
245248 const index = eventName . indexOf ( '.' ) ;
246249 if ( index >= 0 ) {
@@ -283,7 +286,7 @@ export default class EventBindDialog extends Component<PluginProps> {
283286 this . closeDialog ( ) ;
284287 } ;
285288
286- onChangeEditor = ( paramStr ) => {
289+ onChangeEditor = ( paramStr : string ) => {
287290 this . setState ( {
288291 paramStr,
289292 } ) ;
@@ -370,7 +373,7 @@ export default class EventBindDialog extends Component<PluginProps> {
370373 value = { paramStr }
371374 { ...defaultEditorOption }
372375 { ...{ language : 'json' } }
373- onChange = { ( newCode ) => this . onChangeEditor ( newCode ) }
376+ onChange = { ( newCode : string ) => this . onChangeEditor ( newCode ) }
374377 />
375378 { ! useParams && < div className = "mask" /> }
376379 </ div >
0 commit comments