Skip to content

Commit 84ecacf

Browse files
committed
fix: микрофон
1 parent 6b5c183 commit 84ecacf

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

src/features/add-transaction/AddTransactionSheet.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,21 @@ export const AddTransactionSheet = ({ open, onClose, onAdd, defaultDate }: Props
8585
{mode === 'voice' && (
8686
<div className="flex flex-col items-center gap-4 py-2">
8787
{!voice.supported ? (
88-
<p className="text-sm text-text-secondary text-center">Голосовой ввод не поддерживается в этом браузере. Воспользуйтесь ручным вводом.</p>
88+
<div className="flex flex-col items-center gap-3 text-center py-2">
89+
<span className="text-4xl">{voice.notSecure ? '🔒' : '🎙️'}</span>
90+
<p className="text-sm font-semibold text-text-primary">
91+
{voice.notSecure ? 'Требуется HTTPS' : 'Браузер не поддерживает'}
92+
</p>
93+
<p className="text-sm text-text-secondary leading-snug">
94+
{voice.notSecure
95+
? 'Голосовой ввод работает только на защищённых сайтах (HTTPS). Откройте сайт по https:// или воспользуйтесь ручным вводом.'
96+
: 'Голосовой ввод не поддерживается в этом браузере. Попробуйте Chrome или Safari.'}
97+
</p>
98+
<button onClick={() => setMode('manual')}
99+
className="text-sm font-semibold text-primary mt-1">
100+
Перейти к ручному вводу →
101+
</button>
102+
</div>
89103
) : (
90104
<>
91105
<button

src/features/add-transaction/useVoiceCapture.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ export const useVoiceCapture = () => {
1515
const [transcript, setTranscript] = useState('');
1616
const [error, setError] = useState<string | null>(null);
1717
const [supported, setSupported] = useState(true);
18+
const [notSecure, setNotSecure] = useState(false);
1819

1920
useEffect(() => {
21+
// Microphone API requires a secure context (HTTPS / localhost)
22+
if (!window.isSecureContext) { setSupported(false); setNotSecure(true); return; }
2023
const SRClass = (window as any).SpeechRecognition || (window as any).webkitSpeechRecognition;
2124
if (!SRClass) { setSupported(false); return; }
2225
srClassRef.current = SRClass;
@@ -71,6 +74,7 @@ export const useVoiceCapture = () => {
7174

7275
return {
7376
supported,
77+
notSecure,
7478
listening,
7579
transcript,
7680
error,

0 commit comments

Comments
 (0)