Skip to content

Commit

Permalink
fix: 修复题库页评分过滤失效
Browse files Browse the repository at this point in the history
  • Loading branch information
XYShaoKang committed Sep 29, 2024
1 parent 75523fa commit 3e73745
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/content/pages/problemset/intercept.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ export function intercept(): void {
password?: string,
disbaleIntercept?: boolean
) {
let pathname = url
try {
const urlObj = new URL(url)
pathname = urlObj.pathname
} catch (error) {}

Check failure on line 26 in src/content/pages/problemset/intercept.tsx

View workflow job for this annotation

GitHub Actions / Release

Empty block statement
if (
!disbaleIntercept &&
method.toLocaleLowerCase() === 'post' &&
url === `/graphql/`
pathname === `/graphql/`
) {
const originalSend = this.send

Expand Down Expand Up @@ -115,6 +120,19 @@ export function intercept(): void {
} catch (error) {
//
}
} else if (typeof str === 'string') {
try {
const body = JSON.parse(str)
const sortOrder = body?.variables?.filters?.sortOrder
if (
sortOrder &&
sortOrder !== 'DESCENDING' &&
sortOrder !== 'ASCENDING'
) {
body.variables.filters.sortOrder = 'DESCENDING'
str = JSON.stringify(body)
}
} catch (error) {}

Check failure on line 135 in src/content/pages/problemset/intercept.tsx

View workflow job for this annotation

GitHub Actions / Release

Empty block statement
}
return originalSend.call(this, str)
}
Expand Down

0 comments on commit 3e73745

Please sign in to comment.