日常更新

This commit is contained in:
LanShui 2024-05-17 13:13:58 +08:00
parent 47a1765585
commit deb6121f8d
6 changed files with 132 additions and 65 deletions

Binary file not shown.

Binary file not shown.

97
apps.py
View File

@ -2,6 +2,7 @@ from PySide2.QtCore import QObject
from module import *
window_title_apps_name = "CRA-SERVER CLIENT"
client_version = "v1.0.0"
login_headers = {"Content-Type": "application/json"}
login_user_key = "f0649fc2aeb411eda71f00163e095b49"
@ -11,7 +12,7 @@ cra_mc_server_api = ""
reload_password_page = "https://login.mc-user.com:233/account/login"
register_web_page = "https://login.mc-user.com:233/f0649fc2aeb411eda71f00163e095b49/register"
server_list_configfile = "config_app/server_list_config.db"
server_list_configfile = "config_app/server_list_config.json"
login_json_file = "config_app/login_user.json"
@ -19,7 +20,20 @@ window_size_int = (950, 560)
style_qss_stylesheet_body_file_dir = "style/style.qss"
id_key_sqlite = "INTEGER PRIMARY KEY AUTOINCREMENT"
data_server_list_dict_jsonfile = [
{
"name": "CRA-MC",
"server_test": "HELLO WORLD",
"server_file_name": "cra_mc",
"image": "https://s21.ax1x.com/2024/05/05/pkE9wUe.jpg"
},
{
"name": "CRA-MC1",
"server_test": "HELLO WORLD",
"server_file_name": "cra_mc",
"image": "https://s21.ax1x.com/2024/05/05/pkE9wUe.jpg"
}
]
@staticmethod
def readQSS(style: str):
@ -106,46 +120,18 @@ class Thread_appcode_login_user(QThread):
code = int(0)
if os.path.isfile(server_list_configfile) is False:
data_serverlistdbfile = [
f'''
CREATE TABLE SERVER_LIST (
ID {id_key_sqlite},
NAME TEXT,
SERVER_FILE_NAME TEXT,
SERVER_TEST TEXT,
IMAGE TEXT
);
''',
'''
CREATE TABLE SERVER_PLAY (
NAME TEXT,
VERSION TEXT
);
''',
'''
INSERT INTO SERVER_LIST (
NAME, SERVER_FILE_NAME, SERVER_TEST, IMAGE
) VALUES (
"CRA-MC", "cramc", "HELLO WORLD", "https://s21.ax1x.com/2024/05/06/pkEPVmV.jpg"
);
''',
'''
INSERT INTO SERVER_PLAY (
VERSION
) VALUES (
"v1.0"
);
'''
]
sql_file_config = sqlite3.connect(server_list_configfile)
sql_file_config_csr = sql_file_config.cursor()
for i_db in data_serverlistdbfile:
sql_file_config_csr.execute(i_db)
sql_file_config_csr.close()
sql_file_config.commit()
sql_file_config.close()
with open(file=server_list_configfile, mode='w', encoding="UTF-8", newline='') as f_write_server_list:
json.dump(data_server_list_dict_jsonfile, f_write_server_list)
if os.path.isfile(server_list_configfile) is True:
with open(file=server_list_configfile, mode='r', encoding="UTF-8", newline='') as f_read_all:
json_server_list_all = json.load(f_read_all)
if all(json_server_list_all) is False:
data_server_list_dict_jsonfile_all = data_server_list_dict_jsonfile
with open(file=server_list_configfile, mode='w', encoding="UTF-8", newline='') as f_write_all:
json.dump(data_server_list_dict_jsonfile_all, f_write_all)
if os.system("ping www.baidu.com -n 1") == 1:
ping_server = os.system("ping www.baidu.com -n 3")
if ping_server == 1:
data = dict()
code = int(2)
data_config = {
@ -183,21 +169,26 @@ class Thread_appcode_login_user(QThread):
with open(file=login_json_file, mode='w', encoding="UTF-8", newline='') as dump_f:
json.dump(data_login_file, dump_f)
print_server_list = sqlite_shell(sql_db=server_list_configfile, sql_code="SELECT * FROM SERVER_LIST;")
data_server_list_dicts = list()
for dict_server_list in print_server_list:
data_server_list_dict = dict()
data_server_list_dict["name"] = dict_server_list[1]
data_server_list_dict["server_file_name"] = dict_server_list[2]
data_server_list_dict["server_test"] = dict_server_list[3]
req_image = requests.get(url=dict_server_list[4])
image_print = req_image.content
data_server_list_dict["image"] = image_print
data_server_list_dicts.append(data_server_list_dict)
with open(file=server_list_configfile, mode='r', encoding="UTF-8", newline='') as read_server_list_f:
server_list_json_dict = json.load(read_server_list_f)
server_list_json_ = server_list_json_dict
server_list0 = list()
for i_server in server_list_json_:
server_list1 = [
i_server.get("name"), i_server.get("server_file_name"), i_server.get("server_ip")
]
server_list0.append(server_list1)
for i_image_content_for in server_list_json_:
req_image = requests.get(url=i_image_content_for.get("image")).content
i_image_content_for.update({"image": req_image})
data = {
"name": login_json_user.get("name"),
"server_list": data_server_list_dicts
"server_list": server_list_json_,
"server_id_list": server_list0
}
data_config = {

View File

@ -0,0 +1 @@
{"accessToken": "cf9e9027138e11ef92c5e252f2c508d4", "clientToken": "ceee8954-138e-11ef-92c5-e252f2c508d4", "id": "a6143eb7a7883daab9a05dbe052879a1", "name": "GameDaBai"}

View File

@ -0,0 +1 @@
[{"name": "CRA-MC", "server_test": "HELLO WORLD", "server_file_name": "cra_mc", "image": "https://s21.ax1x.com/2024/05/05/pkE9wUe.jpg"}, {"name": "CRA-MC1", "server_test": "HELLO WORLD", "server_file_name": "cra_mc", "image": "https://s21.ax1x.com/2024/05/05/pkE9wUe.jpg"}]

98
main.py
View File

@ -33,6 +33,7 @@ class Login_Window_app(QWidget):
self.start_cramc_server_client_myapp = My_APP_Window(data=data_config.get("data_config"), code=data_config.get("code"))
self.start_cramc_server_client_myapp.show()
return None
os.remove(apps.login_json_file)
apps.Message_ok(message="CRA-USER已过期请重新登录")
self.login_user_window = Login_users_window_app()
self.login_user_window.show()
@ -67,9 +68,11 @@ class Login_users_window_app(QWidget):
login_user_box.setSpacing(15)
login_user_box.addWidget(QLabel(text="用户名:"), 0, 0, alignment=Qt.AlignTop)
self.username = QLineEdit()
self.username.setPlaceholderText("请输入CRA-USER用户名")
login_user_box.addWidget(self.username, 0, 1, alignment=Qt.AlignTop)
login_user_box.addWidget(QLabel(text="密码:"), 1, 0, alignment=Qt.AlignTop)
self.password = QLineEdit()
self.password.setPlaceholderText("请输入CRA-USER密码")
self.password.setEchoMode(QLineEdit.Password)
login_user_box.addWidget(self.password, 1, 1, alignment=Qt.AlignTop)
login_user_button = QPushButton(text="登录")
@ -138,7 +141,8 @@ class My_APP_Window(QTabWidget):
super().__init__()
self.data = data
self.code = code
self.server_list_dict = self.data.get("server_list")
self.server_list_dict: dict = self.data.get("server_list")
self.server_id_dict_list: dict = self.data.get("server_id_list")
self.setWindowFlags(Qt.FramelessWindowHint)
self.setFixedSize(apps.window_size_int[0], apps.window_size_int[1])
self.setWindowTitle(apps.window_title_apps_name)
@ -172,7 +176,7 @@ class My_APP_Window(QTabWidget):
self.index_home = QWidget()
self.craserver_client_settings = Craserver_client_settings()
self.craserver_client_game_settings = QWidget()
self.craserver_client_game_settings = App_settings_tab()
self.craserver_client_user_settings = QWidget()
self.header_tab = QTabWidget()
@ -187,28 +191,74 @@ class My_APP_Window(QTabWidget):
self.setLayout(gui_box_grid)
self.index_home_page()
self.craserver_client_game_settings_page()
self.craserver_client_user_settings_page()
def craserver_client_user_settings_page(self):
pass
self.gamer_name_user = self.data.get("name")
v_box = QVBoxLayout()
v_box.setSpacing(25)
def craserver_client_game_settings_page(self):
pass
login_user_panel_button = QPushButton(text="控制台")
login_user_panel_button.setFixedSize(250, 35)
login_user_panel_button.clicked.connect(lambda: os.startfile("https://login.mc-user.com:233/account/index"))
exit_user_login_button = QPushButton(text="退出登录")
exit_user_login_button.setFixedSize(250, 35)
exit_user_login_button.clicked.connect(self.exit_user_apps)
v_box.addWidget(QLabel(text=self.gamer_name_user), alignment=Qt.AlignCenter | Qt.AlignCenter)
user_button_hbox = QHBoxLayout()
user_button_hbox.setContentsMargins(200, 0, 200, 300)
user_button_hbox.addWidget(login_user_panel_button, alignment=Qt.AlignTop | Qt.AlignCenter)
user_button_hbox.addWidget(exit_user_login_button, alignment=Qt.AlignTop | Qt.AlignCenter)
v_box.addLayout(user_button_hbox)
join_qq_group = QPushButton(text="加入QQ群")
join_kook = QPushButton(text="加入KOOK")
self.craserver_client_user_settings.setLayout(v_box)
def exit_user_apps(self):
message = apps.Message_yes_no(message="确定要退出登录吗?")
if message.value() is True:
with open(file=apps.login_json_file, mode='r', encoding="UTF-8", newline='') as f:
data_json = json.load(f)
data_exit_user = {
"accessToken": data_json.get("accessToken"),
"clientToken": data_json.get("clientToken")
}
requests.post(url=apps.aotu_user_url + "authserver/invalidate", headers=apps.login_headers, json=data_exit_user)
os.remove(apps.login_json_file)
self.destroy()
self.login_window_user_app = Login_users_window_app()
self.login_window_user_app.show()
return None
def index_home_page(self):
index_home_grid_box = QGridLayout()
search_box = QHBoxLayout()
self.search_lineedit = QLineEdit()
self.search_lineedit.setPlaceholderText("输入服务器名称或ID搜索")
search_button = QPushButton(text="搜索")
search_button.setFixedWidth(120)
reload_server_list_button = QPushButton(text="显示全部")
reload_server_list_button.setFixedWidth(120)
search_box.addWidget(self.search_lineedit)
search_box.addWidget(search_button)
search_box.addWidget(reload_server_list_button)
index_home_grid_box.addLayout(search_box, 0, 0, alignment=Qt.AlignTop | Qt.AlignTop)
self.server_list = QListWidget()
self.start_game_button = QPushButton(text="启动CRA-SERVER")
self.start_game_button = QPushButton(text="启动游戏")
self.start_game_button.clicked.connect(self.start_games_apps)
self.start_game_button.setFixedSize(200, 55)
index_home_grid_box.addWidget(self.server_list, 0, 0)
index_home_grid_box.addWidget(self.start_game_button, 1, 0, alignment=Qt.AlignRight | Qt.AlignBottom)
index_home_grid_box.addWidget(self.server_list, 1, 0)
index_home_grid_box.addWidget(self.start_game_button, 2, 0, alignment=Qt.AlignRight | Qt.AlignBottom)
for i_server_list in self.server_list_dict:
item = apps.customQListWidgetItem(image=i_server_list.get("image"), names=i_server_list.get("name"), tests=i_server_list.get("server_test"))
for i_server_list_for in self.server_list_dict:
item = apps.customQListWidgetItem(image=i_server_list_for.get("image"), names=i_server_list_for.get("name"), tests=i_server_list_for.get("server_test"))
self.server_list.addItem(item)
self.server_list.setItemWidget(item, item.item_widget)
@ -217,7 +267,13 @@ class My_APP_Window(QTabWidget):
def start_games_apps(self):
if self.server_list.currentRow() == -1:
return apps.Message_ok(message="请先选择需要加入的服务器")
start_game_name = self.server_id_dict_list[self.server_list.currentRow()]
self.start_window_game = QWidget()
self.start_window_game.setWindowModality(Qt.ApplicationModal)
self.start_window_game.setWindowFlags(Qt.FramelessWindowHint)
self.start_window_game.setWindowTitle(apps.window_title_apps_name)
self.start_window_game.setFixedSize(400, 230)
self.start_window_game.show()
return None
def zxh_apps(self):
@ -244,6 +300,24 @@ class My_APP_Window(QTabWidget):
self.destroy()
return sys.exit(0)
class App_settings_tab(QTabWidget):
def __init__(self):
super().__init__()
self.game_settings = QWidget()
self.app_settings = QWidget()
self.addTab(self.game_settings, "游戏")
self.addTab(self.app_settings, "客户端")
self.game_settings_page()
self.app_settings_page()
def game_settings_page(self):
pass
def app_settings_page(self):
pass
class Craserver_client_settings(QTabWidget):
def __init__(self):
super().__init__()