日常更新

This commit is contained in:
LanShui 2024-05-21 23:33:06 +08:00
parent 4735cf0081
commit e7d1b45de1
7 changed files with 95 additions and 56 deletions

Binary file not shown.

Binary file not shown.

140
apps.py
View File

@ -16,6 +16,7 @@ reload_password_page = "https://login.mc-user.com:233/account/login"
register_web_page = "https://login.mc-user.com:233/f0649fc2aeb411eda71f00163e095b49/register"
login_json_file = "config_app/login_user.json"
favorite_file_sqlite = "config_app/favorite.db"
window_size_int = (950, 560)
@ -102,75 +103,106 @@ class Thread_appcode_login_user(QThread):
super(Thread_appcode_login_user, self).__init__()
def run(self):
data = dict()
code = int(0)
ping_server = os.system("ping www.baidu.com -n 3")
if ping_server == 1:
try:
data = dict()
code = int(2)
data_config = {
"data_config": data,
"code": code
}
return self.data_th.emit(data_config)
code = int(0)
with open(file=login_json_file, mode='r', encoding="UTF-8", newline='') as f_read:
login_json_user = json.load(f_read)
login_user = {
"accessToken": login_json_user.get("accessToken"),
"clientToken": login_json_user.get("clientToken")
}
json_login_crauser = requests.post(url=aotu_user_url + "authserver/validate", headers=login_headers, json=login_user)
if json_login_crauser.status_code != 204:
ref_login_key = requests.post(url=aotu_user_url + "authserver/refresh", headers=login_headers, json=login_user)
if ref_login_key.status_code != 204:
ping_server = os.system("ping www.baidu.com -n 3")
if ping_server == 1:
data = dict()
code = int(1)
code = int(2)
data_config = {
"data_config": data,
"code": code
}
return self.data_th.emit(data_config)
url_https_mc_login_json = requests.post(url=aotu_user_url + "authserver/refresh", headers=login_headers, json=login_user)
data_login_file = {
"accessToken": url_https_mc_login_json.get("accessToken"),
"clientToken": url_https_mc_login_json.get("clientToken"),
"id": url_https_mc_login_json["selectedProfile"]["id"],
"name": url_https_mc_login_json["selectedProfile"]["name"]
if os.path.isfile(favorite_file_sqlite) is False:
sqlite_list_code = [
'''
CREATE TABLE Favorite_table (
ID INTEGER PRIMARY KEY AUTOINCREMENT,
SERVERNAME TEXT,
SERVER_TEST TEXT,
IMAGE TEXT,
SERVER_FILE_NAME TEXT
);
'''
]
sql = sqlite3.connect(favorite_file_sqlite)
csr = sql.cursor()
for sqlite_play_i in sqlite_list_code:
csr.execute(sqlite_play_i)
csr.close()
sql.commit()
sql.close()
with open(file=login_json_file, mode='r', encoding="UTF-8", newline='') as f_read:
login_json_user = json.load(f_read)
login_user = {
"accessToken": login_json_user.get("accessToken"),
"clientToken": login_json_user.get("clientToken")
}
with open(file=login_json_file, mode='w', encoding="UTF-8", newline='') as dump_f:
json.dump(data_login_file, dump_f)
json_login_crauser = requests.post(url=aotu_user_url + "authserver/validate", headers=login_headers, json=login_user)
req_server_list_api = requests.get(url=cra_mc_server_api + server_ip_list_dict, headers=login_headers)
server_list_json_dict: dict = [req_server_list_api.json()[cra_mc_api_id]]
if json_login_crauser.status_code != 204:
ref_login_key = requests.post(url=aotu_user_url + "authserver/refresh", headers=login_headers, json=login_user)
if ref_login_key.status_code != 204:
data = dict()
code = int(1)
data_config = {
"data_config": data,
"code": code
}
return self.data_th.emit(data_config)
url_https_mc_login_json = requests.post(url=aotu_user_url + "authserver/refresh", headers=login_headers, json=login_user)
data_login_file = {
"accessToken": url_https_mc_login_json.get("accessToken"),
"clientToken": url_https_mc_login_json.get("clientToken"),
"id": url_https_mc_login_json["selectedProfile"]["id"],
"name": url_https_mc_login_json["selectedProfile"]["name"]
}
with open(file=login_json_file, mode='w', encoding="UTF-8", newline='') as dump_f:
json.dump(data_login_file, dump_f)
server_list_json_ = server_list_json_dict
req_server_list_api = requests.get(url=cra_mc_server_api + server_ip_list_dict, headers=login_headers)
server_list_json_dict: dict = [req_server_list_api.json()[cra_mc_api_id]]
server_list0 = list()
for i_server in server_list_json_:
server_list1 = [
i_server.get("servername")
]
server_list0.append(server_list1)
server_list_json_ = server_list_json_dict
for i_image_content_for in server_list_json_:
req_image = requests.get(url=i_image_content_for.get("logourl")).content
i_image_content_for.update({"image": req_image})
server_list0 = list()
for i_server in server_list_json_:
server_list1 = [
i_server.get("servername")
]
server_list0.append(server_list1)
data = {
"name": login_json_user.get("name"),
"server_list": server_list_json_,
"server_id_list": server_list0
}
for i_image_content_for in server_list_json_:
req_image = requests.get(url=i_image_content_for.get("logourl")).content
i_image_content_for.update({"image": req_image})
data_config = {
"data_config": data,
"code": code
}
return self.data_th.emit(data_config)
data = {
"name": login_json_user.get("name"),
"server_list": server_list_json_,
"server_id_list": server_list0
}
data_config = {
"data_config": data,
"code": code
}
return self.data_th.emit(data_config)
except Exception as error:
data = {
"error": str(error)
}
code = int(9)
data_configs = {
"data_config": data,
"code": code
}
return self.data_th.emit(data_configs)
class customQListWidgetItem(QListWidgetItem):
def __init__(self, image, names: str, tests: str):

BIN
config_app/favorite.db Normal file

Binary file not shown.

View File

@ -1 +1 @@
{"accessToken": "eb00b22d167411ef92c5e252f2c508d4", "clientToken": "ea55c2cc-1674-11ef-92c5-e252f2c508d4", "id": "a6143eb7a7883daab9a05dbe052879a1", "name": "GameDaBai"}
{"accessToken": "7e56f116178611ef92c5e252f2c508d4", "clientToken": "7da4f2dd-1786-11ef-92c5-e252f2c508d4", "id": "a6143eb7a7883daab9a05dbe052879a1", "name": "GameDaBai"}

View File

@ -26,6 +26,12 @@ class Login_Window_app(QWidget):
def run_th_app(self, data_config: dict):
self.destroy()
if data_config.get("code") == 9:
error_str = data_config.get("data_config")
message_error = apps.Message_yes_no(message="在启动客户端时发生严重错误,请复制以下错误信息发送给开发者或管理员,单击确定即可复制\n\n" + error_str.get("error"))
if message_error.value() is True:
pyperclip.copy(error_str.get("error"))
return sys.exit(0)
if data_config.get("code") == 2:
apps.Message_ok(message="网络出问题了,请检查完网络连接再来哦主人")
return sys.exit(0)
@ -254,7 +260,6 @@ class My_APP_Window(QTabWidget):
self.server_ip_list = QListWidget()
self.server_ip_list.setFixedSize(500, 55)
self.server_ip_list.setFlow(QListView.LeftToRight)
self.server_ip_list.addItems(["name1", "name2", "name33"])
index_home_grid_box.addWidget(self.server_ip_list, 2, 0, alignment=Qt.AlignLeft | Qt.AlignBottom)
self.start_game_button = QPushButton(text="启动游戏")

View File

@ -12,6 +12,8 @@ import requests
import json
import datetime
import sqlite3
import pyperclip
import traceback
from time import sleep
import zipfile
from shutil import rmtree