diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 335ac46..a52bbd0 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -138,12 +138,12 @@ async fn download_assets(state: State<'_, AppState>) -> Result<(), String> { let assets = [ ( "injector.exe", - "https://git.rlidentity.me/bits/RLidentity/src/branch/dll/injector.exe", + "https://git.rlidentity.me/bits/RLidentity/raw/branch/main/injector.exe", "B447D618886EEDE9F6A331A5605BFC40FADEB3F508916D8B19916467EC8E0E69" ), ( "RLIdentity.dll", - "https://git.rlidentity.me/bits/RLidentity/src/branch/main/RLIdentity.dll", + "https://git.rlidentity.me/bits/RLidentity/raw/branch/main/RLIdentity.dll", "69108E3E1084EA9AE6AC97D4F19D68356213FEF3A29193D63CE3A6069D333CD8" ), ]; @@ -169,6 +169,10 @@ async fn download_assets(state: State<'_, AppState>) -> Result<(), String> { } Ok(()) } +#[tauri::command] +fn get_app_version(app: tauri::AppHandle) -> String { + app.package_info().version.to_string() +} #[tauri::command] async fn check_status() -> Status { @@ -177,6 +181,13 @@ async fn check_status() -> Status { let is_running = s.processes_by_exact_name("RocketLeague.exe").next().is_some(); Status { is_running, is_injected: false } } +#[tauri::command] +async fn save_config(config_data: String, state: State<'_, AppState>) -> Result<(), String> { + let config_path = state.app_data.join("config.json"); + fs::write(config_path, config_data) + .await + .map_err(|e| format!("failed to save config: {}", e)) +} #[tauri::command] fn minimize_to_tray(window: WebviewWindow) { @@ -203,7 +214,9 @@ pub fn run() { validate_key, check_status, get_hwid, - download_assets + download_assets, + get_app_version, + save_config ]) .setup(|app| { let window = app.get_webview_window("main").unwrap(); diff --git a/src/App.tsx b/src/App.tsx index e6c24e2..79c104e 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,5 +1,6 @@ import { useMemo, useState, useEffect } from "react"; - +import { invoke } from '@tauri-apps/api/core'; +const [version, setVersion] = useState(''); type Status = | "ready" | "saved successfully" @@ -87,7 +88,7 @@ export default function App() { const initialPlatform = useMemo(() => localStorage.getItem(LS_KEYS.platform) ?? "Epic", []); const initialAutoInject = useMemo(() => localStorage.getItem(LS_KEYS.autoInject) === "true", []); const initialTheme = useMemo(() => (localStorage.getItem(LS_KEYS.theme) ?? "phantom") as ThemeId, []); - + const [version, setVersion] = useState(''); const [apiKey, setApiKey] = useState(initialApiKey); const [spoofedUsername, setSpoofedUsername] = useState(initialSpoofed); const [isAuthorized, setIsAuthorized] = useState(false); @@ -138,17 +139,21 @@ export default function App() { useEffect(() => { if (initialApiKey) authorize(initialApiKey); syncAssetsAndCheckUpdates(); + tryInvoke("get_app_version").then(v => setVersion(v as string)); }, []); async function syncAssetsAndCheckUpdates() { - if (!isTauriRuntime()) return; - try { - await tryInvoke("download_assets"); - } catch (e) { - console.error("Failed to sync assets:", e); - } - checkForUpdates(); + if (!isTauriRuntime()) return; + try { + setStatus("syncing assets..."); + await tryInvoke("download_assets"); + setStatus("ready"); + } catch (e) { + console.error("Failed to sync assets:", e); + setStatus("Sync Error: " + String(e)); } + checkForUpdates(); +} async function checkForUpdates() { if (!isTauriRuntime()) return; @@ -300,9 +305,11 @@ export default function App() { style={{ cursor: "default" }} />