From d91314112de68bad59baa1b98e1a1f233e9121f9 Mon Sep 17 00:00:00 2001 From: Lncvrt Date: Fri, 3 Apr 2026 10:51:23 -0700 Subject: [PATCH] Should be ready for release now. Will do some testing before. --- src-tauri/src/lib.rs | 45 +++++++++++++++++++++++--------- src/app/main/layout.tsx | 42 +---------------------------- src/app/update/outdated/page.tsx | 20 ++++++++++++++ 3 files changed, 53 insertions(+), 54 deletions(-) create mode 100644 src/app/update/outdated/page.tsx diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 109492c..01ffd61 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -19,7 +19,6 @@ use tauri::window::{ProgressBarState, ProgressBarStatus}; use tauri::{AppHandle, Emitter, Manager}; use tauri_plugin_os::platform; use tauri_plugin_prevent_default::Flags; -use tauri_plugin_updater::UpdaterExt; use tokio::io::AsyncReadExt; use tokio::{io::AsyncWriteExt, time::timeout}; use zip::ZipArchive; @@ -31,6 +30,9 @@ use sysinfo::System; #[cfg(unix)] use std::os::unix::fs::PermissionsExt; +#[cfg(not(debug_assertions))] +use tauri_plugin_updater::UpdaterExt; + static CANCEL_MAP: OnceLock> = OnceLock::new(); fn cancel_map() -> &'static DashMap { @@ -561,35 +563,52 @@ pub fn run() { cancel_download ]) .setup(|app| { + let window = app.get_webview_window("main").unwrap(); + #[cfg(target_os = "windows")] { use tauri_plugin_decorum::WebviewWindowExt; - if let Some(main_window) = app.get_webview_window("main") { - if let Err(e) = main_window.create_overlay_titlebar() { - eprintln!("Failed to create overlay titlebar: {:?}", e); - } + if let Err(e) = window.create_overlay_titlebar() { + eprintln!("Failed to create overlay titlebar: {:?}", e); } } - let handle = app.handle().clone(); - tauri::async_runtime::spawn(async move { - update(handle).await.unwrap(); - }); + #[cfg(not(debug_assertions))] + { + let handle = app.handle().clone(); + tauri::async_runtime::spawn(async move { + update(handle, window.clone()).await.unwrap(); + }); + } + #[cfg(debug_assertions)] + { + let mut new_url = window.url().unwrap(); + new_url.set_path("/main"); + window.navigate(new_url).unwrap(); + } + Ok(()) }) .run(tauri::generate_context!()) .expect("error while running tauri application"); } -async fn update(app: tauri::AppHandle) -> tauri_plugin_updater::Result<()> { - let window = app.get_webview_window("main").unwrap(); - +#[cfg(not(debug_assertions))] +async fn update( + app: tauri::AppHandle, + window: tauri::WebviewWindow, +) -> tauri_plugin_updater::Result<()> { let target = { #[cfg(target_os = "linux")] { if std::path::Path::new("/etc/debian_version").exists() { "linux-debian" - } else { + } else if std::path::Path::new("/etc/redhat-release").exists() { "linux-fedora" + } else { + let mut new_url = window.url().unwrap(); + new_url.set_path("/update/outdated"); + window.navigate(new_url).unwrap(); + return Ok(()); } } #[cfg(not(target_os = "linux"))] diff --git a/src/app/main/layout.tsx b/src/app/main/layout.tsx index 44a8792..f8dbf6c 100644 --- a/src/app/main/layout.tsx +++ b/src/app/main/layout.tsx @@ -5,7 +5,6 @@ import { useCallback, useEffect, useRef, useState } from 'react' import Sidebar from '@/components/Sidebar' import { DownloadProgress } from '@/types/DownloadProgress' import { app } from '@tauri-apps/api' -import { openUrl } from '@tauri-apps/plugin-opener' import { GlobalProvider } from '@/providers/GlobalProvider' import { Roboto } from 'next/font/google' import { ServerVersionsResponse } from '@/types/ServerVersionsResponse' @@ -51,7 +50,6 @@ export default function RootLayout ({ }) { const [loading, setLoading] = useState(true) const [loadingText, setLoadingText] = useState('Loading...') - const [outdated, setOutdated] = useState(false) const [version, setVersion] = useState(null) const [platformName, setPlatformName] = useState(null) @@ -266,27 +264,6 @@ export default function RootLayout ({ setPlatformName(platform()) const client = await app.getVersion() setVersion(client) - if (process.env.NODE_ENV === 'production') { - try { - const response = await fetch( - 'https://games.lncvrt.xyz/api/launcher/latest' - ) - const signature = response.headers.get('x-signature') ?? '' - const data = await response.text() - if (await verifySignature(data, signature)) { - if (data !== client) { - setOutdated(true) - return - } - } else { - setLoadingText('Failed to check latest version.') - return - } - } catch { - setLoadingText('Failed to check latest version.') - return - } - } try { const response = await fetch( `https://games.lncvrt.xyz/api/launcher/versions?platform=${platform()}&arch=${arch()}` @@ -712,24 +689,7 @@ export default function RootLayout ({ : 'h-screen' } flex items-center justify-center`} > - {outdated ? ( -
-

Outdated Launcher!

-

- Please update to the latest version to continue. -

- -
- ) : ( -

{loadingText}

- )} +

{loadingText}

) : ( diff --git a/src/app/update/outdated/page.tsx b/src/app/update/outdated/page.tsx new file mode 100644 index 0000000..103e986 --- /dev/null +++ b/src/app/update/outdated/page.tsx @@ -0,0 +1,20 @@ +'use client' + +import { openUrl } from '@tauri-apps/plugin-opener' + +export default function UpdateCheckingPage () { + return ( +
+

Outdated Launcher!

+

+ Please update to the latest version to continue. +

+ +
+ ) +}