From 6ac73a8d28c623d63610d28c0ca3fa68b2347625 Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Mon, 3 Dec 2018 17:50:43 +0800 Subject: [PATCH] u --- class/core/system_api.py | 17 +++++++++++++++-- route/system.py | 3 ++- static/js/index.js | 8 ++++---- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/class/core/system_api.py b/class/core/system_api.py index a7325ff2b..905e6a3ca 100755 --- a/class/core/system_api.py +++ b/class/core/system_api.py @@ -537,6 +537,7 @@ class system_api: return ret def getServerInfo(self): + upAddr = 'https://raw.githubusercontent.com/midoks/mdserver-web/master/version' try: version = public.httpGet( @@ -548,7 +549,7 @@ class system_api: return {} # 更新服务 - def updateServer(self, stype): + def updateServer(self, stype, version=''): try: if not public.isRestart(): @@ -579,7 +580,19 @@ class system_api: return public.returnJson(True, '更新信息!', version_new_info) if stype == 'update': - pass + if version == '': + return public.returnJson(False, '缺少版本信息!') + + v_new_info = self.getServerInfo() + if v_new_info['version'] != version: + return public.returnJson(False, '更新失败,请重试!') + + if not 'path' in v_new_info or v_new_info['path'] == '': + return public.returnJson(False, '下载地址不存在!') + + public.downloadFile( + v_new_info['path'], 'mdserver-web.zip') + print v_new_info return public.returnJson(False, '已经是最新,无需更新!') except Exception as ex: diff --git a/route/system.py b/route/system.py index e1ba3a8d0..930c35659 100644 --- a/route/system.py +++ b/route/system.py @@ -26,7 +26,8 @@ def network(): @system.route("/update_server") def updateServer(): stype = request.args.get('type', 'check') - data = system_api.system_api().updateServer(stype) + version = request.args.get('version', '') + data = system_api.system_api().updateServer(stype, version) return data diff --git a/static/js/index.js b/static/js/index.js index 8580299aa..46937bb31 100755 --- a/static/js/index.js +++ b/static/js/index.js @@ -518,8 +518,8 @@ function updateMsg(){ content:'
' +'

'+rdata.data.content+'

' +'
' - +'' - +'' + +'' + +'' +'
' +'
' }); @@ -529,8 +529,8 @@ function updateMsg(){ //开始升级 function updateVersion(version) { - var loadT = layer.msg(lan.index.update_the, { icon: 16, time: 0, shade: [0.3, '#000'] }); - $.get('/system/update_server?type=update', function(rdata) { + var loadT = layer.msg('正在升级面板..', { icon: 16, time: 0, shade: [0.3, '#000'] }); + $.get('/system/update_server?type=update&version='+version, function(rdata) { layer.closeAll(); if (rdata.status === false) { layer.msg(rdata.msg, { icon: 5, time: 5000 });