From deb6121f8d292a02b2686be26c9a0a06065e285b Mon Sep 17 00:00:00 2001 From: LanShui <2031845258@qq.com> Date: Fri, 17 May 2024 13:13:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=B8=B8=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __pycache__/apps.cpython-310.pyc | Bin 7658 -> 7211 bytes __pycache__/module.cpython-310.pyc | Bin 1056 -> 1056 bytes apps.py | 97 +++++++++++++--------------- config_app/login_user.json | 1 + config_app/server_list_config.json | 1 + main.py | 98 +++++++++++++++++++++++++---- 6 files changed, 132 insertions(+), 65 deletions(-) create mode 100644 config_app/login_user.json create mode 100644 config_app/server_list_config.json diff --git a/__pycache__/apps.cpython-310.pyc b/__pycache__/apps.cpython-310.pyc index 04c40045a3c1411fbb68a72b42212ac2554a2060..147230b96cc5537350a9a9498a79dd8fb1a83daf 100644 GIT binary patch delta 3205 zcmaJ@O>7)V74GWp>FN3Z|FOq*Y{%Ys$l4ndvb({%A*}7)!1^bN6D8Y8=$)Nv+vCh% zs@wK%)Pn&Vgpe$fEpbYaZ0#x96XLKJP8`s3M;uy09N>Tuf)fX%AoE_$#2IfKrd40P z_p07cz1P#P{yz2jo2MI*NKk@b{Wmkq2ZNII7i7AB8ZZ}O*nfC$mrg_@4qiz!;NqemXEr3j= zeYAf^HB#?Mbby}Nk?094y{#A-;0Ngt@I!*n0zXVo0)NuV!FnF}5jqO|sMQ0!zn8wU zBo$9R{9DnlZA?y_nK;AaiT$*h&{pXU9kftho!HSf-z-@I;3tTk7Ps;AaVHOmXx7Td6x=~%Yo#XHP$rD~aC z*;lERR;>H}w)siECjTOYnf1u>6N#mGP&u1;1@njrjmsJtIba#SpnRcaLBMi6q)xn% zLQ+5)C@*Z^t5zJ#v{$Wa^)yKAI6#o-1V{T(2^-{BB58gx5cu`3`Wb-(Pips=mhH(44JHn77Uh!wMMY$f4Fhci zJ`xEw>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Z19LjFZ+Fn#0|~b9jKVwB5-Fw34QKAAXPf07 zajf+BkIoFA9UtvKqx2V8zFfe;yXj13Qn@!dlevjg>lb3O{+)BH57Sd~<+-7i)usN{ zFvsl0PK(vcvJa|0v=v8lYqpwud1afvuBP?#LvMbw6gyUnl_h0kV`FF`U!-e8g=$$j zTT#yM;iI%C0;ELSNAreNjs^#r3j_>b;LM3CiFt60pKIm=uw4~xqg1R|o6)3v52g35 zUq!!Px1~zHtbut$hKe5|;CIR<8=GCT=}dYwtDI79%}kE(?=wE3*HR*Durn~tg`0eE zu~^bnbh+n155A_@&~#%D32%z9c~m%y<@}PCY7-lg_U({Prh2V=u}hjAC{p#I_E>H3 zJk|!w7=EQ#2LjSX)`idwV9WYr-O$Rm3mTGFjb&TX%0+|uQ5Pyzmx>j2MF-l4`7!){ z+fu2Tr`G>sBXzn~US%g5GKg=xfX^Dh)odAvu2!L`_6Ea~&^NmahPgH#rcoT`Oc&5` zE(E#q5KT&)iyaZD1)b%jqDmK776ZzQDzp9(U#~}2S+QcMhgfy4{ZNbs&!)wKq36PQ zdByT@HZLu69;Q7~d7pDWeo=XlLo@;zgzaE!mHIM_^q&IAK%K)P9`cu>N0ddEwCC+b zI_+LBoQHvt18f9aQ^qMw}j$}PEJ7MHwY9O(C9eVn*Oq~sv|A}R;L*6%>Q4F2#J z=GIW?z{$JI5%_T(wOSENgt!3M00iJ$Z! z;b#+sL@q( diff --git a/__pycache__/module.cpython-310.pyc b/__pycache__/module.cpython-310.pyc index dd96451fa92264bfdea91a279337c5176bec95f5..de4f081c93f6b4927330e9275aae44bc66454587 100644 GIT binary patch delta 20 acmZ3$v4Dd+pO=@50SKO&xNYPXWdQ&!=maAG delta 20 acmZ3$v4Dd+pO=@50SGu}m~Z43WdQ&w@dKOy diff --git a/apps.py b/apps.py index f7fcaf5..1992d23 100644 --- a/apps.py +++ b/apps.py @@ -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 = { diff --git a/config_app/login_user.json b/config_app/login_user.json new file mode 100644 index 0000000..c0771ff --- /dev/null +++ b/config_app/login_user.json @@ -0,0 +1 @@ +{"accessToken": "cf9e9027138e11ef92c5e252f2c508d4", "clientToken": "ceee8954-138e-11ef-92c5-e252f2c508d4", "id": "a6143eb7a7883daab9a05dbe052879a1", "name": "GameDaBai"} \ No newline at end of file diff --git a/config_app/server_list_config.json b/config_app/server_list_config.json new file mode 100644 index 0000000..bed49d7 --- /dev/null +++ b/config_app/server_list_config.json @@ -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"}] \ No newline at end of file diff --git a/main.py b/main.py index a2cdd59..f7ff247 100644 --- a/main.py +++ b/main.py @@ -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__()