@@ -96,10 +96,13 @@ const showNotification = async (
9696
9797 // 处理超时
9898 if ( options ?. timeout ) {
99- await Promise . all ( [
100- new Promise ( ( resolve ) => setTimeout ( resolve , options . timeout ) ) ,
101- vscode . commands . executeCommand ( "closeNotification" ) ,
102- ] ) ;
99+ const closePromise = new Promise < void > ( ( resolve ) => {
100+ setTimeout ( ( ) => {
101+ vscode . commands . executeCommand ( "workbench.action.closeMessages" ) ;
102+ resolve ( ) ;
103+ } , options . timeout ) ;
104+ } ) ;
105+ await closePromise ;
103106 }
104107 return result ;
105108 } catch ( error ) {
@@ -144,13 +147,28 @@ export const notify: INotify = {
144147 showNotification ( item . type , item . messageKey , item . args , item . options ) ,
145148
146149 info : ( messageKey : string , args ?: any [ ] , options ?: NotificationOptions ) =>
147- notify . add ( { type : "info" , messageKey, args, options } ) ,
150+ notify . add ( {
151+ type : "info" ,
152+ messageKey,
153+ args,
154+ options : { timeout : DEFAULT_TIMEOUT , ...options } ,
155+ } ) ,
148156
149157 warn : ( messageKey : string , args ?: any [ ] , options ?: NotificationOptions ) =>
150- notify . add ( { type : "warn" , messageKey, args, options } ) ,
158+ notify . add ( {
159+ type : "warn" ,
160+ messageKey,
161+ args,
162+ options : { timeout : DEFAULT_TIMEOUT , ...options } ,
163+ } ) ,
151164
152165 error : ( messageKey : string , args ?: any [ ] , options ?: NotificationOptions ) =>
153- notify . add ( { type : "error" , messageKey, args, options } ) ,
166+ notify . add ( {
167+ type : "error" ,
168+ messageKey,
169+ args,
170+ options : { timeout : DEFAULT_TIMEOUT , ...options } ,
171+ } ) ,
154172
155173 // 快捷方法
156174 confirm : ( messageKey : string , onYes : ( ) => void , onNo ?: ( ) => void ) =>
0 commit comments