Skip to content

Commit 3e73745

Browse files
committed
fix: 修复题库页评分过滤失效
1 parent 75523fa commit 3e73745

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/content/pages/problemset/intercept.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,15 @@ export function intercept(): void {
1919
password?: string,
2020
disbaleIntercept?: boolean
2121
) {
22+
let pathname = url
23+
try {
24+
const urlObj = new URL(url)
25+
pathname = urlObj.pathname
26+
} catch (error) {}
2227
if (
2328
!disbaleIntercept &&
2429
method.toLocaleLowerCase() === 'post' &&
25-
url === `/graphql/`
30+
pathname === `/graphql/`
2631
) {
2732
const originalSend = this.send
2833

@@ -115,6 +120,19 @@ export function intercept(): void {
115120
} catch (error) {
116121
//
117122
}
123+
} else if (typeof str === 'string') {
124+
try {
125+
const body = JSON.parse(str)
126+
const sortOrder = body?.variables?.filters?.sortOrder
127+
if (
128+
sortOrder &&
129+
sortOrder !== 'DESCENDING' &&
130+
sortOrder !== 'ASCENDING'
131+
) {
132+
body.variables.filters.sortOrder = 'DESCENDING'
133+
str = JSON.stringify(body)
134+
}
135+
} catch (error) {}
118136
}
119137
return originalSend.call(this, str)
120138
}

0 commit comments

Comments
 (0)