Skip to content

Commit 04c8d1e

Browse files
committed
fix(webview): macOS ARCH64 navigation
Signed-off-by: Izuna <izuna.seikatsu@ccbluex.net>
1 parent eb4cf2a commit 04c8d1e

1 file changed

Lines changed: 18 additions & 12 deletions

File tree

src-tauri/src/app/webview.rs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,21 @@
1717
* along with LiquidLauncher. If not, see <https://www.gnu.org/licenses/>.
1818
*/
1919

20+
use crate::app::gui::ShareableWindow;
2021
use crate::minecraft::{
2122
launcher::LauncherData,
2223
progress::{ProgressReceiver, ProgressUpdate},
2324
};
2425
use anyhow::{anyhow, bail, Context, Result};
2526
use serde::Deserialize;
26-
use std::{
27-
sync::{
28-
atomic::{AtomicBool, Ordering},
29-
Arc, Mutex,
30-
},
31-
time::Duration,
32-
};
27+
use std::{sync::{
28+
atomic::{AtomicBool, Ordering},
29+
Arc, Mutex,
30+
}, time::Duration};
3331
use tauri::{Listener, Manager, Url, WebviewWindowBuilder};
3432
use tokio::time::sleep;
3533
use tracing::{debug, error, info};
3634

37-
use super::gui::ShareableWindow;
38-
3935
const MAX_DOWNLOAD_ATTEMPTS: u8 = 2;
4036

4137
pub async fn open_download_page(
@@ -101,6 +97,11 @@ async fn show_webview(url: Url, window: &Arc<Mutex<tauri::Window>>) -> Result<St
10197
}
10298
}?;
10399

100+
// Redirect the download view to the download page
101+
if let Err(e) = download_view.navigate(url.clone()) {
102+
error!("Failed to navigate to download page: {:?}", e);
103+
}
104+
104105
// Show and maximize the download view
105106
download_view
106107
.show()
@@ -109,9 +110,14 @@ async fn show_webview(url: Url, window: &Arc<Mutex<tauri::Window>>) -> Result<St
109110
.maximize()
110111
.context("Failed to maximize the download view")?;
111112

112-
// Redirect the download view to the download page
113-
if let Err(e) = download_view.navigate(url.clone()) {
114-
error!("Failed to navigate to download page: {:?}", e);
113+
// Attempt to navigate to the download page using a JavaScript redirect
114+
#[cfg(target_os = "macos")]
115+
{
116+
// On macOS, we need to wait for the window to be fully loaded before redirecting
117+
if *crate::utils::ARCHITECTURE == crate::utils::Architecture::AARCH64 {
118+
sleep(Duration::from_millis(500)).await;
119+
download_view.eval(&format!("window.location.href = '{}';", url))?;
120+
}
115121
}
116122

117123
debug!("Download view URL: {}", download_view.url()?);

0 commit comments

Comments
 (0)