fix(reader): add Always on Top toggle to reader view, closes #3482 (#3505)

- Apply alwaysOnTop setting on reader window init so books opened
  in a new window correctly inherit the setting
- Update tauriHandleSetAlwaysOnTop to apply to all open windows
  so toggling from any window keeps all windows in sync

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Huang Xin
2026-03-10 20:15:08 +08:00
committed by GitHub
parent bcd7a90f27
commit 8df9f909b4
2 changed files with 7 additions and 3 deletions
+4
View File
@@ -6,6 +6,7 @@ import { useTranslation } from '@/hooks/useTranslation';
import { useOpenWithBooks } from '@/hooks/useOpenWithBooks';
import { useSettingsStore } from '@/store/settingsStore';
import { checkForAppUpdates, checkAppReleaseNotes } from '@/helpers/updater';
import { tauriHandleSetAlwaysOnTop } from '@/utils/window';
import Reader from './components/Reader';
// This is only used for the Tauri app in the app router
@@ -24,6 +25,9 @@ export default function Page() {
checkAppReleaseNotes();
}
};
if (appService?.hasWindow && settings.alwaysOnTop) {
tauriHandleSetAlwaysOnTop(settings.alwaysOnTop);
}
doCheckAppUpdates();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [appService?.hasUpdater, settings.autoCheckUpdates]);
+3 -3
View File
@@ -1,4 +1,4 @@
import { getCurrentWindow } from '@tauri-apps/api/window';
import { getAllWindows, getCurrentWindow } from '@tauri-apps/api/window';
import { emitTo, TauriEvent } from '@tauri-apps/api/event';
import { exit } from '@tauri-apps/plugin-process';
import { type as osType } from '@tauri-apps/plugin-os';
@@ -76,8 +76,8 @@ export const tauriHandleToggleFullScreen = async () => {
};
export const tauriHandleSetAlwaysOnTop = async (isAlwaysOnTop: boolean) => {
const currentWindow = getCurrentWindow();
await currentWindow.setAlwaysOnTop(isAlwaysOnTop);
const windows = await getAllWindows();
await Promise.all(windows.map((w) => w.setAlwaysOnTop(isAlwaysOnTop)));
};
export const tauriGetAlwaysOnTop = async () => {