Skip to content

Commit

Permalink
1.18 (#155)
Browse files Browse the repository at this point in the history
* 修改连通性

连通性测试改为对提供的 URL 测试而不是单纯的 GitHub

* 简化 插件查看 的下载判读逻辑

* 更新版本号
  • Loading branch information
Mzdyl authored Oct 31, 2024
1 parent 488b404 commit dd346bf
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions install_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from concurrent.futures import ThreadPoolExecutor, as_completed

# 当前版本号
current_version = "1.17"
current_version = "1.18"


# 存储反代服务器的URL
Expand Down Expand Up @@ -247,9 +247,9 @@ def get_document_path() -> str:
return path


def can_connect_to_github():
def can_connect(url, timeout=2):
try:
response = requests.head("https://github.com", timeout=5)
response = requests.head(url, timeout=timeout)
return response.status_code == 200
except requests.exceptions.RequestException:
return False
Expand Down Expand Up @@ -528,26 +528,22 @@ def install_plugin_store(file_path):

temp_dir = tempfile.gettempdir()

if not os.path.exists(existing_destination_path):
if not os.path.exists(existing_destination_path) or not os.path.exists(os.path.join(existing_destination_path, 'main', 'index.js')):
if not os.path.exists(existing_destination_path):
os.makedirs(plugin_path, exist_ok=True)
else:
print("检测到已安装插件商店可能存在问题,即将重装")
shutil.rmtree(existing_destination_path)
print("更新和安装插件请使用 release 版本")
print("非 release 版本可能导致 QQ 无法正常启动")

# 下载并解压插件
download_and_extract_form_release("ltxhhz/LL-plugin-list-viewer")
os.makedirs(plugin_path, exist_ok=True)
print(f"移动自: {os.path.join(temp_dir, 'list-viewer')}")
print(f"移动到: {existing_destination_path}")
shutil.move(os.path.join(temp_dir, "list-viewer"), plugin_path)
else:
download_and_extract_form_release("ltxhhz/LL-plugin-list-viewer")
index_js_path = os.path.join(existing_destination_path, 'main', 'index.js')
if not os.path.exists(index_js_path):
print("检测到已安装插件商店可能存在问题,即将重装")
print("更新和安装插件请使用 release 版本")
print("非 release 版本可能导致 QQ 无法正常启动")
shutil.rmtree(existing_destination_path)
os.makedirs(existing_destination_path, exist_ok=True)
print(f"移动自: {os.path.join(temp_dir, 'list-viewer')}")
print(f"移动到: {existing_destination_path}")
shutil.move(os.path.join(temp_dir, "list-viewer"), existing_destination_path)
else:
print("检测到已安装插件商店,不在重新安装")
print("检测到已安装插件商店,不再重新安装")

except Exception as e:
print(f"安装插件商店发生错误: {e}\n请尝试手动安装")
Expand Down Expand Up @@ -583,7 +579,7 @@ def download_file(url_or_path: str, filepath: str, timeout: int = 10):
shutil.copy(url_or_path, filepath)
return
elif url_or_path.startswith(('http://', 'https://')):
download_url = url_or_path if can_connect_to_github() else f"{get_working_proxy()}/{url_or_path}"
download_url = url_or_path if can_connect(url_or_path) else f"{get_working_proxy()}/{url_or_path}"
print(f"当前使用的下载链接: {download_url}")

# 尝试下载文件
Expand Down

0 comments on commit dd346bf

Please sign in to comment.