diff --git a/auto_pt/views.py b/auto_pt/views.py index e348f25..7784401 100644 --- a/auto_pt/views.py +++ b/auto_pt/views.py @@ -123,16 +123,36 @@ def restart_container(request): # res = scraper.get('https://gitee.com/ngfchl/ptools/raw/master/update.md') # update_md = markdown.markdown(res.text, extensions=['tables']) + # 拉取更新元数据 + update_log = subprocess.Popen('git remote update', shell=True) + update_log.wait() + # 获取本地更新日志第一条 + p_local = subprocess.Popen('git log --oneline -1', shell=True, stdout=subprocess.PIPE, ) + commit_local = p_local.stdout.readline().decode('utf8').strip() + # 获取远端仓库更新日志第一条 + p_remote = subprocess.Popen('git log origin/master --oneline -1', shell=True, stdout=subprocess.PIPE, ) + commit_remote = p_remote.stdout.readline().decode('utf8').strip() + print(commit_local, commit_remote) + # if 'HEAD' in commit and 'origin' in commit: + print(commit_remote == commit_local) + # 如果日志相同则更新到最新,否则显示远端更新日志 + if commit_remote == commit_local: + update = 'false' + update_tips = '目前您使用的是最新版本!' + else: + update = 'true' + update_tips = '已有新版本,请根据需要升级!' restart = 'false' - update = 'false' if os.environ.get('CONTAINER_NAME'): restart = 'true' return render(request, 'auto_pt/restart.html', context={ # 'update_md': update_md, 'local_logs': get_git_logs(), + 'update_notes': get_git_logs(master='origin/master'), 'restart': restart, 'update': update, + 'update_tips': update_tips, }) diff --git a/templates/auto_pt/restart.html b/templates/auto_pt/restart.html index 8a77383..e50e5ec 100644 --- a/templates/auto_pt/restart.html +++ b/templates/auto_pt/restart.html @@ -9,7 +9,6 @@
- 更新提示 + {{ update_tips }} + + - 获取更新 +{# 获取更新#} 更新 重启 @@ -50,7 +52,7 @@ - +
更新日志 @@ -90,13 +92,28 @@ // element: 指定用vue来管理页面中的哪个标签区域 el: '#app', data: { - update_notes: '', + update_notes: {{ update_notes|safe }}, local_logs: {{ local_logs|safe }}, restart:{{ restart }}, - update:{{ update }}, - update_log: false, + + update: false, + {#update_log: false,#} local_log_width: 24 }, + created() { + this.update = + {{ update }} + + if (this.update) { + this.local_log_width = 12 + + } + this.$message({ + showClose: true, + message: "{{ update_tips }}", + type: 'success' + }); + }, methods: { do_restart() { this.$confirm('此操作将重启容器,并更新软件, 是否继续?', '提示', { @@ -143,7 +160,7 @@ if (res.data.code === 0) { console.log(res.data) this.update_notes = res.data.data.update_notes - this.update_log = true + {#this.update_log = true#} this.local_log_width = 12 this.$message({ type: 'success', diff --git a/update.md b/update.md index 046f00a..c57f13c 100644 --- a/update.md +++ b/update.md @@ -7,6 +7,15 @@ ### 更新修复 +- 0827 + 1. 修复部分导入导出失败的错误 + 2. 修复带逗号的魔力值解析错误的bug + 3. 修复获取更新失败的bug + 4. 修复删除站点时权限拒绝的bug + 5. 修复PT时间刷新状态时报错的bug + 6. 优化更新界面,增加提示信息 + 7. 优化更新流程,自动获取更新信息并展示,用户自行决定是否升级 + - 0826 1. 修复白兔签到返回错误的bug 2. 修复容器名称与环境变量已正确显示无法重启的bug @@ -14,4 +23,4 @@ 4. 更新功能中加入规则更新,直接写入数据库(写入前备份) 5. 更新部分站点规则 6. 修复容器名称与环境变量已正确设置但无法重启的bug - 7. 优化重启按钮,在环境变量CONTAINER_NAME未设置时不显示 \ No newline at end of file + 7. 优化重启按钮,在环境变量CONTAINER_NAME未设置时不显示