元旦节皮肤

This commit is contained in:
eafonyang
2026-10-09 13:56:41 +08:00
parent 4363b10917
commit b99655277c
20 changed files with 970 additions and 19 deletions
+6
View File
@@ -58,6 +58,8 @@ export function DeviceProvider({ children }: { children: React.ReactNode }) {
const [api, setApi] = useState<LuxsinAPI | null>(null);
const lastMsgCountRef = useRef<number>(-1);
const pollIntervalRef = useRef<ReturnType<typeof setInterval> | null>(null);
/** 轮询重入保护:上一轮未 settle(如断网挂起至超时)则跳过本轮,避免挂起请求堆叠。 */
const pollInFlightRef = useRef(false);
const autoConnectStartedRef = useRef(false);
const setDeviceIp = useCallback((newIp: string) => {
@@ -260,6 +262,8 @@ export function DeviceProvider({ children }: { children: React.ReactNode }) {
if (!isConnected || isDemoMode || !api) return;
const poll = async () => {
if (pollInFlightRef.current) return;
pollInFlightRef.current = true;
try {
const count = await api.getMsgCount();
if (count !== lastMsgCountRef.current) {
@@ -270,6 +274,8 @@ export function DeviceProvider({ children }: { children: React.ReactNode }) {
}
} catch {
// Silently fail polling
} finally {
pollInFlightRef.current = false;
}
};