Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions openless-all/app/src/components/Onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// 触发条件:App.tsx 启动检查 accessibility + microphone,任一未授权则渲染本组件而非主 Shell。
// 与 Swift `Sources/OpenLessApp/Onboarding/` 同语义,但简化为单页三步。

import { useEffect, useState } from 'react';
import { useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import {
checkAccessibilityPermission,
Expand All @@ -25,6 +25,7 @@ export function Onboarding({ onComplete }: OnboardingProps) {
const [accessibility, setAccessibility] = useState<PermissionStatus>('notDetermined');
const [microphone, setMicrophone] = useState<PermissionStatus>('notDetermined');
const [busy, setBusy] = useState(false);
const refreshTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const { capability } = useHotkeySettings();

const refresh = async () => {
Expand All @@ -48,6 +49,7 @@ export function Onboarding({ onComplete }: OnboardingProps) {
return () => {
window.clearInterval(id);
window.removeEventListener('focus', onFocus);
if (refreshTimeoutRef.current) clearTimeout(refreshTimeoutRef.current);
};
}, []);

Expand Down Expand Up @@ -76,7 +78,8 @@ export function Onboarding({ onComplete }: OnboardingProps) {
} finally {
setBusy(false);
}
setTimeout(refresh, 800);
if (refreshTimeoutRef.current) clearTimeout(refreshTimeoutRef.current);
refreshTimeoutRef.current = window.setTimeout(refresh, 800);
};

return (
Expand Down
10 changes: 9 additions & 1 deletion openless-all/app/src/pages/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -735,11 +735,19 @@ function LanguageSection() {
function AboutSection() {
const { t } = useTranslation();
const [qqCopied, setQqCopied] = useState(false);
const qqCopiedRef = useRef<ReturnType<typeof setTimeout> | null>(null);

useEffect(() => {
return () => {
if (qqCopiedRef.current) clearTimeout(qqCopiedRef.current);
};
}, []);

const copyQq = () => {
navigator.clipboard?.writeText('1078960553');
setQqCopied(true);
setTimeout(() => setQqCopied(false), 1500);
if (qqCopiedRef.current) clearTimeout(qqCopiedRef.current);
qqCopiedRef.current = window.setTimeout(() => setQqCopied(false), 1500);
};

return (
Expand Down
Loading