fix: use external browsers to open links in epub file, closes #1211 (#1228)

This commit is contained in:
Huang Xin
2025-05-23 14:15:57 +08:00
committed by GitHub
parent facf5fba75
commit 6a48f3feb4
2 changed files with 20 additions and 0 deletions
@@ -15,6 +15,7 @@ import { useSettingsStore } from '@/store/settingsStore';
import { useDeviceControlStore } from '@/store/deviceStore';
import { useScreenWakeLock } from '@/hooks/useScreenWakeLock';
import { eventDispatcher } from '@/utils/event';
import { interceptGlobalOpen } from '@/utils/open';
import { mountAdditionalFonts } from '@/utils/style';
import { setSystemUIVisibility } from '@/utils/bridge';
import { AboutWindow } from '@/components/AboutWindow';
@@ -39,6 +40,7 @@ const Reader: React.FC<{ ids?: string }> = ({ ids }) => {
useEffect(() => {
mountAdditionalFonts(document);
interceptGlobalOpen();
}, []);
useEffect(() => {
+18
View File
@@ -0,0 +1,18 @@
import { openUrl } from '@tauri-apps/plugin-opener';
import { isTauriAppPlatform } from '@/services/environment';
export const interceptGlobalOpen = () => {
const windowOpen = window.open;
globalThis.open = function (
url?: string | URL,
target?: string,
features?: string,
): Window | null {
if (isTauriAppPlatform()) {
openUrl(url?.toString() || '');
return null;
} else {
return windowOpen(url, target, features);
}
};
};