@@ -35,8 +35,8 @@ function Env(name, opts) {
3535
3636 runScript ( script ) {
3737 return new Promise ( ( resolve ) => {
38- const httpapi = this . getdata ( '@chavy_boxjs_userCfgs.httpapi' )
39- console . log ( httpapi )
38+ let httpapi = this . getdata ( '@chavy_boxjs_userCfgs.httpapi' )
39+ httpapi = httpapi ? httpapi . replace ( / \n / g , '' ) . trim ( ) : httpapi
4040 const [ key , addr ] = httpapi . split ( '@' )
4141 const opts = {
4242 url : `http://${ addr } /v1/scripting/evaluate` ,
@@ -264,29 +264,28 @@ function Env(name, opts) {
264264 }
265265 }
266266 /**
267- *
267+ *
268268 * 示例:$.time('yyyy-MM-dd qq HH:mm:ss.S')
269269 * :$.time('yyyyMMddHHmmssS')
270- * y:年 M:月 d:日 q:季 H:时 m:分 s:秒 S:毫秒
270+ * y:年 M:月 d:日 q:季 H:时 m:分 s:秒 S:毫秒
271271 * 其中y可选0-4位占位符、S可选0-1位占位符,其余可选0-2位占位符
272272 * @param {* } fmt 格式化参数
273- *
273+ *
274274 */
275275 time ( fmt ) {
276276 let o = {
277- "M+" : new Date ( ) . getMonth ( ) + 1 ,
278- "d+" : new Date ( ) . getDate ( ) ,
279- "H+" : new Date ( ) . getHours ( ) ,
280- "m+" : new Date ( ) . getMinutes ( ) ,
281- "s+" : new Date ( ) . getSeconds ( ) ,
282- "q+" : Math . floor ( ( new Date ( ) . getMonth ( ) + 3 ) / 3 ) ,
283- "S" : new Date ( ) . getMilliseconds ( )
277+ 'M+' : new Date ( ) . getMonth ( ) + 1 ,
278+ 'd+' : new Date ( ) . getDate ( ) ,
279+ 'H+' : new Date ( ) . getHours ( ) ,
280+ 'm+' : new Date ( ) . getMinutes ( ) ,
281+ 's+' : new Date ( ) . getSeconds ( ) ,
282+ 'q+' : Math . floor ( ( new Date ( ) . getMonth ( ) + 3 ) / 3 ) ,
283+ 'S' : new Date ( ) . getMilliseconds ( )
284284 }
285- if ( / ( y + ) / . test ( fmt ) ) fmt = fmt . replace ( RegExp . $1 , ( new Date ( ) . getFullYear ( ) + "" ) . substr ( 4 - RegExp . $1 . length ) )
286- for ( let k in o )
287- if ( new RegExp ( "(" + k + ")" ) . test ( fmt ) ) fmt = fmt . replace ( RegExp . $1 , ( RegExp . $1 . length == 1 ) ? ( o [ k ] ) : ( ( "00" + o [ k ] ) . substr ( ( "" + o [ k ] ) . length ) ) )
285+ if ( / ( y + ) / . test ( fmt ) ) fmt = fmt . replace ( RegExp . $1 , ( new Date ( ) . getFullYear ( ) + '' ) . substr ( 4 - RegExp . $1 . length ) )
286+ for ( let k in o ) if ( new RegExp ( '(' + k + ')' ) . test ( fmt ) ) fmt = fmt . replace ( RegExp . $1 , RegExp . $1 . length == 1 ? o [ k ] : ( '00' + o [ k ] ) . substr ( ( '' + o [ k ] ) . length ) )
288287 return fmt
289- }
288+ }
290289
291290 /**
292291 * 系统通知
0 commit comments