feat: implement osu! installation validation

This commit is contained in:
2025-06-30 23:07:45 +02:00
parent c43fd4395d
commit 1834d8dfb3
12 changed files with 476 additions and 44 deletions

View File

@@ -1,6 +1,7 @@
import ky from 'ky';
const BANCHO_ENDPOINT = 'https://c.ez-pp.farm/';
const ENDPOINT = 'https://ez-pp.farm/';
export const ezppfarm = {
ping: async (): Promise<number | undefined> => {
@@ -14,4 +15,44 @@ export const ezppfarm = {
return undefined;
}
},
login: async (
username: string,
password: string
): Promise<
| {
code: number;
message: string;
user?: {
id: number;
donor: boolean;
name: string;
email: string;
};
}
| undefined
> => {
try {
const request = await ky(`${ENDPOINT}login/check`, {
method: 'POST',
body: JSON.stringify({ username, password }),
headers: {
'Content-Type': 'application/json',
'User-Agent': 'EZPPLauncher',
},
});
if (!request.ok) return undefined;
return await request.json<{
code: number;
message: string;
user?: {
id: number;
donor: boolean;
name: string;
email: string;
};
}>();
} catch {
return undefined;
}
},
};

View File

@@ -16,7 +16,7 @@ export class Config {
private crypto: Crypto | undefined;
private configFilePath: string | undefined;
async init() {
async init(): Promise<boolean> {
const hwid: string = (await invoke('get_hwid')) ?? 'recorderinsandybridge';
this.crypto = new Crypto(hwid);
@@ -28,9 +28,11 @@ export class Config {
const createFolder = !(await exists(folderPath));
if (createFolder) await mkdir(folderPath);
const createConfig = !(await exists(this.configFilePath));
if (createConfig) await this.save();
else await this.load();
const configExists = await exists(this.configFilePath);
if (!configExists) return true;
await this.load();
return false;
}
private async load() {

View File

@@ -1,5 +1,9 @@
import { writable } from 'svelte/store';
import { ezppfarm } from './api/ezpp';
import type { Component } from 'svelte';
import Loading from '../pages/Loading.svelte';
export const current_view = writable<Component>(Loading);
export const server_ping = writable<number | undefined>(undefined);
export const server_connection_fails = writable(0);