working authirization
This commit is contained in:
@ -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>) => {
|
||||
|
Reference in New Issue
Block a user