后台静默代理功能上线

This commit is contained in:
DLmaster
2024-12-23 20:30:12 +08:00
parent ad31961c2b
commit 3db3fa4e1f
6 changed files with 815 additions and 495 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -59,8 +59,10 @@ class UpdateProcess(QThread):
self.name = name
self.main_version = main_version
self.updater_version = updater_version
self.download_path = f"{app_path}/AUTO_MAA_Update.zip" # 临时下载文件的路径
self.version_path = f"{app_path}/res/version.json"
self.download_path = os.path.normpath(
f"{app_path}/AUTO_MAA_Update.zip"
) # 临时下载文件的路径
self.version_path = os.path.normpath(f"{app_path}/res/version.json")
def run(self):
@@ -70,34 +72,35 @@ class UpdateProcess(QThread):
except FileNotFoundError:
pass
self.info.emit("正在获取下载链接")
url_list = self.get_download_url()
# 下载
try:
# 验证下载地址并获取文件大小
for i in range(len(url_list)):
try:
response = requests.get(url_list[i], stream=True)
if response.status_code != 200:
self.info.emit(
f"连接失败,错误代码 {response.status_code} ,正在切换代理({i+1}/{len(url_list)}"
)
time.sleep(1)
continue
file_size = response.headers.get("Content-Length")
break
except requests.RequestException:
self.info.emit(f"请求超时,正在切换代理({i+1}/{len(url_list)}")
# 验证下载地址并获取文件大小
for i in range(len(url_list)):
try:
self.info.emit(f"正在验证下载地址:{url_list[i]}")
response = requests.get(url_list[i], stream=True)
if response.status_code != 200:
self.info.emit(
f"连接失败,错误代码 {response.status_code} ,正在切换代理({i+1}/{len(url_list)}"
)
time.sleep(1)
else:
self.info.emit(f"服务器连接失败,已尝试所有{len(url_list)}个代理")
return None
continue
file_size = response.headers.get("Content-Length")
break
except requests.RequestException:
self.info.emit(f"请求超时,正在切换代理({i+1}/{len(url_list)}")
time.sleep(1)
else:
self.info.emit(f"连接失败,已尝试所有{len(url_list)}个代理")
return None
if file_size is None:
file_size = 1
else:
file_size = int(file_size)
if file_size is None:
file_size = 1
else:
file_size = int(file_size)
try:
# 下载文件
with open(self.download_path, "wb") as f:
@@ -180,7 +183,7 @@ class UpdateProcess(QThread):
# 主程序更新完成后打开AUTO_MAA
if self.name == "AUTO_MAA主程序":
subprocess.Popen(
f"{self.app_path}/AUTO_MAA.exe",
os.path.normpath(f"{self.app_path}/AUTO_MAA.exe"),
shell=True,
creationflags=subprocess.CREATE_NO_WINDOW,
)
@@ -188,16 +191,42 @@ class UpdateProcess(QThread):
self.accomplish.emit()
def get_download_url(self):
"""计算下载链接"""
PROXY_list = [
"",
"https://gitproxy.click/",
"https://cdn.moran233.xyz/",
"https://gh.llkk.cc/",
"https://github.akams.cn/",
"https://www.ghproxy.cn/",
"https://ghp.ci/",
]
"""获取下载链接"""
try_num = 3
for i in range(try_num):
try:
response = requests.get(
"https://gitee.com/DLmaster_361/AUTO_MAA/raw/main/res/version.json"
)
if response.status_code != 200:
self.info.emit(
f"连接失败,错误代码 {response.status_code} ,正在重试({i+1}/{try_num}"
)
time.sleep(0.1)
continue
version_remote = response.json()
PROXY_list = version_remote["proxy_list"]
break
except requests.RequestException:
self.info.emit(f"请求超时,正在重试({i+1}/{try_num}")
time.sleep(0.1)
except KeyError:
self.info.emit(f"未找到远端代理网址项,正在重试({i+1}/{try_num}")
time.sleep(0.1)
else:
self.info.emit("获取远端代理信息失败,将使用默认代理地址")
PROXY_list = [
"",
"https://gitproxy.click/",
"https://cdn.moran233.xyz/",
"https://gh.llkk.cc/",
"https://github.akams.cn/",
"https://www.ghproxy.cn/",
"https://ghp.ci/",
]
time.sleep(1)
url_list = []
if self.name == "AUTO_MAA主程序":
url_list.append(
@@ -225,8 +254,10 @@ class Updater(QObject):
self.ui = QDialog()
self.ui.setWindowTitle("AUTO_MAA更新器")
self.ui.resize(500, 70)
self.ui.setWindowIcon(QIcon(f"{app_path}/gui/ico/AUTO_MAA_Updater.ico"))
self.ui.resize(700, 70)
self.ui.setWindowIcon(
QIcon(os.path.normpath(f"{app_path}/gui/ico/AUTO_MAA_Updater.ico"))
)
# 创建垂直布局
self.Layout_v = QVBoxLayout(self.ui)
@@ -264,11 +295,13 @@ class AUTO_MAA_Updater(QApplication):
if __name__ == "__main__":
# 获取软件自身的路径
app_path = os.path.dirname(os.path.realpath(sys.argv[0])).replace("\\", "/")
app_path = os.path.normpath(os.path.dirname(os.path.realpath(sys.argv[0])))
# 从本地版本信息文件获取当前版本信息
if os.path.exists(f"{app_path}/res/version.json"):
with open(f"{app_path}/res/version.json", "r", encoding="utf-8") as f:
if os.path.exists(os.path.normpath(f"{app_path}/res/version.json")):
with open(
os.path.normpath(f"{app_path}/res/version.json"), "r", encoding="utf-8"
) as f:
version_current = json.load(f)
main_version_current = list(
map(int, version_current["main_version"].split("."))
@@ -277,11 +310,21 @@ if __name__ == "__main__":
main_version_current = [0, 0, 0, 0]
# 从远程服务器获取最新版本信息
response = requests.get(
"https://gitee.com/DLmaster_361/AUTO_MAA/raw/main/res/version.json"
)
version_remote = response.json()
main_version_remote = list(map(int, version_remote["main_version"].split(".")))
for _ in range(3):
try:
response = requests.get(
"https://gitee.com/DLmaster_361/AUTO_MAA/raw/main/res/version.json"
)
version_remote = response.json()
main_version_remote = list(
map(int, version_remote["main_version"].split("."))
)
break
except Exception as e:
err = e
time.sleep(0.1)
else:
sys.exit(f"获取版本信息时出错:\n{err}")
# 启动更新线程
if main_version_remote > main_version_current:

View File

@@ -182,7 +182,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>88</width>
<width>98</width>
<height>74</height>
</rect>
</property>
@@ -1048,84 +1048,7 @@
<property name="title">
<string>AUTO_MAA设置</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QFrame" name="frame_routine_3">
<property name="frameShape">
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_19">
<item>
<widget class="QCheckBox" name="checkBox_ifselfstart">
<property name="text">
<string>开机自动启动AUTO_MAA</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_14">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QFrame" name="frame_routine_2">
<property name="frameShape">
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_18">
<item>
<widget class="QCheckBox" name="checkBox_ifsleep">
<property name="text">
<string>AUTO_MAA启动时禁止电脑休眠</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_13">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="3">
<spacer name="horizontalSpacer_7">
<property name="orientation">
@@ -1139,6 +1062,136 @@
</property>
</spacer>
</item>
<item row="2" column="0" colspan="2">
<widget class="QFrame" name="frame_routine_5">
<property name="frameShape">
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_22" stretch="0,1,3">
<item>
<widget class="QCheckBox" name="checkBox_silence">
<property name="text">
<string>后台静默代理</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_16">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_boss">
<property name="placeholderText">
<string>安卓模拟器老板键</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer_11">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>231</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="2" colspan="2">
<widget class="QFrame" name="frame_routine_6">
<property name="frameShape">
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_26" stretch="0,1,3,0">
<item>
<widget class="QCheckBox" name="checkBox_ifsendmail">
<property name="text">
<string>通过邮件通知结果</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_24">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_mailaddress">
<property name="placeholderText">
<string>收信邮箱地址</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_ifonlyerror">
<property name="text">
<string>仅推送异常信息</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="2">
<widget class="QFrame" name="frame_iftotray">
<property name="frameShape">
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_23">
<item>
<widget class="QCheckBox" name="checkBox_iftotray">
<property name="text">
<string>最小化到托盘</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_17">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>149</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QFrame" name="frame_routine_4">
<property name="frameShape">
@@ -1171,37 +1224,37 @@
</layout>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer_11">
<item row="3" column="1">
<spacer name="horizontalSpacer_23">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>231</width>
<width>32</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="2" colspan="2">
<widget class="QFrame" name="frame_routine_5">
<item row="0" column="0">
<widget class="QFrame" name="frame_routine_3">
<property name="frameShape">
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_22" stretch="0,1,3,0">
<layout class="QHBoxLayout" name="horizontalLayout_19">
<item>
<widget class="QCheckBox" name="checkBox_ifsendmail">
<widget class="QCheckBox" name="checkBox_ifselfstart">
<property name="text">
<string>通过邮件通知结果</string>
<string>开机自动启动AUTO_MAA</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_16">
<spacer name="horizontalSpacer_14">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
@@ -1213,43 +1266,33 @@
</property>
</spacer>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_mailaddress"/>
</item>
<item>
<widget class="QCheckBox" name="checkBox_ifonlyerror">
<property name="text">
<string>仅推送异常信息</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QFrame" name="frame_iftotray">
<item row="0" column="2">
<widget class="QFrame" name="frame_routine_2">
<property name="frameShape">
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_23">
<layout class="QHBoxLayout" name="horizontalLayout_18">
<item>
<widget class="QCheckBox" name="checkBox_iftotray">
<widget class="QCheckBox" name="checkBox_ifsleep">
<property name="text">
<string>最小化到托盘</string>
<string>AUTO_MAA启动时禁止电脑休眠</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_17">
<spacer name="horizontalSpacer_13">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>149</width>
<width>40</width>
<height>20</height>
</size>
</property>
@@ -1258,7 +1301,7 @@
</layout>
</widget>
</item>
<item row="2" column="1">
<item row="1" column="3">
<spacer name="horizontalSpacer_12">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
@@ -1271,7 +1314,78 @@
</property>
</spacer>
</item>
<item row="2" column="2">
<item row="0" column="1">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QFrame" name="frame_changePASSWORD">
<property name="frameShape">
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_25">
<item>
<spacer name="horizontalSpacer_21">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_changePASSWORD">
<property name="text">
<string>修改管理密钥</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_22">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="3" column="3">
<spacer name="horizontalSpacer_25">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="2">
<widget class="QFrame" name="frame_check_update">
<property name="frameShape">
<enum>QFrame::Shape::StyledPanel</enum>
@@ -1316,35 +1430,6 @@
</layout>
</widget>
</item>
<item row="2" column="3">
<spacer name="horizontalSpacer_19">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
<string>管理密钥</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QPushButton" name="pushButton_changePASSWORD">
<property name="text">
<string>修改管理密钥</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@@ -1,5 +1,7 @@
plyer
PySide6
pywin32
pyautogui
pycryptodome
pyinstaller
requests

View File

@@ -37,3 +37,6 @@
"Start.RunDirectly": "True" #启动MAA后直接运行
"Start.MinimizeDirectly": "True" #启动MAA后直接最小化
"Start.OpenEmulatorAfterLaunch": "True" #启动MAA后自动开启模拟器
"GUI.UseTray": "True" #显示托盘图标
"GUI.MinimizeToTray": "False" #最小化时隐藏至托盘
"Start.EmulatorPath" #模拟器路径

View File

@@ -1,5 +1,14 @@
{
"main_version": "4.1.3.6",
"updater_version": "1.0.5.1",
"announcement": "\n# 测试版本遇BUG速速上报谢谢~\n## 新增功能\n- 添加托盘中止当前任务选项\n- 添加邮件仅推送异常信息选项\n## 修复BUG\n- 修复深色模式下UI异常 #10\n## 程序优化\n- MainTimer逻辑实现优化\n- 修改配置方法优化\n- 代理逻辑优化\n- 更新器添加更多代理地址,更新流程优化"
"main_version": "4.1.3.7",
"updater_version": "1.0.5.2",
"announcement": "\n# 测试版本遇BUG速速上报谢谢~\n## 新增功能\n- 添加托盘中止当前任务选项\n- 添加邮件仅推送异常信息选项\n- 后台静默代理功能上线\n## 修复BUG\n- 修复深色模式下UI异常 #10\n## 程序优化\n- MainTimer逻辑实现优化\n- 修改配置方法优化\n- 代理逻辑优化\n- 更新器添加更多代理地址,更新流程优化,可获取远端代理地址\n- 路径跨平台适配",
"proxy_list":[
"",
"https://gitproxy.click/",
"https://cdn.moran233.xyz/",
"https://gh.llkk.cc/",
"https://github.akams.cn/",
"https://www.ghproxy.cn/",
"https://ghp.ci/"
]
}