Skip to content

Commit

Permalink
Merge pull request #114 from fishshi/OptiRecord
Browse files Browse the repository at this point in the history
feat: Better RecordRank
  • Loading branch information
ximu3 authored Jan 2, 2025
2 parents b58a489 + aba863f commit aa4ce65
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
7 changes: 5 additions & 2 deletions src/renderer/src/pages/Record/PlayedTimesRank.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ export function PlayedTimesRank({ className }: { className?: string }): JSX.Elem
return (
<GamePoster
isShowGameName
infoStyle={cn('flex-row text-sm gap-3 justify-start items-center pl-3')}
fontStyles={{ name: 'text-lg w-[330px]', additionalInfo: 'text-sm' }}
infoStyle={cn('flex-row gap-3 justify-between items-center pl-3 pr-3')}
fontStyles={{
name: 'text-lg grow',
additionalInfo: 'text-sm w-[40px] text-end flex-shrink-0 xl:w-auto'
}}
className={cn('w-full h-[50px]')}
key={gameId}
gameId={gameId}
Expand Down
19 changes: 14 additions & 5 deletions src/renderer/src/pages/Record/PlayingTimeRank.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import { useGameIndexManager } from '~/hooks'
export function PlayingTimeRank({ className }: { className?: string }): JSX.Element {
const { sort, gameIndex } = useGameIndexManager()
const sortedGameIds = sort('playingTime', 'desc')
const formatTime = (time: number): string => {
let res: string = formatTimeToChinese(time)
if (!res.endsWith('秒')) {
if (res.split(' ')[0].length >= 2) res = res.replace(' ', '\n')
}
return res
}
return (
<div className={cn(className)}>
{sortedGameIds.length === 0 ? (
Expand All @@ -17,15 +24,17 @@ export function PlayingTimeRank({ className }: { className?: string }): JSX.Elem
return (
<GamePoster
isShowGameName
infoStyle={cn('flex-row text-sm gap-3 justify-start items-center pl-3')}
fontStyles={{ name: 'text-lg w-[330px]', additionalInfo: 'text-sm' }}
infoStyle={cn('flex-row gap-3 justify-between items-center pl-3 pr-3')}
fontStyles={{
name: 'text-lg grow',
additionalInfo:
'whitespace-pre-wrap text-sm w-[40px] text-end flex-shrink-0 xl:w-auto xl:whitespace-normal'
}}
className={cn('w-full h-[50px]')}
key={gameId}
gameId={gameId}
additionalInfo={
game.playingTime == 0
? '从未游玩'
: formatTimeToChinese(game.playingTime as number)
game.playingTime == 0 ? '从未游玩' : formatTime(game.playingTime as number)
}
/>
)
Expand Down
7 changes: 5 additions & 2 deletions src/renderer/src/pages/Record/ScoreRank.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ export function ScoreRank({ className }: { className?: string }): JSX.Element {
return (
<GamePoster
isShowGameName
infoStyle={cn('flex-row text-sm gap-3 justify-start items-center pl-3')}
fontStyles={{ name: 'text-lg w-[330px]', additionalInfo: 'text-sm' }}
infoStyle={cn('flex-row gap-3 justify-between items-center pl-3 pr-3')}
fontStyles={{
name: 'text-lg grow',
additionalInfo: 'text-sm w-[40px] text-end flex-shrink-0 xl:w-auto'
}}
className={cn('w-full h-[50px]')}
key={gameId}
gameId={gameId}
Expand Down

0 comments on commit aa4ce65

Please sign in to comment.