feat(core): 优化 Cloudflare IP 加速功能
- 在消息框中添加 Cloudflare 图标 - 更新应用版本号至 1.1.3 - 优化配置获取流程,增加错误处理 - 移除未使用的资源文件 - 调整资源路径获取逻辑
BIN
source/IMG/ICO/cloudflare_logo_icon.ico
Normal file
|
After Width: | Height: | Size: 66 KiB |
@@ -6,8 +6,9 @@ from urllib.parse import urlparse
|
|||||||
|
|
||||||
from PySide6 import QtWidgets
|
from PySide6 import QtWidgets
|
||||||
from PySide6.QtCore import Qt
|
from PySide6.QtCore import Qt
|
||||||
|
from PySide6.QtGui import QIcon, QPixmap
|
||||||
|
|
||||||
from utils import msgbox_frame, HostsManager
|
from utils import msgbox_frame, HostsManager, resource_path
|
||||||
from data.config import APP_NAME, PLUGIN, GAME_INFO, UA, CONFIG_URL
|
from data.config import APP_NAME, PLUGIN, GAME_INFO, UA, CONFIG_URL
|
||||||
from workers import IpOptimizerThread
|
from workers import IpOptimizerThread
|
||||||
|
|
||||||
@@ -185,6 +186,16 @@ class DownloadManager:
|
|||||||
msg_box = QtWidgets.QMessageBox(self.main_window)
|
msg_box = QtWidgets.QMessageBox(self.main_window)
|
||||||
msg_box.setWindowTitle(f"下载优化 - {APP_NAME}")
|
msg_box.setWindowTitle(f"下载优化 - {APP_NAME}")
|
||||||
msg_box.setText("是否愿意通过Cloudflare加速来优化下载速度?\n\n这将临时修改系统的hosts文件,并需要管理员权限。")
|
msg_box.setText("是否愿意通过Cloudflare加速来优化下载速度?\n\n这将临时修改系统的hosts文件,并需要管理员权限。")
|
||||||
|
|
||||||
|
# 设置Cloudflare图标
|
||||||
|
cf_icon_path = resource_path("IMG/ICO/cloudflare_logo_icon.ico")
|
||||||
|
if os.path.exists(cf_icon_path):
|
||||||
|
cf_pixmap = QPixmap(cf_icon_path)
|
||||||
|
if not cf_pixmap.isNull():
|
||||||
|
msg_box.setWindowIcon(QIcon(cf_pixmap))
|
||||||
|
msg_box.setIconPixmap(cf_pixmap.scaled(64, 64, Qt.AspectRatioMode.KeepAspectRatio,
|
||||||
|
Qt.TransformationMode.SmoothTransformation))
|
||||||
|
else:
|
||||||
msg_box.setIcon(QtWidgets.QMessageBox.Icon.Question)
|
msg_box.setIcon(QtWidgets.QMessageBox.Icon.Question)
|
||||||
|
|
||||||
yes_button = msg_box.addButton("是,开启加速", QtWidgets.QMessageBox.ButtonRole.YesRole)
|
yes_button = msg_box.addButton("是,开启加速", QtWidgets.QMessageBox.ButtonRole.YesRole)
|
||||||
@@ -240,10 +251,21 @@ class DownloadManager:
|
|||||||
# 禁用退出按钮
|
# 禁用退出按钮
|
||||||
self.main_window.ui.exit_btn.setEnabled(False)
|
self.main_window.ui.exit_btn.setEnabled(False)
|
||||||
|
|
||||||
|
# 使用Cloudflare图标创建消息框
|
||||||
|
|
||||||
self.optimizing_msg_box = msgbox_frame(
|
self.optimizing_msg_box = msgbox_frame(
|
||||||
f"通知 - {APP_NAME}",
|
f"通知 - {APP_NAME}",
|
||||||
"\n正在优选Cloudflare IP,请稍候...\n\n这可能需要5-10分钟,请耐心等待喵~"
|
"\n正在优选Cloudflare IP,请稍候...\n\n这可能需要5-10分钟,请耐心等待喵~"
|
||||||
)
|
)
|
||||||
|
# 设置Cloudflare图标
|
||||||
|
cf_icon_path = resource_path("IMG/ICO/cloudflare_logo_icon.ico")
|
||||||
|
if os.path.exists(cf_icon_path):
|
||||||
|
cf_pixmap = QPixmap(cf_icon_path)
|
||||||
|
if not cf_pixmap.isNull():
|
||||||
|
self.optimizing_msg_box.setWindowIcon(QIcon(cf_pixmap))
|
||||||
|
self.optimizing_msg_box.setIconPixmap(cf_pixmap.scaled(64, 64, Qt.AspectRatioMode.KeepAspectRatio,
|
||||||
|
Qt.TransformationMode.SmoothTransformation))
|
||||||
|
|
||||||
# 我们不再提供"跳过"按钮
|
# 我们不再提供"跳过"按钮
|
||||||
self.optimizing_msg_box.setStandardButtons(QtWidgets.QMessageBox.StandardButton.NoButton)
|
self.optimizing_msg_box.setStandardButtons(QtWidgets.QMessageBox.StandardButton.NoButton)
|
||||||
self.optimizing_msg_box.setWindowModality(Qt.WindowModality.ApplicationModal)
|
self.optimizing_msg_box.setWindowModality(Qt.WindowModality.ApplicationModal)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import base64
|
|||||||
|
|
||||||
# 配置信息
|
# 配置信息
|
||||||
app_data = {
|
app_data = {
|
||||||
"APP_VERSION": "1.1.2.1",
|
"APP_VERSION": "1.1.3",
|
||||||
"APP_NAME": "FRAISEMOE Addons Installer NEXT",
|
"APP_NAME": "FRAISEMOE Addons Installer NEXT",
|
||||||
"TEMP": "TEMP",
|
"TEMP": "TEMP",
|
||||||
"CACHE": "FRAISEMOE",
|
"CACHE": "FRAISEMOE",
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import shutil
|
import shutil
|
||||||
import json
|
import json
|
||||||
|
import webbrowser
|
||||||
|
|
||||||
from PySide6 import QtWidgets
|
from PySide6 import QtWidgets
|
||||||
from PySide6.QtCore import QTimer
|
from PySide6.QtCore import QTimer
|
||||||
@@ -36,6 +37,7 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
# 初始化状态变量
|
# 初始化状态变量
|
||||||
self.cloud_config = None
|
self.cloud_config = None
|
||||||
|
self.config_valid = False # 添加配置有效标志
|
||||||
self.installed_status = {f"NEKOPARA Vol.{i}": False for i in range(1, 5)}
|
self.installed_status = {f"NEKOPARA Vol.{i}": False for i in range(1, 5)}
|
||||||
self.installed_status["NEKOPARA After"] = False # 添加After的状态
|
self.installed_status["NEKOPARA After"] = False # 添加After的状态
|
||||||
self.hash_msg_box = None
|
self.hash_msg_box = None
|
||||||
@@ -111,8 +113,11 @@ class MainWindow(QMainWindow):
|
|||||||
"""动画完成后启用按钮"""
|
"""动画完成后启用按钮"""
|
||||||
self.animation_in_progress = False
|
self.animation_in_progress = False
|
||||||
|
|
||||||
# 启用开始安装按钮
|
# 只有在配置有效时才启用开始安装按钮
|
||||||
|
if self.config_valid:
|
||||||
self.ui.start_install_btn.setEnabled(True)
|
self.ui.start_install_btn.setEnabled(True)
|
||||||
|
else:
|
||||||
|
self.ui.start_install_btn.setEnabled(False)
|
||||||
|
|
||||||
def fetch_cloud_config(self):
|
def fetch_cloud_config(self):
|
||||||
"""获取云端配置"""
|
"""获取云端配置"""
|
||||||
@@ -130,6 +135,9 @@ class MainWindow(QMainWindow):
|
|||||||
error_message: 错误信息,如果有
|
error_message: 错误信息,如果有
|
||||||
"""
|
"""
|
||||||
if error_message:
|
if error_message:
|
||||||
|
# 标记配置无效
|
||||||
|
self.config_valid = False
|
||||||
|
|
||||||
if error_message == "update_required":
|
if error_message == "update_required":
|
||||||
msg_box = msgbox_frame(
|
msg_box = msgbox_frame(
|
||||||
f"更新提示 - {APP_NAME}",
|
f"更新提示 - {APP_NAME}",
|
||||||
@@ -137,8 +145,11 @@ class MainWindow(QMainWindow):
|
|||||||
QMessageBox.StandardButton.Ok,
|
QMessageBox.StandardButton.Ok,
|
||||||
)
|
)
|
||||||
msg_box.exec()
|
msg_box.exec()
|
||||||
self.ui_manager.open_project_home_page()
|
# 在浏览器中打开项目主页
|
||||||
|
webbrowser.open("https://github.com/hyb-oyqq/FRAISEMOE-Addons-Installer-NEXT/")
|
||||||
|
# 强制关闭程序
|
||||||
self.shutdown_app(force_exit=True)
|
self.shutdown_app(force_exit=True)
|
||||||
|
return
|
||||||
elif "missing_keys" in error_message:
|
elif "missing_keys" in error_message:
|
||||||
missing_versions = error_message.split(":")[1]
|
missing_versions = error_message.split(":")[1]
|
||||||
msg_box = msgbox_frame(
|
msg_box = msgbox_frame(
|
||||||
@@ -147,17 +158,38 @@ class MainWindow(QMainWindow):
|
|||||||
QMessageBox.StandardButton.Ok,
|
QMessageBox.StandardButton.Ok,
|
||||||
)
|
)
|
||||||
msg_box.exec()
|
msg_box.exec()
|
||||||
|
# 对于部分缺失,仍然允许使用,因为可能只影响部分游戏版本
|
||||||
|
self.config_valid = True
|
||||||
else:
|
else:
|
||||||
# 其他错误暂时只在debug模式下打印
|
# 显示通用错误消息,只在debug模式下显示详细错误
|
||||||
debug_mode = self.ui_manager.debug_action.isChecked() if self.ui_manager.debug_action else False
|
debug_mode = self.ui_manager.debug_action.isChecked() if self.ui_manager.debug_action else False
|
||||||
if debug_mode:
|
error_msg = "访问云端配置失败,请检查网络状况或稍后再试。"
|
||||||
print(f"获取云端配置失败: {error_message}")
|
if debug_mode and "详细错误:" in error_message:
|
||||||
|
msg_box = msgbox_frame(
|
||||||
|
f"错误 - {APP_NAME}",
|
||||||
|
f"\n{error_message}\n",
|
||||||
|
QMessageBox.StandardButton.Ok,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
msg_box = msgbox_frame(
|
||||||
|
f"错误 - {APP_NAME}",
|
||||||
|
f"\n{error_msg}\n",
|
||||||
|
QMessageBox.StandardButton.Ok,
|
||||||
|
)
|
||||||
|
msg_box.exec()
|
||||||
|
# 在无法连接到云端时禁用开始安装按钮
|
||||||
|
self.ui.start_install_btn.setEnabled(False)
|
||||||
else:
|
else:
|
||||||
self.cloud_config = data
|
self.cloud_config = data
|
||||||
|
# 标记配置有效
|
||||||
|
self.config_valid = True
|
||||||
|
|
||||||
debug_mode = self.ui_manager.debug_action.isChecked() if self.ui_manager.debug_action else False
|
debug_mode = self.ui_manager.debug_action.isChecked() if self.ui_manager.debug_action else False
|
||||||
if debug_mode:
|
if debug_mode:
|
||||||
print("--- Cloud config fetched successfully ---")
|
print("--- Cloud config fetched successfully ---")
|
||||||
print(json.dumps(data, indent=2))
|
print(json.dumps(data, indent=2))
|
||||||
|
# 确保按钮在成功获取配置时启用
|
||||||
|
self.ui.start_install_btn.setEnabled(True)
|
||||||
|
|
||||||
def toggle_debug_mode(self, checked):
|
def toggle_debug_mode(self, checked):
|
||||||
"""切换调试模式
|
"""切换调试模式
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 162 KiB |
|
Before Width: | Height: | Size: 179 KiB |
|
Before Width: | Height: | Size: 571 KiB |
|
Before Width: | Height: | Size: 250 KiB |
|
Before Width: | Height: | Size: 1.3 MiB |
|
Before Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 229 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 177 KiB |
|
Before Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 327 KiB |
|
Before Width: | Height: | Size: 166 KiB |
|
Before Width: | Height: | Size: 184 KiB |
|
Before Width: | Height: | Size: 197 KiB |
|
Before Width: | Height: | Size: 166 KiB |
@@ -28,7 +28,7 @@ def resource_path(relative_path):
|
|||||||
if relative_path in ("aria2c.exe", "cfst.exe"):
|
if relative_path in ("aria2c.exe", "cfst.exe"):
|
||||||
return os.path.join(base_path, 'bin', relative_path)
|
return os.path.join(base_path, 'bin', relative_path)
|
||||||
elif relative_path in ("ip.txt", "ipv6.txt"):
|
elif relative_path in ("ip.txt", "ipv6.txt"):
|
||||||
return os.path.join(base_path, 'resources', 'data', relative_path)
|
return os.path.join(base_path, 'data', relative_path)
|
||||||
|
|
||||||
return os.path.join(base_path, relative_path)
|
return os.path.join(base_path, relative_path)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
|
import webbrowser
|
||||||
from PySide6.QtCore import QThread, Signal
|
from PySide6.QtCore import QThread, Signal
|
||||||
|
from PySide6.QtWidgets import QMessageBox
|
||||||
|
import sys
|
||||||
|
|
||||||
class ConfigFetchThread(QThread):
|
class ConfigFetchThread(QThread):
|
||||||
finished = Signal(object, str) # data, error_message
|
finished = Signal(object, str) # data, error_message
|
||||||
@@ -30,8 +33,12 @@ class ConfigFetchThread(QThread):
|
|||||||
# 首先,总是尝试解析JSON
|
# 首先,总是尝试解析JSON
|
||||||
config_data = response.json()
|
config_data = response.json()
|
||||||
|
|
||||||
# 检查是否是要求更新的错误信息
|
# 检查是否是要求更新的错误信息 - 使用Unicode编码的更新提示文本
|
||||||
if config_data.get("message") == "请使用最新版本的FRAISEMOE Addons Installer NEXT进行下载安装":
|
update_required_msg = "\u8bf7\u4f7f\u7528\u6700\u65b0\u7248\u672c\u7684FraiseMoe2-Next\u8fdb\u884c\u4e0b\u8f7d"
|
||||||
|
if isinstance(config_data, str) and config_data == update_required_msg:
|
||||||
|
self.finished.emit(None, "update_required")
|
||||||
|
return
|
||||||
|
elif isinstance(config_data, dict) and config_data.get("message") == update_required_msg:
|
||||||
self.finished.emit(None, "update_required")
|
self.finished.emit(None, "update_required")
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -44,9 +51,15 @@ class ConfigFetchThread(QThread):
|
|||||||
|
|
||||||
self.finished.emit(config_data, "")
|
self.finished.emit(config_data, "")
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
self.finished.emit(None, f"网络请求失败: {e}")
|
error_msg = "访问云端配置失败,请检查网络状况或稍后再试。"
|
||||||
|
if self.debug_mode:
|
||||||
|
error_msg += f"\n详细错误: {e}"
|
||||||
|
self.finished.emit(None, error_msg)
|
||||||
except (ValueError, json.JSONDecodeError) as e:
|
except (ValueError, json.JSONDecodeError) as e:
|
||||||
self.finished.emit(None, f"JSON解析失败: {e}")
|
error_msg = "访问云端配置失败,请检查网络状况或稍后再试。"
|
||||||
|
if self.debug_mode:
|
||||||
|
error_msg += f"\nJSON解析失败: {e}"
|
||||||
|
self.finished.emit(None, error_msg)
|
||||||
finally:
|
finally:
|
||||||
if self.debug_mode:
|
if self.debug_mode:
|
||||||
print("--- Finished fetching cloud config ---")
|
print("--- Finished fetching cloud config ---")
|
||||||