savesave
This commit is contained in:
21
src/App.jsx
21
src/App.jsx
@@ -73,6 +73,7 @@ export default function App() {
|
||||
const [shortcutUpKey, setShortcutUpKey] = useState('q');
|
||||
const [shortcutDownKey, setShortcutDownKey] = useState('e');
|
||||
const [recordingKey, setRecordingKey] = useState(null);
|
||||
const [shortcutConflict, setShortcutConflict] = useState(false);
|
||||
const [userStatus, setUserStatus] = useState('online');
|
||||
|
||||
// Estado da Comunidade
|
||||
@@ -308,6 +309,8 @@ export default function App() {
|
||||
|
||||
useEffect(() => {
|
||||
if (!shortcutsEnabled) return;
|
||||
// Se as teclas forem iguais, ambos os atalhos ficam desativados
|
||||
if (shortcutUpKey.toLowerCase() === shortcutDownKey.toLowerCase()) return;
|
||||
|
||||
const handleKeyDown = (e) => {
|
||||
if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') return;
|
||||
@@ -338,16 +341,18 @@ export default function App() {
|
||||
if (recordingKey === 'up') {
|
||||
setShortcutUpKey(key);
|
||||
saveUserSetting('shortcutUpKey', key);
|
||||
setShortcutConflict(key.toLowerCase() === shortcutDownKey.toLowerCase());
|
||||
} else if (recordingKey === 'down') {
|
||||
setShortcutDownKey(key);
|
||||
saveUserSetting('shortcutDownKey', key);
|
||||
setShortcutConflict(key.toLowerCase() === shortcutUpKey.toLowerCase());
|
||||
}
|
||||
setRecordingKey(null);
|
||||
};
|
||||
|
||||
window.addEventListener('keydown', handleCapture, true);
|
||||
return () => window.removeEventListener('keydown', handleCapture, true);
|
||||
}, [recordingKey]);
|
||||
}, [recordingKey, shortcutUpKey, shortcutDownKey]);
|
||||
|
||||
useEffect(() => {
|
||||
if (editingItem && editingItem.color) {
|
||||
@@ -493,8 +498,11 @@ export default function App() {
|
||||
}
|
||||
if (data.settings.isPrivate !== undefined) setIsPrivate(data.settings.isPrivate);
|
||||
if (data.settings.shortcutsEnabled !== undefined) setShortcutsEnabled(data.settings.shortcutsEnabled);
|
||||
if (data.settings.shortcutUpKey !== undefined) setShortcutUpKey(data.settings.shortcutUpKey);
|
||||
if (data.settings.shortcutDownKey !== undefined) setShortcutDownKey(data.settings.shortcutDownKey);
|
||||
const loadedUp = data.settings.shortcutUpKey !== undefined ? data.settings.shortcutUpKey : 'q';
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -2814,6 +2822,13 @@ export default function App() {
|
||||
</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>
|
||||
<p className="font-bold text-inherit flex items-center gap-2">{t('dailyOutfitNotification')}</p>
|
||||
|
||||
@@ -231,6 +231,7 @@ export const translations = {
|
||||
shortcutDownDesc: "Tecla para navegar para baixo no menu",
|
||||
pressAnyKey: "Pressione uma tecla...",
|
||||
spaceKey: "Espaço",
|
||||
shortcutConflictWarning: "Não podes usar a mesma tecla para cima e para baixo. Os atalhos estão desativados.",
|
||||
},
|
||||
EN: {
|
||||
loginModeIntro: "The Future of Your Style",
|
||||
@@ -464,6 +465,7 @@ export const translations = {
|
||||
shortcutDownDesc: "Key to navigate down in the menu",
|
||||
pressAnyKey: "Press a key...",
|
||||
spaceKey: "Space",
|
||||
shortcutConflictWarning: "You cannot use the same key for up and down. Shortcuts are disabled.",
|
||||
},
|
||||
ES: {
|
||||
loginModeIntro: "El Futuro de Tu Estilo",
|
||||
@@ -697,6 +699,7 @@ export const translations = {
|
||||
shortcutDownDesc: "Tecla para navegar hacia abajo en el menú",
|
||||
pressAnyKey: "Presione una tecla...",
|
||||
spaceKey: "Espacio",
|
||||
shortcutConflictWarning: "No puedes usar la misma tecla para arriba y abajo. Los atajos están desactivados.",
|
||||
},
|
||||
FR: {
|
||||
loginModeIntro: "Le Futur de Ton Style",
|
||||
@@ -930,6 +933,7 @@ export const translations = {
|
||||
shortcutDownDesc: "Touche pour naviguer vers le bas dans le menu",
|
||||
pressAnyKey: "Appuyez sur une touche...",
|
||||
spaceKey: "Espace",
|
||||
shortcutConflictWarning: "Vous ne pouvez pas utiliser la même touche pour haut et bas. Les raccourcis sont désactivés.",
|
||||
},
|
||||
DE: {
|
||||
loginModeIntro: "Die Zukunft deines Stils",
|
||||
@@ -1163,5 +1167,6 @@ export const translations = {
|
||||
shortcutDownDesc: "Taste zum Navigieren nach unten im Menü",
|
||||
pressAnyKey: "Taste drücken...",
|
||||
spaceKey: "Leertaste",
|
||||
shortcutConflictWarning: "Du kannst dieselbe Taste nicht für oben und unten verwenden. Tastenkürzel sind deaktiviert.",
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user