From 5e8e63b37895172e162d34a97c4991fb2869ceb3 Mon Sep 17 00:00:00 2001 From: Aaron Liu Date: Sun, 27 Apr 2025 10:27:19 +0800 Subject: [PATCH] fix: custom URL scheme in custom viewer cannot be opened on mobile devices (https://github.com/cloudreve/Cloudreve/issues/2314) --- src/redux/thunks/viewer.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/redux/thunks/viewer.ts b/src/redux/thunks/viewer.ts index 0864752..29aa9fb 100644 --- a/src/redux/thunks/viewer.ts +++ b/src/redux/thunks/viewer.ts @@ -219,7 +219,7 @@ export function openViewer(file: FileResponse, viewer: Viewer, size: number, pre fm.list?.files?.forEach((f) => { if (f.id == originalFileId) { fileIndex = files.length; - f = {...file} + f = { ...file }; } if (viewer.exts.indexOf(fileExtension(f.name) ?? "") > -1) { @@ -282,8 +282,14 @@ export function openCustomViewer(file: FileResponse, viewer: Viewer, preferredVe url = url.replace(`{$${key}}`, vars[key]); } + // if not start with http or https, it's a custom scheme + if (!url.startsWith("http") && !url.startsWith("https")) { + window.location.assign(url); + return; + } + if (isTrueVal(viewer.props?.openInNew ?? "")) { - window.open(url); + window.window.open(url); return; }