Skip to content

Commit

Permalink
Develop (#19)
Browse files Browse the repository at this point in the history
* Fix #18

* Win 修改版本判断机制

* Win 添加显示更新内容

* Win 自动更新优化 和 workflow 依赖添加

* Win 添加下载超时功能

* Win 插件商店安装路径修复
  • Loading branch information
Mzdyl authored Feb 19, 2024
1 parent db0b601 commit 1fdff8c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
1 change: 1 addition & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install requests
pip install rich
- name: Install pyinstaller
run: |
Expand Down
43 changes: 20 additions & 23 deletions install_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
import struct
import requests
import tempfile
import urllib.request
import tkinter as tk
from tkinter import filedialog
from rich.console import Console
from rich.markdown import Markdown

# 当前版本号
current_version = "1.7"
current_version = "1.8"

# 存储反代服务器的URL
PROXY_URL = 'https://mirror.ghproxy.com/'
Expand Down Expand Up @@ -93,26 +94,22 @@ def read_registry_key(hive, subkey, value_name):


def check_for_updates():

# 获取最新版本号
response = requests.get("https://api.github.com/repos/Mzdyl/LiteLoaderQQNT_Install/releases/latest")
latest_release = response.json()
tag_name = latest_release['tag_name']

# 构建最新版本文件地址
version_url = f"https://github.com/Mzdyl/LiteLoaderQQNT_Install/releases/download/{tag_name}/version.txt"

print(version_url)

try:
with urllib.request.urlopen(version_url) as response:
remote_version = response.read().decode('utf-8').strip()

if remote_version > current_version:
print(f"发现新版本 {remote_version}!")
# 获取最新版本号
response = requests.get("https://api.github.com/repos/Mzdyl/LiteLoaderQQNT_Install/releases/latest", timeout=3)
latest_release = response.json()
tag_name = latest_release['tag_name']
body = latest_release['body']
if tag_name > current_version:
print(f"发现新版本 {tag_name}!")
print(f"更新日志:\n ")
console = Console()
markdown = Markdown(body)
console.print(markdown)
download_url = (
f"https://github.com/Mzdyl/LiteLoaderQQNT_Install/releases/download/{remote_version}/install_windows.exe")
urllib.request.urlretrieve(download_url, f"install_windows-{remote_version}.exe")
f"https://github.com/Mzdyl/LiteLoaderQQNT_Install/releases/download/{tag_name}/install_windows.exe")
# urllib.request.urlretrieve(download_url, f"install_windows-{tag_name}.exe")
download_file(download_url, f"install_windows-{tag_name}.exe", PROXY_URL)
print("版本号已更新。")
print("请重新运行脚本。")
sys.exit(0)
Expand Down Expand Up @@ -152,9 +149,9 @@ def can_connect_to_github():
def download_file(url, filename, proxy_url=None):
if not can_connect_to_github() and proxy_url:
proxy_url = proxy_url + url # 将代理地址和要下载的文件 URL 拼接在一起
response = requests.get(proxy_url)
response = requests.get(proxy_url, timeout=10)
else:
response = requests.get(url)
response = requests.get(url, timeout=10)

with open(filename, 'wb') as file:
file.write(response.content)
Expand Down Expand Up @@ -228,7 +225,7 @@ def download_and_install_plugin_store(file_path):

if not os.path.exists(existing_destination_path1) and not os.path.exists(existing_destination_path2):
# 创建目标文件夹
os.makedirs(os.path.join(file_path, 'resources', 'app', 'LiteLoaderQQNT-main', 'plugins'), exist_ok=True)
os.makedirs(plugin_path, exist_ok=True)
print(
f"Moving from: {os.path.join(temp_dir, 'LiteLoaderQQNT-Plugin-Plugin-Store', 'LiteLoaderQQNT-Plugin-Plugin-Store-master')}")
print(f"Moving to: {existing_destination_path2}")
Expand Down

0 comments on commit 1fdff8c

Please sign in to comment.