feat: Implement sidebar toggle functionality with keyboard shortcuts and improve translations

This commit is contained in:
twwu
2025-07-08 20:04:15 +08:00
parent b3431ab0c4
commit 1c85dada53
8 changed files with 142 additions and 55 deletions

View File

@ -4,13 +4,13 @@ import { useTranslation } from 'react-i18next'
import { useKeyPress } from 'ahooks'
import Button from '../../base/button'
import Tooltip from '../../base/tooltip'
import { getKeyboardKeyCodeBySystem } from '../utils'
import { getKeyboardKeyCodeBySystem, getKeyboardKeyNameBySystem } from '../utils'
type VersionHistoryButtonProps = {
onClick: () => Promise<unknown> | unknown
}
const VERSION_HISTORY_SHORTCUT = ['', '⇧', 'H']
const VERSION_HISTORY_SHORTCUT = ['ctrl', '⇧', 'H']
const PopupContent = React.memo(() => {
const { t } = useTranslation()
@ -25,7 +25,7 @@ const PopupContent = React.memo(() => {
key={key}
className='system-kbd rounded-[4px] bg-components-kbd-bg-white px-[1px] text-text-tertiary'
>
{key}
{getKeyboardKeyNameBySystem(key)}
</span>
))}
</div>
@ -45,8 +45,7 @@ const VersionHistoryButton: FC<VersionHistoryButtonProps> = ({
useKeyPress(`${getKeyboardKeyCodeBySystem('ctrl')}.shift.h`, (e) => {
e.preventDefault()
handleViewVersionHistory()
},
{ exactMatch: true, useCapture: true })
}, { exactMatch: true, useCapture: true })
return <Tooltip
popupContent={<PopupContent />}