This commit is contained in:
2026-06-09 01:10:51 +01:00
parent ab19a3bfc9
commit a6bfcb10b0
2 changed files with 23 additions and 3 deletions

View File

@@ -73,6 +73,7 @@ export default function App() {
const [shortcutUpKey, setShortcutUpKey] = useState('q'); const [shortcutUpKey, setShortcutUpKey] = useState('q');
const [shortcutDownKey, setShortcutDownKey] = useState('e'); const [shortcutDownKey, setShortcutDownKey] = useState('e');
const [recordingKey, setRecordingKey] = useState(null); const [recordingKey, setRecordingKey] = useState(null);
const [shortcutConflict, setShortcutConflict] = useState(false);
const [userStatus, setUserStatus] = useState('online'); const [userStatus, setUserStatus] = useState('online');
// Estado da Comunidade // Estado da Comunidade
@@ -308,6 +309,8 @@ export default function App() {
useEffect(() => { useEffect(() => {
if (!shortcutsEnabled) return; if (!shortcutsEnabled) return;
// Se as teclas forem iguais, ambos os atalhos ficam desativados
if (shortcutUpKey.toLowerCase() === shortcutDownKey.toLowerCase()) return;
const handleKeyDown = (e) => { const handleKeyDown = (e) => {
if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') return; if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') return;
@@ -338,16 +341,18 @@ export default function App() {
if (recordingKey === 'up') { if (recordingKey === 'up') {
setShortcutUpKey(key); setShortcutUpKey(key);
saveUserSetting('shortcutUpKey', key); saveUserSetting('shortcutUpKey', key);
setShortcutConflict(key.toLowerCase() === shortcutDownKey.toLowerCase());
} else if (recordingKey === 'down') { } else if (recordingKey === 'down') {
setShortcutDownKey(key); setShortcutDownKey(key);
saveUserSetting('shortcutDownKey', key); saveUserSetting('shortcutDownKey', key);
setShortcutConflict(key.toLowerCase() === shortcutUpKey.toLowerCase());
} }
setRecordingKey(null); setRecordingKey(null);
}; };
window.addEventListener('keydown', handleCapture, true); window.addEventListener('keydown', handleCapture, true);
return () => window.removeEventListener('keydown', handleCapture, true); return () => window.removeEventListener('keydown', handleCapture, true);
}, [recordingKey]); }, [recordingKey, shortcutUpKey, shortcutDownKey]);
useEffect(() => { useEffect(() => {
if (editingItem && editingItem.color) { if (editingItem && editingItem.color) {
@@ -493,8 +498,11 @@ export default function App() {
} }
if (data.settings.isPrivate !== undefined) setIsPrivate(data.settings.isPrivate); if (data.settings.isPrivate !== undefined) setIsPrivate(data.settings.isPrivate);
if (data.settings.shortcutsEnabled !== undefined) setShortcutsEnabled(data.settings.shortcutsEnabled); if (data.settings.shortcutsEnabled !== undefined) setShortcutsEnabled(data.settings.shortcutsEnabled);
if (data.settings.shortcutUpKey !== undefined) setShortcutUpKey(data.settings.shortcutUpKey); const loadedUp = data.settings.shortcutUpKey !== undefined ? data.settings.shortcutUpKey : 'q';
if (data.settings.shortcutDownKey !== undefined) setShortcutDownKey(data.settings.shortcutDownKey); const loadedDown = data.settings.shortcutDownKey !== undefined ? data.settings.shortcutDownKey : 'e';
if (data.settings.shortcutUpKey !== undefined) setShortcutUpKey(loadedUp);
if (data.settings.shortcutDownKey !== undefined) setShortcutDownKey(loadedDown);
setShortcutConflict(loadedUp.toLowerCase() === loadedDown.toLowerCase());
if (data.settings.status !== undefined) setUserStatus(data.settings.status); if (data.settings.status !== undefined) setUserStatus(data.settings.status);
} }
} }
@@ -2814,6 +2822,13 @@ export default function App() {
</div> </div>
)} )}
{shortcutsEnabled && shortcutConflict && (
<div className="flex items-center gap-2 px-3 py-2 rounded-xl bg-amber-50 dark:bg-amber-950/40 border border-amber-300 dark:border-amber-700 text-amber-700 dark:text-amber-400 text-xs font-medium animate-pulse">
<span></span>
<span>{t('shortcutConflictWarning') || 'Não podes usar a mesma tecla para cima e para baixo. Os atalhos estão desativados.'}</span>
</div>
)}
<div className="flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4"> <div className="flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4">
<div> <div>
<p className="font-bold text-inherit flex items-center gap-2">{t('dailyOutfitNotification')}</p> <p className="font-bold text-inherit flex items-center gap-2">{t('dailyOutfitNotification')}</p>

View File

@@ -231,6 +231,7 @@ export const translations = {
shortcutDownDesc: "Tecla para navegar para baixo no menu", shortcutDownDesc: "Tecla para navegar para baixo no menu",
pressAnyKey: "Pressione uma tecla...", pressAnyKey: "Pressione uma tecla...",
spaceKey: "Espaço", spaceKey: "Espaço",
shortcutConflictWarning: "Não podes usar a mesma tecla para cima e para baixo. Os atalhos estão desativados.",
}, },
EN: { EN: {
loginModeIntro: "The Future of Your Style", loginModeIntro: "The Future of Your Style",
@@ -464,6 +465,7 @@ export const translations = {
shortcutDownDesc: "Key to navigate down in the menu", shortcutDownDesc: "Key to navigate down in the menu",
pressAnyKey: "Press a key...", pressAnyKey: "Press a key...",
spaceKey: "Space", spaceKey: "Space",
shortcutConflictWarning: "You cannot use the same key for up and down. Shortcuts are disabled.",
}, },
ES: { ES: {
loginModeIntro: "El Futuro de Tu Estilo", loginModeIntro: "El Futuro de Tu Estilo",
@@ -697,6 +699,7 @@ export const translations = {
shortcutDownDesc: "Tecla para navegar hacia abajo en el menú", shortcutDownDesc: "Tecla para navegar hacia abajo en el menú",
pressAnyKey: "Presione una tecla...", pressAnyKey: "Presione una tecla...",
spaceKey: "Espacio", spaceKey: "Espacio",
shortcutConflictWarning: "No puedes usar la misma tecla para arriba y abajo. Los atajos están desactivados.",
}, },
FR: { FR: {
loginModeIntro: "Le Futur de Ton Style", loginModeIntro: "Le Futur de Ton Style",
@@ -930,6 +933,7 @@ export const translations = {
shortcutDownDesc: "Touche pour naviguer vers le bas dans le menu", shortcutDownDesc: "Touche pour naviguer vers le bas dans le menu",
pressAnyKey: "Appuyez sur une touche...", pressAnyKey: "Appuyez sur une touche...",
spaceKey: "Espace", spaceKey: "Espace",
shortcutConflictWarning: "Vous ne pouvez pas utiliser la même touche pour haut et bas. Les raccourcis sont désactivés.",
}, },
DE: { DE: {
loginModeIntro: "Die Zukunft deines Stils", loginModeIntro: "Die Zukunft deines Stils",
@@ -1163,5 +1167,6 @@ export const translations = {
shortcutDownDesc: "Taste zum Navigieren nach unten im Menü", shortcutDownDesc: "Taste zum Navigieren nach unten im Menü",
pressAnyKey: "Taste drücken...", pressAnyKey: "Taste drücken...",
spaceKey: "Leertaste", spaceKey: "Leertaste",
shortcutConflictWarning: "Du kannst dieselbe Taste nicht für oben und unten verwenden. Tastenkürzel sind deaktiviert.",
} }
}; };