Skip to content

Commit 9acac3f

Browse files
authored
fix(plugins/score): Fix requestAllPassingScores (#64)
修复成绩相关工具依赖的「全部成绩成绩查询」接口的调用。
1 parent ee671c3 commit 9acac3f

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/store/actions/request.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {
3939
getExamTypeNameByCode,
4040
getPageHTML,
4141
getThisTermScoresDataURL,
42+
getAllPassingScoresURL,
4243
LoadHTMLToDealWithError
4344
} from './utils'
4445

@@ -595,7 +596,7 @@ function filterCourseScoreInfoList(list: CourseScoreInfo[]): CourseScoreInfo[] {
595596
}
596597

597598
export async function requestAllPassingScores(): Promise<CourseScoreInfo[]> {
598-
const url = '/student/integratedQuery/scoreQuery/allPassingScores/callback'
599+
const url = await getAllPassingScoresURL()
599600
try {
600601
const { lnList } = (await $.get(url)) as APIAllPassingScoresDTO
601602
const records = lnList.reduce(

src/store/actions/utils.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,19 @@ export async function getThisTermScoresDataURL(): Promise<string> {
5050
}
5151
}
5252

53+
export async function getAllPassingScoresURL(): Promise<string> {
54+
const referralUrl = 'student/integratedQuery/scoreQuery/allPassingScores/index'
55+
const referralPageHTML = await getPageHTML(referralUrl)
56+
const r = /scoreQuery\/(.+?)\/allPassingScores/.exec(referralPageHTML)
57+
if (!r) {
58+
const msg = '无法获取 allPassingScores 接口的完整地址。'
59+
notifyError(msg, '[均分绩点计算器] 获取数据接口地址失败')
60+
throw new Error(msg)
61+
} else {
62+
return `/student/integratedQuery/scoreQuery/${r[1]}/allPassingScores/callback`
63+
}
64+
}
65+
5366
export function getExamTypeNameByCode(
5467
examTypeCode: string | undefined
5568
): string | undefined {

0 commit comments

Comments
 (0)