@@ -151,7 +151,7 @@ export default class PermissionVerify {
151151 return ;
152152 }
153153 try {
154- const ret = await this . confirm ( data . request , data . confirm ) ;
154+ const ret = await this . confirm ( data . request , data . confirm , data . sender ) ;
155155 data . resolve ( ret ) ;
156156 } catch ( e ) {
157157 data . reject ( e ) ;
@@ -170,7 +170,7 @@ export default class PermissionVerify {
170170 } ) ;
171171 }
172172
173- async confirm ( request : Request , confirm : boolean | ConfirmParam ) : Promise < boolean > {
173+ async confirm ( request : Request , confirm : boolean | ConfirmParam , sender : GetSender ) : Promise < boolean > {
174174 if ( typeof confirm === "boolean" ) {
175175 return confirm ;
176176 }
@@ -195,7 +195,7 @@ export default class PermissionVerify {
195195 throw new Error ( "permission denied" ) ;
196196 }
197197 // 没有权限,则弹出页面让用户进行确认
198- const userConfirm = await this . confirmWindow ( request . script , confirm ) ;
198+ const userConfirm = await this . confirmWindow ( request . script , confirm , sender ) ;
199199 // 成功存入数据库
200200 const model : Permission = {
201201 uuid : request . uuid ,
@@ -251,7 +251,7 @@ export default class PermissionVerify {
251251 > = new Map ( ) ;
252252
253253 // 弹出窗口让用户进行确认
254- async confirmWindow ( script : Script , confirm : ConfirmParam ) : Promise < UserConfirm > {
254+ async confirmWindow ( script : Script , confirm : ConfirmParam , sender : GetSender ) : Promise < UserConfirm > {
255255 return new Promise ( ( resolve , reject ) => {
256256 const uuid = uuidv4 ( ) ;
257257 // 超时处理
@@ -270,7 +270,8 @@ export default class PermissionVerify {
270270 reject,
271271 } ) ;
272272 // 打开窗口
273- openInCurrentTab ( `src/confirm.html?uuid=${ uuid } ` ) ;
273+ const { tabId } = sender . getExtMessageSender ( ) ;
274+ openInCurrentTab ( `src/confirm.html?uuid=${ uuid } ` , tabId === - 1 ? undefined : tabId ) ;
274275 } ) ;
275276 }
276277
0 commit comments