pull/109/head
Mr Chen 7 years ago
parent d81a069d94
commit d66f208b53
  1. 64
      class/core/plugin_api.py
  2. 6
      plugins/php/versions/72/install.sh
  3. 7
      route/plugins.py
  4. 80
      static/js/soft.js

@ -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

@ -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 \

@ -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', '')

@ -148,52 +148,48 @@ function GetSList(isdisplay) {
var handle = '<a class="btlink" onclick="AddVersion(\'' + plugin.name + '\',\'' + version_info + '\',\'' + plugin.tip + '\',this,\'' + plugin.title + '\')">安装</a>';
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) ? '' : '<a class="btlink" onclick="SoftUpdate(\'' + plugin.name + '\',\'' + plugin.versions + '\',\'' + plugin.versions[n].version + '\')">更新</a> | ';
handle = mupdate + '<a class="btlink" onclick="PluginMan(\'' + plugin.name + '\',\'' + plugin.title + '\')">' + lan.soft.setup + '</a> | <a class="btlink" onclick="UninstallVersion(\'' + plugin.name + '\',\'' + plugin.versions + '\',\'' + plugin.title + '\')">卸载</a>';
titleClick = 'onclick="PluginMan(\'' + plugin.name + '\',\'' + plugin.title + '\')" style="cursor:pointer"';
} else {
console.log(plugin, n);
var mupdate = '';//(plugin.versions[n] == plugin.updates[n]) '' : '<a class="btlink" onclick="SoftUpdate(\'' + plugin.name + '\',\'' + plugin.versions[n].version + '\',\'' + plugin.updates[n] + '\')">更新</a> | ';
if (plugin.versions[n] == '') mupdate = '';
handle = mupdate + '<a class="btlink" onclick="SoftMan(\'' + plugin.name + '\',\'' + version_info + '\')">' + lan.soft.setup + '</a> | <a class="btlink" onclick="UninstallVersion(\'' + plugin.name + '\',\'' + plugin.versions + '\',\'' + plugin.title + '\')">卸载</a>';
titleClick = 'onclick="SoftMan(\'' + plugin.name + '\',\'' + version_info + '\')" style="cursor:pointer"';
}
version = plugin.version;
softPath = '<span class="glyphicon glyphicon-folder-open" title="' + rdata.data[i].path + '" onclick="openPath(\'' + rdata.data[i].path + '\')"></span>';
indexshow = '<div class="index-item"><input class="btswitch btswitch-ios" id="index_' + rdata.data[i].name + '" type="checkbox" ' + checked + '><label class="btswitch-btn" for="index_' + plugin.name + '" onclick="toIndexDisplay(\'' + plugin.name + '\',\'' + version + '\')"></label></div>';
if (rdata.data[i].versions[n].run == true) {
state = '<span style="color:#20a53a" class="glyphicon glyphicon-play"></span>'
} else {
state = '<span style="color:red" class="glyphicon glyphicon-pause"></span>'
}
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) ? '' : '<a class="btlink" onclick="SoftUpdate(\'' + plugin.name + '\',\'' + plugin.versions + '\',\'' + plugin.versions[n].version + '\')">更新</a> | ';
handle = mupdate + '<a class="btlink" onclick="PluginMan(\'' + plugin.name + '\',\'' + plugin.title + '\')">' + lan.soft.setup + '</a> | <a class="btlink" onclick="UninstallVersion(\'' + plugin.name + '\',\'' + plugin.versions + '\',\'' + plugin.title + '\')">卸载</a>';
titleClick = 'onclick="PluginMan(\'' + plugin.name + '\',\'' + plugin.title + '\')" style="cursor:pointer"';
} else {
var mupdate = '';//(plugin.versions[n] == plugin.updates[n]) '' : '<a class="btlink" onclick="SoftUpdate(\'' + plugin.name + '\',\'' + plugin.versions[n].version + '\',\'' + plugin.updates[n] + '\')">更新</a> | ';
if (plugin.versions[n] == '') mupdate = '';
handle = mupdate + '<a class="btlink" onclick="SoftMan(\'' + plugin.name + '\',\'' + version_info + '\')">' + lan.soft.setup + '</a> | <a class="btlink" onclick="UninstallVersion(\'' + plugin.name + '\',\'' + plugin.versions + '\',\'' + plugin.title + '\')">卸载</a>';
titleClick = 'onclick="SoftMan(\'' + plugin.name + '\',\'' + version_info + '\')" style="cursor:pointer"';
}
var isTask = plugin.task;
if (isTask == '-1') {
handle = '<a style="color:green;" href="javascript:task();">正在安装...</a>';
} else if (isTask == '0') {
handle = '<a style="color:#C0C0C0;" href="javascript:task();">等待安装...</a>';
version = plugin.version;
softPath = '<span class="glyphicon glyphicon-folder-open" title="' + rdata.data[i].path + '" onclick="openPath(\'' + rdata.data[i].path + '\')"></span>';
indexshow = '<div class="index-item"><input class="btswitch btswitch-ios" id="index_' + rdata.data[i].name + '" type="checkbox" ' + checked + '><label class="btswitch-btn" for="index_' + plugin.name + '" onclick="toIndexDisplay(\'' + plugin.name + '\',\'' + version + '\')"></label></div>';
if (rdata.data[i].versions[n].run == true) {
state = '<span style="color:#20a53a" class="glyphicon glyphicon-play"></span>'
} else {
state = '<span style="color:red" class="glyphicon glyphicon-pause"></span>'
}
}
var isTask = plugin.task;
if (plugin.task == '-1') {
handle = '<a style="color:green;" href="javascript:task();">正在安装...</a>';
} else if (isTask == '0') {
handle = '<a style="color:#C0C0C0;" href="javascript:task();">等待安装...</a>';
}
}
// console.log(plugin);
sBody += '<tr>' +
'<td><span ' + titleClick +
'><img src="/plugins/file?name=' + rdata.data[i].name +
'&f=ico.png' + '">' + rdata.data[i].title + ' ' + version_info + '</span></td>' +
'<td>' + rdata.data[i].ps + '</td>' +
'<td>' + softPath + '</td>' +
'<td>' + state + '</td>' +
'<td>' + indexshow + '</td>' +
'<td style="text-align: right;">' + handle + '</td>' +
'</tr>';
sBody += '<tr>' +
'<td><span ' + titleClick +
'><img src="/plugins/file?name=' + plugin.name +
'&f=ico.png' + '">' + plugin.title + ' ' + version_info + '</span></td>' +
'<td>' + plugin.ps + '</td>' +
'<td>' + softPath + '</td>' +
'<td>' + state + '</td>' +
'<td>' + indexshow + '</td>' +
'<td style="text-align: right;">' + handle + '</td>' +
'</tr>';
}

Loading…
Cancel
Save