diff --git a/class/core/plugin_api.py b/class/core/plugin_api.py index fdc0a3998..b7422dc09 100755 --- a/class/core/plugin_api.py +++ b/class/core/plugin_api.py @@ -10,13 +10,14 @@ import json class plugin_api: __tasks = None - __plugin_dir = "plugins" - __type = "data/json/type.json" + __plugin_dir = 'plugins' + __type = 'data/json/type.json' __index = 'data/json/index.json' setupPath = None def __init__(self): self.setupPath = 'server' + # self.__plugin_dir = public.getRunDir() + '/plugins' # 进程是否存在 def processExists(self, pname, exe=None): @@ -69,13 +70,11 @@ class plugin_api: # 构造本地插件信息 def getPluginInfo(self, info): - # print info["checks"] - - checks = "" - if info["checks"][0:1] == "/": + checks = '' + if info["checks"][0:1] == '/': checks = info["checks"] else: - checks = public.getRootDir() + "/" + info['checks'] + checks = public.getRootDir() + '/' + info['checks'] pluginInfo = { "id": 10000, @@ -95,44 +94,59 @@ class plugin_api: } pluginInfo['task'] = self.checkSetupTask(pluginInfo['name']) + + if checks.find('VERSION') > -1: + pluginInfo['install_checks'] = checks.replace( + 'VERSION', info['versions']) + pluginInfo['setup'] = os.path.exists(pluginInfo['install_checks']) pluginInfo['status'] = os.path.exists(pluginInfo['install_checks']) return pluginInfo - def getPluginList(self, sType, sPage=1, sPageSize=15): - + def getAllList(self, sType='0'): ret = {} ret['type'] = json.loads(public.readFile(self.__type)) plugins_info = [] + for dirinfo in os.listdir(self.__plugin_dir): + if dirinfo[0:1] == '.': + continue + path = self.__plugin_dir + '/' + dirinfo + if os.path.isdir(path): - jsonFile = path + '/info.json' - if os.path.exists(jsonFile): + json_file = path + '/info.json' + if os.path.exists(json_file): try: - tmp = json.loads(public.readFile(jsonFile)) - if tmp['name'] == 'php': - for index in range(len(tmp['versions'])): - + data = json.loads(public.readFile(json_file)) + if type(data['versions']) == list and data['name'] == 'php': + for index in range(len(data['versions'])): + tmp = data.copy() + tmp['versions'] = data['versions'][index] pg = self.getPluginInfo(tmp) - pg['versions'] = tmp['versions'][index] - - # print "sss:", i, v - # pg['updates'] = tmp["updates"][v] - if sType == "0": + if sType == '0': plugins_info.append(pg) else: if pg['pid'] == sType: plugins_info.append(pg) else: - pg = self.getPluginInfo(tmp) - if sType == "0": + pg = self.getPluginInfo(data) + if sType == '0': plugins_info.append(pg) else: if pg['pid'] == sType: plugins_info.append(pg) except Exception, e: print e + # pass + + return plugins_info + + def getPluginList(self, sType, sPage=1, sPageSize=15): + + ret = {} + ret['type'] = json.loads(public.readFile(self.__type)) + plugins_info = self.getAllList(sType) args = {} args['count'] = len(plugins_info) args['p1'] = sPage @@ -140,3 +154,9 @@ class plugin_api: ret['data'] = plugins_info ret['list'] = public.getPage(args) return ret + + def addIndex(self, name, version): + pass + + def run(self): + pass diff --git a/plugins/php/versions/72/install.sh b/plugins/php/versions/72/install.sh index 5114c0210..b2163d1f2 100755 --- a/plugins/php/versions/72/install.sh +++ b/plugins/php/versions/72/install.sh @@ -33,9 +33,9 @@ fi cd $sourcePath/php/php-7.2.5 && ./configure \ ---prefix=$serverPath/php/php72 \ ---exec-prefix=$serverPath/php/php72 \ ---with-config-file-path=$serverPath/php/php72/etc \ +--prefix=$serverPath/php/72 \ +--exec-prefix=$serverPath/php/72 \ +--with-config-file-path=$serverPath/php/72/etc \ --with-zlib-dir=$serverPath/lib/zlib \ --without-iconv \ --enable-zip \ diff --git a/route/plugins.py b/route/plugins.py index fa181318e..92b85c50a 100644 --- a/route/plugins.py +++ b/route/plugins.py @@ -141,6 +141,13 @@ def checkInstalled(): return "False" +@plugins.route('/add_index', methods=['GET']) +def addIndex(): + name = request.args.get('name', '') + html = __plugin_name + '/' + name + '/index.html' + return public.readFile(html) + + @plugins.route('/setting', methods=['GET']) def setting(): name = request.args.get('name', '') diff --git a/static/js/soft.js b/static/js/soft.js index d493c3cd2..37fa4cbd0 100755 --- a/static/js/soft.js +++ b/static/js/soft.js @@ -148,52 +148,48 @@ function GetSList(isdisplay) { var handle = '安装'; var isSetup = false; - for (var n = 0; n < len; n++) { - if (plugin.status == true) { - isSetup = true; - if (plugin.tip == 'lib') { - var mupdate = (plugin.versions[n].no == plugin.versions[n].version) ? '' : '更新 | '; - handle = mupdate + '' + lan.soft.setup + ' | 卸载'; - titleClick = 'onclick="PluginMan(\'' + plugin.name + '\',\'' + plugin.title + '\')" style="cursor:pointer"'; - } else { - console.log(plugin, n); - - - var mupdate = '';//(plugin.versions[n] == plugin.updates[n]) '' : '更新 | '; - if (plugin.versions[n] == '') mupdate = ''; - handle = mupdate + '' + lan.soft.setup + ' | 卸载'; - titleClick = 'onclick="SoftMan(\'' + plugin.name + '\',\'' + version_info + '\')" style="cursor:pointer"'; - } - - version = plugin.version; - softPath = ''; - indexshow = '
'; - if (rdata.data[i].versions[n].run == true) { - state = '' - } else { - state = '' - } + for (var n = 0; n < len; n++) { + if (plugin.status == true) { + isSetup = true; + if (plugin.tip == 'lib') { + var mupdate = (plugin.versions[n].no == plugin.versions[n].version) ? '' : '更新 | '; + handle = mupdate + '' + lan.soft.setup + ' | 卸载'; + titleClick = 'onclick="PluginMan(\'' + plugin.name + '\',\'' + plugin.title + '\')" style="cursor:pointer"'; + } else { + + var mupdate = '';//(plugin.versions[n] == plugin.updates[n]) '' : '更新 | '; + if (plugin.versions[n] == '') mupdate = ''; + handle = mupdate + '' + lan.soft.setup + ' | 卸载'; + titleClick = 'onclick="SoftMan(\'' + plugin.name + '\',\'' + version_info + '\')" style="cursor:pointer"'; } - var isTask = plugin.task; - if (isTask == '-1') { - handle = '正在安装...'; - } else if (isTask == '0') { - handle = '等待安装...'; + + version = plugin.version; + softPath = ''; + indexshow = '
'; + if (rdata.data[i].versions[n].run == true) { + state = '' + } else { + state = '' } } + var isTask = plugin.task; + if (plugin.task == '-1') { + handle = '正在安装...'; + } else if (isTask == '0') { + handle = '等待安装...'; + } + } - // console.log(plugin); - - sBody += '' + - '' + rdata.data[i].title + ' ' + version_info + '' + - '' + rdata.data[i].ps + '' + - '' + softPath + '' + - '' + state + '' + - '' + indexshow + '' + - '' + handle + '' + - ''; + sBody += '' + + '' + plugin.title + ' ' + version_info + '' + + '' + plugin.ps + '' + + '' + softPath + '' + + '' + state + '' + + '' + indexshow + '' + + '' + handle + '' + + ''; }