Skip to content

Commit 044f62e

Browse files
committed
fix(problem-list): 题单页带custom参数的url刷新后不需要等待重定向
1 parent df90b01 commit 044f62e

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

src/content/pages/problemset/Title.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
import TitleBase from './TitleBase'
1616
import { Portal } from '@/components/Portal'
1717
import { routerTo } from '@/utils'
18-
import { selectIsPremium } from '../global/globalSlice'
18+
import { selectCurrentPage, selectIsPremium } from '../global/globalSlice'
1919

2020
interface RankTitleProps {
2121
otherRoots: { [key in OrderBy]?: HTMLElement }
@@ -24,6 +24,7 @@ interface RankTitleProps {
2424
const RankTitle: FC<RankTitleProps> = ({ otherRoots }) => {
2525
const [params, setParams] = useState(parseParams())
2626
const isPremium = useAppSelector(selectIsPremium)
27+
const currentPage = useAppSelector(selectCurrentPage)
2728

2829
useEffect(() => {
2930
SORT_KEY.forEach(({ key }) => {
@@ -47,9 +48,16 @@ const RankTitle: FC<RankTitleProps> = ({ otherRoots }) => {
4748
// 如果第一次访问的 url 中,包含 customSort,则需要进行特殊的处理。
4849
void (async function () {
4950
if (params.custom) {
50-
// 如果包含 customSort,那么一定是包含 id 的 sroting,则一定会重定向一次。
51-
await once('routeChangeComplete')
52-
51+
/**
52+
* 在题库页中,如果包含 custom,那么一定是包含 id 的 sroting,
53+
* 则一定会重定向到 sroting 等于 `ASCENDING`,
54+
* 需要等待重定向完成后,再通过路由跳转到到包含自定义参数的 url
55+
*
56+
* 而在题单页中,则不会进行重定向,就不用去等待
57+
*/
58+
if (currentPage === 'problemsetPage') {
59+
await once('routeChangeComplete')
60+
}
5361
handleCustomSort()()
5462
}
5563
})()

0 commit comments

Comments
 (0)