Skip to content

Commit

Permalink
新增关闭浏览器后 自动退出进程
Browse files Browse the repository at this point in the history
  • Loading branch information
zqjzqj committed Jan 8, 2021
1 parent d10f314 commit e825b7d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions secKill/jdSecKill.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,15 @@ func (jsk *jdSecKill) Run() error {
chromedp.ActionFunc(func(ctx context.Context) error {
logs.PrintlnInfo("等待登陆......")
for {
select {
case <-jsk.ctx.Done():
logs.PrintErr("浏览器被关闭,退出进程")
return nil
case <-jsk.bCtx.Done():
logs.PrintErr("浏览器被关闭,退出进程")
return nil
default:
}
if jsk.isLogin {
logs.PrintlnSuccess(jsk.UserInfo.Get("realName").String() + ", 登陆成功........")
break
Expand Down Expand Up @@ -265,6 +274,15 @@ func (jsk *jdSecKill) WaitStart() chromedp.ActionFunc {
st := jsk.StartTime.UnixNano() / 1e6
logs.PrintlnInfo("等待时间到达"+jsk.StartTime.Format(global.DateTimeFormatStr)+"...... 请勿关闭浏览器")
for {
select {
case <-jsk.ctx.Done():
logs.PrintErr("浏览器被关闭,退出进程")
return nil
case <-jsk.bCtx.Done():
logs.PrintErr("浏览器被关闭,退出进程")
return nil
default:
}
if global.UnixMilli() - jsk.DiffTime >= st {
logs.PrintlnInfo("时间到达。。。。开始执行")
break
Expand Down

0 comments on commit e825b7d

Please sign in to comment.