Skip to content

Commit

Permalink
fix: 排行榜筛选栏样式
Browse files Browse the repository at this point in the history
  • Loading branch information
Lil-Ran committed Aug 18, 2024
1 parent a2b94e6 commit ec0f2b8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 28 deletions.
63 changes: 37 additions & 26 deletions src/GZCTF/ClientApp/src/components/ScoreboardTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,12 @@ const ScoreboardTable: FC<ScoreboardProps> = ({
const [searchTextBuffer, setSearchTextBuffer] = useState<string | null>('')
const [searchCloseButtonVisible, setSearchCloseButtonVisible] = useState(false)
const [filterTips, setFilterTips] = useState('')
const onSearch = (searchText: string) => {
setTitlePattern(searchText)
setSearchTextBuffer(searchText)
setSearchCloseButtonVisible(searchText.length > 0)
setPage(1)
}

const [updatingBarrier, setUpdatingBarrier] = useState(true)

Expand Down Expand Up @@ -339,13 +345,20 @@ const ScoreboardTable: FC<ScoreboardProps> = ({
<Select
defaultValue="all"
data={[
{ value: 'all', label: t('game.label.score_table.rank_total') },
...Object.keys(scoreboard.timeLines)
.filter((k) => k !== 'all')
.map((o) => ({
value: o,
label: o === 'nopub' ? t('game.label.score_table.rank_nopub') : o,
})),
{
group: 'Fixed', items: [
{ value: 'all', label: t('game.label.score_table.rank_total') },
{ value: '公开赛道', label: '公开赛道' },
{ value: 'nopub', label: t('game.label.score_table.rank_nopub') },
]
},
{
group: 'Dynamic', items: [
...Object.keys(scoreboard.timeLines)
.filter((k) => !['all', 'nopub', '公开赛道'].includes(k))
.map((o) => ({ value: o, label: o }))
]
},
]}
value={organization}
searchable
Expand All @@ -365,33 +378,31 @@ const ScoreboardTable: FC<ScoreboardProps> = ({
<TextInput
placeholder={t('game.placeholder.scoreboard_search')}
leftSection={
<ActionIcon variant="transparent" color="dimmed" onClick={() => {
const searchText = searchTextBuffer?.trim() ?? ''
setTitlePattern(searchText)
setSearchTextBuffer(searchText)
setSearchCloseButtonVisible(searchText.length > 0)
setPage(1)
}}>
<ActionIcon
variant="transparent"
color="dimmed"
onClick={() => onSearch(searchTextBuffer?.trim() ?? '')}
>
<Icon path={mdiMagnify} size={0.8} />
</ActionIcon>
}
rightSection={searchCloseButtonVisible &&
<CloseButton color="dimmed" size={'sm'} onClick={() => {
setSearchTextBuffer('')
setSearchCloseButtonVisible(false)
setTitlePattern('')
setPage(1)
}} />}
rightSection={
searchCloseButtonVisible &&
<CloseButton
color="dimmed"
size={'sm'}
onClick={() => onSearch('')}
/>
}
onKeyDown={(e) =>
updatingBarrier && e.key === 'Enter' && onSearch(searchTextBuffer?.trim() ?? '')
}
value={searchTextBuffer ?? ''}
onChange={(e) => {
setSearchTextBuffer(e.currentTarget.value)
setSearchCloseButtonVisible(e.currentTarget.value.length > 0)
}}
styles={{
root: {
width: "36%",
},
}}
flex={1}
/>
<Switch
checked={hideWeekInTitle}
Expand Down
4 changes: 2 additions & 2 deletions src/GZCTF/ClientApp/src/locales/zh_CN/game.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
"score_table": {
"rank_organization": "排名",
"rank_total": "总排名",
"rank_nopub": "非公开赛道",
"rank_nopub": "全部校内赛道",
"score": "得分",
"score_total": "总分",
"solved_count": "解题数量",
Expand Down Expand Up @@ -232,7 +232,7 @@
"placeholder": {
"challenge_search": "正则匹配题目名称",
"no_solved": "Ouch! 这支队伍还没有解出题目呢……",
"scoreboard_search": "正则匹配题目名称,输入后点击放大镜图标"
"scoreboard_search": "正则匹配题目名称"
},
"tab": {
"challenge": "比赛题目",
Expand Down

0 comments on commit ec0f2b8

Please sign in to comment.