Skip to content

Commit 112f574

Browse files
committed
fix: 适配新版数字京师
1 parent 3005ca0 commit 112f574

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed

catch.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ func (a *App) CatchCoursePub(
6666
dialog.Accept()
6767
})
6868

69+
page.SetDefaultNavigationTimeout(60_000)
70+
6971
// 跳转到登录页面
7072
if useWebVpn {
7173
_, err = page.Goto("https://one.bnu.edu.cn/dcp/forward.action?path=/portal/portal&p=home")
@@ -76,17 +78,17 @@ func (a *App) CatchCoursePub(
7678
}
7779

7880
// 输入学号
79-
ele = page.Locator("#un")
81+
ele = page.Locator("#loginForm > div > div.username > input")
8082
err = ele.Fill(studentID)
8183
if err != nil { errCh <- err; return }
8284

8385
// 输入密码
84-
ele = page.Locator("#pd")
86+
ele = page.Locator("#password-input")
8587
err = ele.Fill(password)
8688
if err != nil { errCh <- err; return }
8789

8890
// 点击登录按钮
89-
ele = page.Locator("#index_login_btn")
91+
ele = page.Locator("#loginForm > div.login-btn-row > a")
9092
err = ele.Click()
9193
if err != nil { errCh <- err; return }
9294

@@ -111,7 +113,7 @@ func (a *App) CatchCoursePub(
111113
})
112114
// 点击 "教务管理系统"
113115
page.Evaluate(`() => {
114-
const items = document.querySelectorAll('.ml_item_name')
116+
const items = document.querySelectorAll('#common_div > ul > li > div.text-box')
115117
for (const item of items) {
116118
if (item.textContent?.includes('教务管理系统')) {
117119
item.parentElement?.click()
@@ -315,6 +317,8 @@ func (a *App) CatchCourseMaj(
315317
dialog.Accept()
316318
})
317319

320+
page.SetDefaultNavigationTimeout(60_000)
321+
318322
// 跳转到登录页面
319323
if useWebVpn {
320324
_, err = page.Goto("https://one.bnu.edu.cn/dcp/forward.action?path=/portal/portal&p=home")
@@ -325,17 +329,17 @@ func (a *App) CatchCourseMaj(
325329
}
326330

327331
// 输入学号
328-
ele = page.Locator("#un")
332+
ele = page.Locator("#loginForm > div > div.username > input")
329333
err = ele.Fill(studentID)
330334
if err != nil { errCh <- err; return }
331335

332336
// 输入密码
333-
ele = page.Locator("#pd")
337+
ele = page.Locator("#password-input")
334338
err = ele.Fill(password)
335339
if err != nil { errCh <- err; return }
336340

337341
// 点击登录按钮
338-
ele = page.Locator("#index_login_btn")
342+
ele = page.Locator("#loginForm > div.login-btn-row > a")
339343
err = ele.Click()
340344
if err != nil { errCh <- err; return }
341345

@@ -360,7 +364,7 @@ func (a *App) CatchCourseMaj(
360364
})
361365
// 点击 "教务管理系统"
362366
page.Evaluate(`() => {
363-
const items = document.querySelectorAll('.ml_item_name')
367+
const items = document.querySelectorAll('#common_div > ul > li > div.text-box')
364368
for (const item of items) {
365369
if (item.textContent?.includes('教务管理系统')) {
366370
item.parentElement?.click()

frontend/src/components/Header.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import {
2020
QuestionOutlined,
2121
} from '@ant-design/icons'
2222

23+
const VERSION = '2.3.0'
24+
2325
export function Header() {
2426

2527
// 窗口置顶按钮
@@ -41,7 +43,7 @@ export function Header() {
4143
className='w-full h-full flex items-center justify-start text-sm gap-2 pl-3'
4244
>
4345
<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.2.0</Tag>
46+
<Tag id='version' className='m-0 border-rose-950 bg-white leading-none py-[0.15rem] px-[0.3rem]'>{VERSION}</Tag>
4547
<Tag id='status' className='m-0 border-rose-950 bg-white leading-none py-[0.15rem] px-[0.3rem]'>{systemStatus}</Tag>
4648
</p>
4749
<button

watch.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -150,17 +150,17 @@ func (a *App) watchCoursePubCore(
150150
}
151151

152152
// 输入学号
153-
ele = page.Locator("#un")
153+
ele = page.Locator("#loginForm > div > div.username > input")
154154
err = ele.Fill(studentID)
155155
if err != nil { errCh <- err; return }
156156

157157
// 输入密码
158-
ele = page.Locator("#pd")
158+
ele = page.Locator("#password-input")
159159
err = ele.Fill(password)
160160
if err != nil { errCh <- err; return }
161161

162162
// 点击登录按钮
163-
ele = page.Locator("#index_login_btn")
163+
ele = page.Locator("#loginForm > div.login-btn-row > a")
164164
err = ele.Click()
165165
if err != nil { errCh <- err; return }
166166

@@ -185,7 +185,7 @@ func (a *App) watchCoursePubCore(
185185
})
186186
// 点击 "教务管理系统"
187187
page.Evaluate(`() => {
188-
const items = document.querySelectorAll('.ml_item_name')
188+
const items = document.querySelectorAll('#common_div > ul > li > div.text-box')
189189
for (const item of items) {
190190
if (item.textContent?.includes('教务管理系统')) {
191191
item.parentElement?.click()
@@ -397,17 +397,17 @@ func (a *App) watchCoursePubSyncCore(
397397
}
398398

399399
// 输入学号
400-
ele = page.Locator("#un")
400+
ele = page.Locator("#loginForm > div > div.username > input")
401401
err = ele.Fill(studentID)
402402
if err != nil { ch <- err; return }
403403

404404
// 输入密码
405-
ele = page.Locator("#pd")
405+
ele = page.Locator("#password-input")
406406
err = ele.Fill(password)
407407
if err != nil { ch <- err; return }
408408

409409
// 点击登录按钮
410-
ele = page.Locator("#index_login_btn")
410+
ele = page.Locator("#loginForm > div.login-btn-row > a")
411411
err = ele.Click()
412412
if err != nil { ch <- err; return }
413413

@@ -432,7 +432,7 @@ func (a *App) watchCoursePubSyncCore(
432432
})
433433
// 点击 "教务管理系统"
434434
page.Evaluate(`() => {
435-
const items = document.querySelectorAll('.ml_item_name')
435+
const items = document.querySelectorAll('#common_div > ul > li > div.text-box')
436436
for (const item of items) {
437437
if (item.textContent?.includes('教务管理系统')) {
438438
item.parentElement?.click()
@@ -633,17 +633,17 @@ func (a *App) watchCourseMajCore(
633633
}
634634

635635
// 输入学号
636-
ele = page.Locator("#un")
636+
ele = page.Locator("#loginForm > div > div.username > input")
637637
err = ele.Fill(studentID)
638638
if err != nil { ch <- err; return }
639639

640640
// 输入密码
641-
ele = page.Locator("#pd")
641+
ele = page.Locator("#password-input")
642642
err = ele.Fill(password)
643643
if err != nil { ch <- err; return }
644644

645645
// 点击登录按钮
646-
ele = page.Locator("#index_login_btn")
646+
ele = page.Locator("#loginForm > div.login-btn-row > a")
647647
err = ele.Click()
648648
if err != nil { ch <- err; return }
649649

@@ -672,7 +672,7 @@ func (a *App) watchCourseMajCore(
672672
})
673673
// 点击 "教务管理系统"
674674
page.Evaluate(`() => {
675-
const items = document.querySelectorAll('.ml_item_name')
675+
const items = document.querySelectorAll('#common_div > ul > li > div.text-box')
676676
for (const item of items) {
677677
if (item.textContent?.includes('教务管理系统')) {
678678
item.parentElement?.click()

0 commit comments

Comments
 (0)