Skip to content

Commit d33a61e

Browse files
committed
feat: 日志输出所有弹窗内容
1 parent 9e997d2 commit d33a61e

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

catch.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ func (a *App) CatchCoursePub(speed int, studentID string, password string, cours
2828
// 创建浏览器实例
2929
browser, err := pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{
3030
Headless: playwright.Bool(headless),
31+
SlowMo: playwright.Float(30),
3132
})
3233
if err != nil { return err }
3334
defer browser.Close()
@@ -50,6 +51,10 @@ func (a *App) CatchCoursePub(speed int, studentID string, password string, cours
5051

5152
// 浏览器出现 confirm 时, 点击 "确定"
5253
page.On("dialog", func(dialog playwright.Dialog) {
54+
runtime.EventsEmit(a.ctx, "currentStatus", fmt.Sprintf("课程 %s 页面出现 %s 弹窗: %s", courseID, dialog.Type(), dialog.Message()))
55+
runtime.EventsEmit(a.ctx, "currentStatus", fmt.Sprintf("已自动确认弹窗, 请手动确认课程 %s 选课结果", courseID))
56+
runtime.EventsEmit(a.ctx, "importantStatus", fmt.Sprintf("课程 %s 页面出现 %s 弹窗: %s", courseID, dialog.Type(), dialog.Message()))
57+
runtime.EventsEmit(a.ctx, "importantStatus", fmt.Sprintf("已自动确认弹窗, 请手动确认课程 %s 选课结果", courseID))
5358
dialog.Accept()
5459
})
5560

@@ -224,6 +229,7 @@ func (a *App) CatchCourseMaj(speed int, studentID string, password string, cours
224229
// 创建浏览器实例
225230
browser, err := pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{
226231
Headless: playwright.Bool(headless),
232+
SlowMo: playwright.Float(30),
227233
})
228234
if err != nil { return err }
229235
defer browser.Close()
@@ -247,9 +253,10 @@ func (a *App) CatchCourseMaj(speed int, studentID string, password string, cours
247253
// 专业课特殊处理
248254
page.On("dialog", func(dialog playwright.Dialog) {
249255
runtime.EventsEmit(a.ctx, "currentStatus", fmt.Sprintf("课程 %s 页面出现 %s 弹窗: %s", courseID, dialog.Type(), dialog.Message()))
250-
runtime.EventsEmit(a.ctx, "currentStatus", fmt.Sprintf("请手动确认课程 %s 选课结果", courseID))
256+
runtime.EventsEmit(a.ctx, "currentStatus", fmt.Sprintf("已自动确认弹窗, 请手动确认课程 %s 选课结果", courseID))
251257
runtime.EventsEmit(a.ctx, "importantStatus", fmt.Sprintf("课程 %s 页面出现 %s 弹窗: %s", courseID, dialog.Type(), dialog.Message()))
252-
runtime.EventsEmit(a.ctx, "importantStatus", fmt.Sprintf("请手动确认课程 %s 选课结果", courseID))
258+
runtime.EventsEmit(a.ctx, "importantStatus", fmt.Sprintf("已自动确认弹窗, 请手动确认课程 %s 选课结果", courseID))
259+
dialog.Accept()
253260
})
254261

255262
// 跳转到登录页面

frontend/src/components/Header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function Header() {
4141
className='w-full h-full flex items-center justify-start text-sm gap-2 pl-3'
4242
>
4343
<span className='font-bold' data-tg-tour='测试'>小鸦抢课</span>
44-
<Tag id='version' className='m-0 border-rose-950 bg-white leading-none py-[0.15rem] px-[0.3rem]'>2.0.2</Tag>
44+
<Tag id='version' className='m-0 border-rose-950 bg-white leading-none py-[0.15rem] px-[0.3rem]'>2.0.3</Tag>
4545
<Tag id='status' className='m-0 border-rose-950 bg-white leading-none py-[0.15rem] px-[0.3rem]'>{systemStatus}</Tag>
4646
</p>
4747
<button

watch.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ func (a *App) watchCoursePubCore(speed int, studentID string, password string, c
7777
// 创建浏览器实例
7878
browser, err := pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{
7979
Headless: playwright.Bool(headless),
80+
SlowMo: playwright.Float(30),
8081
})
8182
if err != nil { ch <- err; return }
8283
defer browser.Close()
@@ -99,6 +100,10 @@ func (a *App) watchCoursePubCore(speed int, studentID string, password string, c
99100

100101
// 浏览器出现 confirm 时, 点击 "确定"
101102
page.On("dialog", func(dialog playwright.Dialog) {
103+
runtime.EventsEmit(a.ctx, "currentStatus", fmt.Sprintf("课程 %s 页面出现 %s 弹窗: %s", courseID, dialog.Type(), dialog.Message()))
104+
runtime.EventsEmit(a.ctx, "currentStatus", fmt.Sprintf("已自动确认弹窗, 请手动确认课程 %s 选课结果", courseID))
105+
runtime.EventsEmit(a.ctx, "importantStatus", fmt.Sprintf("课程 %s 页面出现 %s 弹窗: %s", courseID, dialog.Type(), dialog.Message()))
106+
runtime.EventsEmit(a.ctx, "importantStatus", fmt.Sprintf("已自动确认弹窗, 请手动确认课程 %s 选课结果", courseID))
102107
dialog.Accept()
103108
})
104109

@@ -281,6 +286,7 @@ func (a *App) watchCoursePubSyncCore(speed int, studentID string, password strin
281286
// 创建浏览器实例
282287
browser, err := pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{
283288
Headless: playwright.Bool(headless),
289+
SlowMo: playwright.Float(30),
284290
})
285291
if err != nil { ch <- err; return }
286292
defer browser.Close()
@@ -292,6 +298,10 @@ func (a *App) watchCoursePubSyncCore(speed int, studentID string, password strin
292298

293299
// 浏览器出现 confirm 时, 点击 "确定"
294300
page.On("dialog", func(dialog playwright.Dialog) {
301+
runtime.EventsEmit(a.ctx, "currentStatus", fmt.Sprintf("课程 %s 页面出现 %s 弹窗: %s", courseID, dialog.Type(), dialog.Message()))
302+
runtime.EventsEmit(a.ctx, "currentStatus", fmt.Sprintf("已自动确认弹窗, 请手动确认课程 %s 选课结果", courseID))
303+
runtime.EventsEmit(a.ctx, "importantStatus", fmt.Sprintf("课程 %s 页面出现 %s 弹窗: %s", courseID, dialog.Type(), dialog.Message()))
304+
runtime.EventsEmit(a.ctx, "importantStatus", fmt.Sprintf("已自动确认弹窗, 请手动确认课程 %s 选课结果", courseID))
295305
dialog.Accept()
296306
})
297307

@@ -458,6 +468,7 @@ func (a *App) watchCourseMajCore(speed int, studentID string, password string, c
458468
// 创建浏览器实例
459469
browser, err := pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{
460470
Headless: playwright.Bool(headless),
471+
SlowMo: playwright.Float(30),
461472
})
462473
if err != nil { ch <- err; return }
463474
defer browser.Close()
@@ -469,9 +480,10 @@ func (a *App) watchCourseMajCore(speed int, studentID string, password string, c
469480
// 专业课特殊处理
470481
page.On("dialog", func(dialog playwright.Dialog) {
471482
runtime.EventsEmit(a.ctx, "currentStatus", fmt.Sprintf("课程 %s 页面出现 %s 弹窗: %s", courseID, dialog.Type(), dialog.Message()))
472-
runtime.EventsEmit(a.ctx, "currentStatus", fmt.Sprintf("请手动确认课程 %s 选课结果", courseID))
483+
runtime.EventsEmit(a.ctx, "currentStatus", fmt.Sprintf("已自动确认弹窗, 请手动确认课程 %s 选课结果", courseID))
473484
runtime.EventsEmit(a.ctx, "importantStatus", fmt.Sprintf("课程 %s 页面出现 %s 弹窗: %s", courseID, dialog.Type(), dialog.Message()))
474-
runtime.EventsEmit(a.ctx, "importantStatus", fmt.Sprintf("请手动确认课程 %s 选课结果", courseID))
485+
runtime.EventsEmit(a.ctx, "importantStatus", fmt.Sprintf("已自动确认弹窗, 请手动确认课程 %s 选课结果", courseID))
486+
dialog.Accept()
475487
})
476488

477489
if *isClose {

0 commit comments

Comments
 (0)