diff --git a/plugins/gogs/index.py b/plugins/gogs/index.py index c5ee31848..5c69ddf4c 100755 --- a/plugins/gogs/index.py +++ b/plugins/gogs/index.py @@ -383,6 +383,10 @@ def postReceiveLog(): def getGogsConf(): + conf = getConf() + if not os.path.exists(conf): + return mw.returnJson(False, "请先安装初始化!") + gets = [ {'name': 'DOMAIN', 'type': -1, 'ps': '服务器域名'}, {'name': 'ROOT_URL', 'type': -1, 'ps': '公开的完整URL路径'}, @@ -403,7 +407,7 @@ def getGogsConf(): {'name': 'SHOW_FOOTER_VERSION', 'type': 2, 'ps': 'Gogs版本信息'}, {'name': 'SHOW_FOOTER_TEMPLATE_LOAD_TIME', 'type': 2, 'ps': 'Gogs模板加载时间'}, ] - conf = mw.readFile(getConf()) + conf = mw.readFile(conf) result = [] for g in gets: @@ -413,7 +417,7 @@ def getGogsConf(): continue g['value'] = tmp.groups()[0] result.append(g) - return mw.getJson(result) + return mw.returnJson(True, 'OK', result) def submitGogsConf(): @@ -445,6 +449,11 @@ def submitGogsConf(): def userList(): + + conf = getConf() + if not os.path.exists(conf): + return mw.returnJson(False, "请先安装初始化!") + import math args = getArgs() diff --git a/plugins/gogs/js/gogs.js b/plugins/gogs/js/gogs.js index 0792201c0..e6318cc8c 100755 --- a/plugins/gogs/js/gogs.js +++ b/plugins/gogs/js/gogs.js @@ -39,9 +39,12 @@ function gogsPost(method,args,callback, title){ function gogsSetConfig(){ gogsPost('get_gogs_conf', '', function(data){ - // console.log(data); - var rdata = $.parseJSON(data.data); - // console.log(rdata); + var rrdata = $.parseJSON(data.data); + if (!rrdata.status){ + layer.msg(rrdata.msg,{icon:0,time:2000,shade: [0.3, '#000']}); + return; + } + var rdata = rrdata.data; var mlist = ''; for (var i = 0; i < rdata.length; i++) { var w = '140'; @@ -141,7 +144,10 @@ function gogsUserList(page, search) { gogsPost('user_list', _data, function(data){ var rdata = $.parseJSON(data.data); - // console.log(rdata); + if (!rdata.status){ + layer.msg(rdata.msg,{icon:0,time:2000,shade: [0.3, '#000']}); + return; + } content = '
'; content += '
';