From 2d251f48e553a943d984d2dae47ce3dd6d95ad03 Mon Sep 17 00:00:00 2001 From: ngfchl Date: Sat, 27 Aug 2022 16:19:45 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=BC=98=E5=8C=96=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=EF=BC=8C=E8=87=AA=E5=8A=A8=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BF=A1=E6=81=AF=E5=B9=B6=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=EF=BC=8C=E7=94=A8=E6=88=B7=E8=87=AA=E8=A1=8C=E5=86=B3=E5=AE=9A?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auto_pt/views.py | 22 +++++++++++++++++++++- templates/auto_pt/restart.html | 31 ++++++++++++++++++++++++------- update.md | 11 ++++++++++- 3 files changed, 55 insertions(+), 9 deletions(-) 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未设置时不显示