working authirization

This commit is contained in:
2025-07-07 00:21:13 +05:00
parent b65b9538bb
commit 6f92b2acad
8 changed files with 997 additions and 703 deletions

View File

@ -1,7 +1,18 @@
import { useState, useEffect } from 'react';
// Добавляем определение типа Config
interface Config {
username: string;
password: string;
memory: number;
comfortVersion: string;
accessToken: string;
clientToken: string;
uuid?: string; // Добавляем uuid, который используется для авторизации
}
const useConfig = () => {
const [config, setConfig] = useState({
const [config, setConfig] = useState<Config>({
username: '',
password: '',
memory: 4096,
@ -34,28 +45,10 @@ const useConfig = () => {
setConfig(savedConfig);
}, []);
const saveConfig = (
username: string,
memory: number,
accessToken = '',
clientToken = '',
comfortVersion = '',
password = '',
) => {
try {
const newConfig = {
username,
memory,
accessToken: accessToken || config.accessToken,
clientToken: clientToken || config.clientToken,
comfortVersion: comfortVersion || config.comfortVersion,
password: password || config.password,
};
setConfig(newConfig);
localStorage.setItem('launcher_config', JSON.stringify(newConfig));
} catch (error) {
console.log(`Ошибка при сохранении конфигурации: ${error.message}`);
}
const saveConfig = (newConfig: Partial<Config>) => {
const updatedConfig = { ...config, ...newConfig };
setConfig(updatedConfig);
localStorage.setItem('launcher_config', JSON.stringify(updatedConfig));
};
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {