Add account manager and the account page is now fully functional.
Fix "Missing javaVersion" error when launching legacy Minecraft. Add settings page. (But is not fully implemented yet)
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import base64
|
||||
import hashlib
|
||||
import logging
|
||||
import platform
|
||||
@@ -304,4 +306,24 @@ def is_valid_zipfile(path: Path) -> bool:
|
||||
try:
|
||||
return zipfile.is_zipfile(path)
|
||||
except OSError:
|
||||
return False
|
||||
return False
|
||||
|
||||
def bytes_to_data_url(image_data: bytes, mime_type: str = "image/png",) -> str:
|
||||
"""
|
||||
Convert raw image bytes to a Base64 Data URL.
|
||||
:param image_data:
|
||||
:param mime_type:
|
||||
:return:
|
||||
data_url: str
|
||||
"""
|
||||
if not isinstance(image_data, bytes):
|
||||
raise TypeError("image_data must be bytes")
|
||||
|
||||
if not image_data:
|
||||
raise ValueError("image_data cannot be empty")
|
||||
|
||||
if not isinstance(mime_type, str) or not mime_type.startswith("image/"):
|
||||
raise ValueError("mime_type must be a valid image MIME type")
|
||||
|
||||
encoded = base64.b64encode(image_data).decode("ascii")
|
||||
return f"data:{mime_type};base64,{encoded}"
|
||||
@@ -86,4 +86,28 @@ class ProfileLoadException(LauncherException):
|
||||
user_message = "Unable to load profile. Profile may corrupted"
|
||||
|
||||
class ProfileKeyNotFoundException(LauncherException):
|
||||
user_message = "Specified profile key not found. Profile may corrupted."
|
||||
user_message = "Specified profile key not found. Profile may corrupted."
|
||||
|
||||
class AccountException(LauncherException):
|
||||
user_message = "An error occurred while processing account data."
|
||||
|
||||
class AccountSaveException(AccountException):
|
||||
user_message = "Unable to save account data. Try again later."
|
||||
|
||||
class AccountLoadException(AccountException):
|
||||
user_message = "Unable to load account data. The account file may be corrupted."
|
||||
|
||||
class AccountKeyNotFoundException(AccountException):
|
||||
user_message = "Specified account was not found."
|
||||
|
||||
class AuthenticationException(LauncherException):
|
||||
user_message = "Authentication failed."
|
||||
|
||||
class AuthenticationConnectException(LauncherException):
|
||||
user_message = "An error occurred while connecting to authentication server."
|
||||
|
||||
class AuthenticationSessionException(LauncherException):
|
||||
user_message = "Authentication failed. Session may expire."
|
||||
|
||||
class ThirdPartyAPIException(LauncherException):
|
||||
user_message = "An error occurred while fetching third party API."
|
||||
Reference in New Issue
Block a user