From ff87447b6bdf30c570dbb7276376b8643ba21fc4 Mon Sep 17 00:00:00 2001 From: ngfchl Date: Sat, 27 Aug 2022 17:01:01 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=8E=BB=E9=99=A4=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E6=A0=87=E8=AF=86=202.=20=E5=8E=BB=E9=99=A4?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=A1=B5=E9=9D=A2=E6=97=A0=E7=94=A8=E9=93=BE?= =?UTF-8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auto_pt/urls.py | 2 +- auto_pt/views.py | 64 +++++++++++++++++----------------- templates/admin/home.html | 43 ++++++++--------------- templates/auto_pt/restart.html | 56 ++++++++++++++--------------- 4 files changed, 75 insertions(+), 90 deletions(-) diff --git a/auto_pt/urls.py b/auto_pt/urls.py index 12ed15e..ecc8325 100644 --- a/auto_pt/urls.py +++ b/auto_pt/urls.py @@ -12,6 +12,6 @@ urlpatterns = [ path(r'do_restart', views.do_restart, name='do_restart'), path(r'do_restart', views.do_restart, name='do_restart'), path(r'do_update', views.do_update, name='do_update'), - path(r'get_update', views.do_get_update, name='do_get_update'), + # path(r'get_update', views.do_get_update, name='do_get_update'), path(r'do_sql', views.do_sql, name='do_sql'), ] diff --git a/auto_pt/views.py b/auto_pt/views.py index 60802fd..344bb70 100644 --- a/auto_pt/views.py +++ b/auto_pt/views.py @@ -157,38 +157,38 @@ def restart_container(request): 'update_tips': update_tips, }) - -def do_get_update(request): - update = 'false' - # 拉取更新元数据 - 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: - return JsonResponse(data=CommonResponse.success( - msg='已经更新到最新!', - data={ - 'update_notes': get_git_logs(master='origin/master'), - } - ).to_dict(), safe=False) - else: - update = 'true' - return JsonResponse(data=CommonResponse.success( - msg='拉取更新日志成功!!', - data={ - 'update': update, - 'update_notes': get_git_logs(master='origin/master'), - } - ).to_dict(), safe=False) +# +# def do_get_update(request): +# update = 'false' +# # 拉取更新元数据 +# 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: +# return JsonResponse(data=CommonResponse.success( +# msg='已经更新到最新!', +# data={ +# 'update_notes': get_git_logs(master='origin/master'), +# } +# ).to_dict(), safe=False) +# else: +# update = 'true' +# return JsonResponse(data=CommonResponse.success( +# msg='拉取更新日志成功!!', +# data={ +# 'update': update, +# 'update_notes': get_git_logs(master='origin/master'), +# } +# ).to_dict(), safe=False) def do_update(request): diff --git a/templates/admin/home.html b/templates/admin/home.html index 7fe3338..c7ae03b 100644 --- a/templates/admin/home.html +++ b/templates/admin/home.html @@ -4,41 +4,26 @@ - {% if "SIMPLEUI_HOME_QUICK"|get_config != False %} - - - -
- - -
-
- {% if "SIMPLEUI_HOME_QUICK"|get_config != False %} - - {% endif %} -
-
-
- {% endif %} - +
- PTools + +
-
-
- -
v2022.08.13
-
+
+ {% if "SIMPLEUI_HOME_QUICK"|get_config != False %} + + {% endif %}
+ + diff --git a/templates/auto_pt/restart.html b/templates/auto_pt/restart.html index e50e5ec..901ee6e 100644 --- a/templates/auto_pt/restart.html +++ b/templates/auto_pt/restart.html @@ -153,34 +153,34 @@ }); }); }, - get_update() { - axios.get( - "{% url "do_get_update" %}" - ).then(res => { - if (res.data.code === 0) { - console.log(res.data) - this.update_notes = res.data.data.update_notes - {#this.update_log = true#} - this.local_log_width = 12 - this.$message({ - type: 'success', - message: res.data.msg - }); - } else { - console.log(res) - this.$message({ - type: 'warning', - message: res.data.msg - }); - } - }).catch(res => { - console.log(res) - this.$message({ - type: 'info', - message: '获取更新失败!' - }); - }); - }, + {#get_update() {#} + {# axios.get(#} + {# "{% url "do_get_update" %}"#} + {# ).then(res => {#} + {# if (res.data.code === 0) {#} + {# console.log(res.data)#} + {# this.update_notes = res.data.data.update_notes#} + {#this.update_log = true#} + {# this.local_log_width = 12#} + {# this.$message({#} + {# type: 'success',#} + {# message: res.data.msg#} + {# });#} + {# } else {#} + {# console.log(res)#} + {# this.$message({#} + {# type: 'warning',#} + {# message: res.data.msg#} + {# });#} + {# }#} + {# }).catch(res => {#} + {# console.log(res)#} + {# this.$message({#} + {# type: 'info',#} + {# message: '获取更新失败!'#} + {# });#} + {# });#} + {#{},#} do_update() { this.$confirm('此操作会拉取软件更新软件,新版本不一定稳定,是否继续?', '提示', { confirmButtonText: '确定',