@@ -150,7 +150,7 @@ export default class PermissionVerify {
150150 return ;
151151 }
152152 try {
153- const ret = await this . confirm ( data . request , data . confirm ) ;
153+ const ret = await this . confirm ( data . request , data . confirm , data . sender ) ;
154154 data . resolve ( ret ) ;
155155 } catch ( e ) {
156156 data . reject ( e ) ;
@@ -169,7 +169,7 @@ export default class PermissionVerify {
169169 } ) ;
170170 }
171171
172- async confirm ( request : Request , confirm : boolean | ConfirmParam ) : Promise < boolean > {
172+ async confirm ( request : Request , confirm : boolean | ConfirmParam , sender : GetSender ) : Promise < boolean > {
173173 if ( typeof confirm === "boolean" ) {
174174 return confirm ;
175175 }
@@ -194,7 +194,7 @@ export default class PermissionVerify {
194194 throw new Error ( "permission denied" ) ;
195195 }
196196 // 没有权限,则弹出页面让用户进行确认
197- const userConfirm = await this . confirmWindow ( request . script , confirm ) ;
197+ const userConfirm = await this . confirmWindow ( request . script , confirm , sender ) ;
198198 // 成功存入数据库
199199 const model : Permission = {
200200 uuid : request . uuid ,
@@ -250,7 +250,7 @@ export default class PermissionVerify {
250250 > = new Map ( ) ;
251251
252252 // 弹出窗口让用户进行确认
253- async confirmWindow ( script : Script , confirm : ConfirmParam ) : Promise < UserConfirm > {
253+ async confirmWindow ( script : Script , confirm : ConfirmParam , sender : GetSender ) : Promise < UserConfirm > {
254254 return new Promise ( ( resolve , reject ) => {
255255 const uuid = uuidv4 ( ) ;
256256 // 超时处理
@@ -269,7 +269,8 @@ export default class PermissionVerify {
269269 reject,
270270 } ) ;
271271 // 打开窗口
272- openInCurrentTab ( `src/confirm.html?uuid=${ uuid } ` ) ;
272+ const { tabId } = sender . getExtMessageSender ( ) ;
273+ openInCurrentTab ( `src/confirm.html?uuid=${ uuid } ` , tabId === - 1 ? undefined : tabId ) ;
273274 } ) ;
274275 }
275276
0 commit comments