s
This commit is contained in:
@@ -187,6 +187,7 @@ export function LiveAndroidStreamConsole({
|
||||
server_version?: string;
|
||||
hint_zh?: string;
|
||||
} | null>(null);
|
||||
const [pageVisible, setPageVisible] = useState(true);
|
||||
const lastTapRef = useRef<{ t: number; x: number; y: number } | null>(null);
|
||||
const imgRef = useRef<HTMLImageElement | null>(null);
|
||||
const canvasRef = useRef<HTMLCanvasElement | null>(null);
|
||||
@@ -206,6 +207,13 @@ export function LiveAndroidStreamConsole({
|
||||
setFrameTs((n) => n + 1);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const onVis = () => setPageVisible(document.visibilityState === "visible");
|
||||
onVis();
|
||||
document.addEventListener("visibilitychange", onVis);
|
||||
return () => document.removeEventListener("visibilitychange", onVis);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
try {
|
||||
const raw = window.localStorage.getItem(BOOKMARKS_KEY);
|
||||
@@ -256,10 +264,15 @@ export function LiveAndroidStreamConsole({
|
||||
}, [apiBase, adbAvailable, serial]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!adbAvailable || !serial || liveMs <= 0 || scrcpyStream) return;
|
||||
if (!adbAvailable || !serial || liveMs <= 0 || scrcpyStream || !pageVisible) return;
|
||||
const id = window.setInterval(() => setFrameTs((n) => n + 1), liveMs);
|
||||
return () => clearInterval(id);
|
||||
}, [adbAvailable, liveMs, serial, scrcpyStream]);
|
||||
}, [adbAvailable, liveMs, pageVisible, serial, scrcpyStream]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!pageVisible || !adbAvailable || !serial || scrcpyStream) return;
|
||||
bumpFrame();
|
||||
}, [adbAvailable, bumpFrame, pageVisible, serial, scrcpyStream]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!adbAvailable) {
|
||||
|
||||
Reference in New Issue
Block a user