From ed0f806ffa1aec3deeb4cf5e5f59bb12a557cc65 Mon Sep 17 00:00:00 2001 From: hjdhnx Date: Fri, 9 Sep 2022 15:42:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=E5=8D=87=E7=BA=A7=E5=A6=82=E6=9E=9C=E5=8F=8D=E5=90=91=E5=8D=87?= =?UTF-8?q?=E7=BA=A7=E7=9A=84=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/admin.py | 4 ++-- js/version.txt | 2 +- templates/admin.html | 4 +++- utils/update.py | 8 +++++--- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/controllers/admin.py b/controllers/admin.py index 6610954..a40ca51 100644 --- a/controllers/admin.py +++ b/controllers/admin.py @@ -67,8 +67,8 @@ def admin_get_ver(): if not verfy_token(): # return render_template('login.html') return R.error('请登录后再试') - - return jsonify({'local_ver':getLocalVer(),'online_ver':getOnlineVer()}) + online_ver,msg = getOnlineVer() + return jsonify({'local_ver':getLocalVer(),'online_ver':online_ver,'msg':msg}) @admin.route('/update_ver') def admin_update_ver(): diff --git a/js/version.txt b/js/version.txt index 0163af7..fbcbf73 100644 --- a/js/version.txt +++ b/js/version.txt @@ -1 +1 @@ -3.3.5 \ No newline at end of file +3.4.0 \ No newline at end of file diff --git a/templates/admin.html b/templates/admin.html index 8ca94d1..74b0188 100644 --- a/templates/admin.html +++ b/templates/admin.html @@ -33,7 +33,7 @@ alert(data.msg); return false }else{ - if(data.local_ver && data.online_ver){ + if(data.local_ver && data.online_ver && !data.msg){ if(data.local_ver !== data.online_ver){ msg = `本地版本:${data.local_ver}\n线上版本:${data.online_ver}\n是否立即执行升级?`; if(confirm(msg)){ @@ -52,6 +52,8 @@ }else{ alert('已经是最新版,无需升级!') } + }else if(data.msg){ + alert('检测升级疑似发生了问题:\n'+data.msg); }else{ alert('已经是最新版,无需升级!') } diff --git a/utils/update.py b/utils/update.py index 385f9a3..4ae579a 100644 --- a/utils/update.py +++ b/utils/update.py @@ -32,17 +32,19 @@ def getLocalVer(): def getOnlineVer(): ver = '1.0.1' + msg = '' try: r = requests.get('https://gitcode.net/qq_32394351/dr_py/-/raw/master/js/version.txt',timeout=(2,2)) ver = r.text except Exception as e: # print(f'{e}') - logger.info(f'{e}') - return ver + msg = f'{e}' + logger.info(msg) + return ver,msg def checkUpdate(): local_ver = getLocalVer() - online_ver = getOnlineVer() + online_ver,msg = getOnlineVer() if local_ver != online_ver: return True return False -- GitLab