From f0096d93a931e58c88e6d76c883255f5a7b09c98 Mon Sep 17 00:00:00 2001 From: hjdhnx Date: Fri, 9 Sep 2022 23:56:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E5=BC=BA=E5=88=B6?= =?UTF-8?q?=E5=8D=87=E7=BA=A7=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/admin.py | 14 +++++++++++++- js/version.txt | 2 +- readme.md | 1 + templates/admin.html | 23 +++++++++++++++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/controllers/admin.py b/controllers/admin.py index a40ca51..dc4862b 100644 --- a/controllers/admin.py +++ b/controllers/admin.py @@ -9,7 +9,7 @@ from flask import Blueprint,request,render_template,jsonify,make_response from controllers.service import storage_service from base.R import R from utils.web import verfy_token -from utils.update import getLocalVer,getOnlineVer,download_new_version,download_lives +from utils.update import getLocalVer,getOnlineVer,download_new_version,download_lives,copy_to_update from utils import parser from utils.web import getParmas from js.rules import getRules @@ -77,6 +77,18 @@ def admin_update_ver(): msg = download_new_version() return R.success(msg) +@admin.route('/force_update') +def admin_force_update(): + if not verfy_token(): + return R.failed('请登录后再试') + ret = copy_to_update() + if ret: + msg = '升级成功' + return R.success(msg) + else: + msg = '升级失败。具体原因只能去看实时日志(通过9001端口)' + return R.failed(msg) + @admin.route('/update_lives') def admin_update_lives(): url = getParmas('url') diff --git a/js/version.txt b/js/version.txt index a423d42..8a0feb9 100644 --- a/js/version.txt +++ b/js/version.txt @@ -1 +1 @@ -3.4.2 \ No newline at end of file +3.4.3 \ No newline at end of file diff --git a/readme.md b/readme.md index 0a4a746..5d45f52 100644 --- a/readme.md +++ b/readme.md @@ -50,6 +50,7 @@ - [X] 1.增加西瓜源,修复一级不支持lazy的bug - [X] 2.兄弟们dockerhub没法push镜像不知道咋回事,3.4.1的镜像自己用docker目录下的文件build吧 - [X] 3.版本升至3.4.2,增加py源支持,放txt/py目录即可,特别鸣谢Pyramid开发者及xiaoya liu提供的技术和源 +- [X] 3.版本升至3.4.3,增加了强制升级功能(本地增量覆盖大法) ###### 2022/09/08 - [X] 1.升级到3.2.9,支持自动合并自定义用户配置(内置t4测试源) - [X] 2.升级到3.3.0,增加奇珍异兽源 diff --git a/templates/admin.html b/templates/admin.html index 74b0188..adcb5b8 100644 --- a/templates/admin.html +++ b/templates/admin.html @@ -143,6 +143,27 @@ } }); + $('#force_update').click(function (){ + let msg = ` + 升级过程中由于新版本升级脚本发生改变可能会导致升级完毕但是升级不完整。 + 此时需要重启服务后执行强制升级操作通过更新后的升级脚本把本地升级包文件再次覆盖完成完整升级。 + 是否继续(请确认你升级完后重启过,不然点确定毫无必要)? + `; + if(confirm(msg)){ + $.get("/admin/force_update",function(data,status){ + console.log(data); + if(data.code === 200){ + alert(data.msg+'\n除主程序app.py需要自行检测替换升级外,其他关键文件全部更新完毕'); + location.reload(); + }else{ + alert(data.msg||'未知数据,具体到数据控制台查看'); + console.log('升级失败了...'); + return false + } + }); + } + }); + }); function getFileSize(fileObj) { $('#file_size').text('文件大小为:'+fileObj.files[0].size/1024+'kb'); @@ -163,6 +184,8 @@ function getFileSize(fileObj) { id="write_lives">修改直播源 +

你可以在此界面在线管理JS目录里规则文件的上传/删除

-- GitLab