diff --git a/class/core/system_api.py b/class/core/system_api.py index 7cf3f7dac..a7325ff2b 100755 --- a/class/core/system_api.py +++ b/class/core/system_api.py @@ -542,12 +542,12 @@ class system_api: version = public.httpGet( upAddr + '/info.json') version = json.loads(version) - return version[0]['version'] + return version[0] except Exception as e: - pass - return config.config().getVersion() - + print e + return {} # 更新服务 + def updateServer(self, stype): try: @@ -555,17 +555,35 @@ class system_api: return public.returnJson(False, '请等待所有安装任务完成再执行!') if stype == 'check': version_now = config.config().getVersion() - version_new = self.getServerInfo() - diff = self.versionDiff(version_now, version_new) + version_new_info = self.getServerInfo() + if not 'version' in version_new_info: + return public.returnJson(False, '服务器数据有问题!') + + diff = self.versionDiff( + version_now, version_new_info['version']) if diff == 'new': - return public.returnJson(True, '有新版本!ver:' + version_new) + return public.returnJson(True, '有新版本!') elif diff == 'test': - return public.returnJson(True, '有测试版本!ver:' + version_new) + return public.returnJson(True, '有测试版本!') else: return public.returnJson(False, '已经是最新,无需更新!') + if stype == 'info': + version_new_info = self.getServerInfo() + version_now = config.config().getVersion() + + if not 'version' in version_new_info: + return public.returnJson(False, '服务器数据有问题!') + diff = self.versionDiff( + version_now, version_new_info['version']) + return public.returnJson(True, '更新信息!', version_new_info) + + if stype == 'update': + pass + return public.returnJson(False, '已经是最新,无需更新!') except Exception as ex: + print ex return public.returnJson(False, "连接服务器失败!") # 重启面板 diff --git a/route/system.py b/route/system.py index bc8a4bfd9..e1ba3a8d0 100644 --- a/route/system.py +++ b/route/system.py @@ -25,8 +25,8 @@ def network(): @system.route("/update_server") def updateServer(): - data = system_api.system_api().updateServer('check') - print data + stype = request.args.get('type', 'check') + data = system_api.system_api().updateServer(stype) return data diff --git a/static/js/index.js b/static/js/index.js index f04e89e85..8580299aa 100755 --- a/static/js/index.js +++ b/static/js/index.js @@ -487,28 +487,36 @@ setImg(); //检查更新 function checkUpdate() { var loadT = layer.msg(lan.index.update_get, { icon: 16, time: 0, shade: [0.3, '#000'] }); - $.get('/system/update_server?check=true', function(rdata) { + $.get('/system/update_server?type=check', function(rdata) { layer.close(loadT); if (rdata.status === false) { layer.confirm(rdata.msg, { title: lan.index.update_check, icon: 1, closeBtn: 2, btn: [lan.public.know, lan.public.close] }); return; } layer.msg(rdata.msg, { icon: 1 }); - if (rdata.version != undefined) updateMsg(); + if (rdata.data != undefined) updateMsg(); },'json'); } function updateMsg(){ - window.open("http://www.bt.cn/bbs/thread-1186-1-1.html"); - $.get('/system/update_server',function(rdata){ + $.get('/system/update_server?type=info',function(rdata){ + + var v = rdata.data.version; + var v_info = ''; + if (v.split('.').length>3){ + v_info = "测试版本"; + } else { + v_info = "正式版本"; + } + layer.open({ type:1, - title:lan.index.update_to+'['+rdata.version+']', + title:v_info + '升级到['+rdata.data.version+']', area: '400px', shadeClose:false, closeBtn:2, content:'
' - +'

'+rdata.updateMsg+'

' + +'

'+rdata.data.content+'

' +'
' +'' +'' @@ -522,7 +530,7 @@ function updateMsg(){ //开始升级 function updateVersion(version) { var loadT = layer.msg(lan.index.update_the, { icon: 16, time: 0, shade: [0.3, '#000'] }); - $.get('/ajax?action=UpdatePanel', 'toUpdate=yes', function(rdata) { + $.get('/system/update_server?type=update', function(rdata) { layer.closeAll(); if (rdata.status === false) { layer.msg(rdata.msg, { icon: 5, time: 5000 }); @@ -534,17 +542,17 @@ function updateVersion(version) { $("#toUpdate").html(''); } - layer.msg(lan.index.update_ok, { icon: 1 }); - $.get('/system?action=ReWeb', function() {}); - setTimeout(function() { - window.location.reload(); - }, 3000); + // layer.msg(lan.index.update_ok, { icon: 1 }); + // $.get('/system?action=ReWeb', function() {}); + // setTimeout(function() { + // window.location.reload(); + // }, 3000); }).error(function() { - layer.msg(lan.index.update_ok, { icon: 1 }); - $.get('/system?action=ReWeb', function() {}); - setTimeout(function() { - window.location.reload(); - }, 3000); + // layer.msg(lan.index.update_ok, { icon: 1 }); + // $.get('/system?action=ReWeb', function() {}); + // setTimeout(function() { + // window.location.reload(); + // }, 3000); }); } diff --git a/templates/default/index.html b/templates/default/index.html index dcdd457cf..8601e658f 100755 --- a/templates/default/index.html +++ b/templates/default/index.html @@ -6,7 +6,7 @@ 系统:正在获取中...  
- 0.0.1 + {{config.version}} 更新 修复 重启