chore: add platform check

This commit is contained in:
HorizonCode 2025-07-07 15:26:20 +02:00
parent 6d2d5de6d2
commit 3dc62a060e
4 changed files with 39 additions and 3 deletions

View File

@ -634,3 +634,8 @@ pub fn open_url_in_browser(url: String) -> Result<(), String> {
pub fn exit(app: AppHandle) { pub fn exit(app: AppHandle) {
app.exit(0x0100); app.exit(0x0100);
} }
#[tauri::command]
pub fn get_platform() -> String {
std::env::consts::OS.to_string()
}

View File

@ -8,7 +8,7 @@ use crate::commands::{
get_ezpp_launcher_update_files, get_hwid, get_launcher_version, get_osu_release_stream, get_ezpp_launcher_update_files, get_hwid, get_launcher_version, get_osu_release_stream,
get_osu_skin, get_osu_version, get_skins_count, is_osu_running, open_url_in_browser, get_osu_skin, get_osu_version, get_skins_count, is_osu_running, open_url_in_browser,
replace_ui_files, run_osu, run_osu_updater, set_osu_config_values, set_osu_user_config_values, replace_ui_files, run_osu, run_osu_updater, set_osu_config_values, set_osu_user_config_values,
valid_osu_folder, valid_osu_folder, get_platform
}; };
#[cfg_attr(mobile, tauri::mobile_entry_point)] #[cfg_attr(mobile, tauri::mobile_entry_point)]
@ -45,7 +45,8 @@ pub fn run() {
is_osu_running, is_osu_running,
open_url_in_browser, open_url_in_browser,
get_launcher_version, get_launcher_version,
exit exit,
get_platform
]) ])
.plugin(tauri_plugin_fs::init()) .plugin(tauri_plugin_fs::init())
.plugin(tauri_plugin_dialog::init()) .plugin(tauri_plugin_dialog::init())

View File

@ -113,3 +113,4 @@ export const isOsuRunning = async () => {
export const getLauncherVersion = async () => await invoke<string>('get_launcher_version'); export const getLauncherVersion = async () => await invoke<string>('get_launcher_version');
export const exit = async () => await invoke('exit'); export const exit = async () => await invoke('exit');
export const getPlatform = async () => await invoke<string>('get_platform');

View File

@ -1,7 +1,9 @@
<script lang="ts"> <script lang="ts">
import Logo from '$assets/logo.png';
import '../app.css'; import '../app.css';
import Titlebar from '@/components/ui/titlebar/titlebar.svelte'; import Titlebar from '@/components/ui/titlebar/titlebar.svelte';
import * as AlertDialog from '@/components/ui/alert-dialog';
import { currentLoadingInfo, firstStartup, launcherVersion, setupValues } from '@/global'; import { currentLoadingInfo, firstStartup, launcherVersion, setupValues } from '@/global';
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import OsuCursor from '@/components/ui/osu-cursor/OsuCursor.svelte'; import OsuCursor from '@/components/ui/osu-cursor/OsuCursor.svelte';
@ -16,13 +18,16 @@
import { Buffer } from 'buffer'; import { Buffer } from 'buffer';
import { Toaster } from '@/components/ui/sonner'; import { Toaster } from '@/components/ui/sonner';
import { userAuth } from '@/userAuthentication'; import { userAuth } from '@/userAuthentication';
import { getLauncherVersion } from '@/osuUtil'; import { exit, getLauncherVersion, getPlatform } from '@/osuUtil';
import '@fontsource/sora'; import '@fontsource/sora';
import '@fontsource/space-mono'; import '@fontsource/space-mono';
import Button from '@/components/ui/button/button.svelte';
let { children } = $props(); let { children } = $props();
let unsupported_platform = $state<boolean>(false);
function disableReload() { function disableReload() {
if (window.location.hostname !== 'tauri.localhost') { if (window.location.hostname !== 'tauri.localhost') {
return; return;
@ -77,6 +82,7 @@
disableReload(); disableReload();
setupValues(); setupValues();
launcherVersion.set(await getLauncherVersion()); launcherVersion.set(await getLauncherVersion());
if ((await getPlatform()) !== 'windows') unsupported_platform = true;
const isFirstStartup = await $userSettings.init(); const isFirstStartup = await $userSettings.init();
$userAuth.init(); $userAuth.init();
@ -110,6 +116,29 @@
<Titlebar /> <Titlebar />
<AlertDialog.Root open={unsupported_platform}>
<AlertDialog.Content class="bg-theme-950 border-theme-800 p-0">
<div
class="flex flex-col items-center justify-center border-b border-theme-800 bg-black/40 rounded-t-lg p-3"
>
<img class="h-20 w-20" src={Logo} alt="logo" />
<span class="font-semibold text-xl">Unsupported Platform!</span>
</div>
<div
class="flex flex-col items-center text-sm text-center bg-theme-900 border border-theme-800 rounded-lg mx-3 p-3"
>
This Platform is not supported by EZPPLauncher.
</div>
<div class="flex items-center justify-center mb-3">
<Button
onclick={async () => {
await exit();
}}>Close</Button
>
</div>
</AlertDialog.Content>
</AlertDialog.Root>
<main> <main>
{@render children()} {@render children()}
</main> </main>