diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index 7f471f8..711d80c 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -1,3 +1,4 @@ +#![allow(unexpected_cfgs)] use base64::engine::general_purpose::STANDARD; use base64::Engine; use reqwest::header::{HeaderMap, HeaderValue, REFERER, USER_AGENT}; @@ -341,7 +342,7 @@ async fn get_or_create_harvester( if let Ok(ns_window) = win.ns_window() { let ns_window = ns_window as *mut objc::runtime::Object; unsafe { - let _: () = msg_send![ns_window, setAlphaValue: 0.0f64]; + let _: () = msg_send![ns_window, setAlphaValue: 0.01f64]; } } } @@ -423,7 +424,11 @@ async fn poll_harvest(app: AppHandle, req_id: u64, url: String) { ); } } - Err(e) => eprintln!("[harvest#{}] eval error: {}", req_id, e), + Err(e) => { + if !e.contains("eval timed out") { + eprintln!("[harvest#{}] eval error: {}", req_id, e); + } + } } let settled = start.elapsed() >= Duration::from_millis(SETTLE_GRACE_MS); diff --git a/src-tauri/src/types.rs b/src-tauri/src/types.rs index 8d855a3..358e326 100644 --- a/src-tauri/src/types.rs +++ b/src-tauri/src/types.rs @@ -10,14 +10,4 @@ pub struct ChapterData { pub cookies: Option, } -#[derive(Debug, Serialize, Deserialize)] -pub struct FetchError { - pub message: String, - pub kind: String, -} -impl std::fmt::Display for FetchError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}: {}", self.kind, self.message) - } -} diff --git a/src/components/MangaViewer.tsx b/src/components/MangaViewer.tsx index bf7a33f..04daf7b 100644 --- a/src/components/MangaViewer.tsx +++ b/src/components/MangaViewer.tsx @@ -1,9 +1,9 @@ +import { getCurrentWindow } from '@tauri-apps/api/window'; import { useState, useEffect, useCallback, useRef } from 'react'; import type { ViewerSettings } from '../types'; import type { ChapterData } from '../types'; import { MangaPage } from './MangaPage'; import { ViewerToolbar } from './ViewerToolbar'; -import { getCurrentWindow } from '@tauri-apps/api/window'; import { SettingsPanel } from './SettingsPanel'; interface MangaViewerProps { @@ -172,7 +172,7 @@ export function MangaViewer({ }; window.addEventListener('keydown', handler); return () => window.removeEventListener('keydown', handler); - }, [goNext, goPrev, showSettings, settings.direction, toggleFullscreen]); + }, [goNext, goPrev, showSettings, settings.direction]); // Auto-hide toolbar const resetToolbarTimer = useCallback(() => { @@ -190,17 +190,23 @@ export function MangaViewer({ }; }, []); - const toggleFullscreen = useCallback(async () => { + const toggleFullscreen = async () => { try { const win = getCurrentWindow(); - const current = await win.isFullscreen(); - const nextState = !current; - await win.setFullscreen(nextState); - setIsFullscreen(nextState); + const isFull = await win.isFullscreen(); + await win.setFullscreen(!isFull); + setIsFullscreen(!isFull); } catch (e) { - console.error('Failed to toggle fullscreen', e); + console.error("Native fullscreen failed, using DOM fallback", e); + if (!document.fullscreenElement) { + containerRef.current?.requestFullscreen().catch(console.error); + setIsFullscreen(true); + } else { + document.exitFullscreen().catch(console.error); + setIsFullscreen(false); + } } - }, []); + }; const bgMap = { black: '#000000',