pull/109/head
Mr Chen 7 years ago
parent fcf7ff1b21
commit 50e0344a34
  1. 133
      class/core/plugin_api.py
  2. 1
      data/json/index.json
  3. 6
      plugins/openresty/info.json
  4. 42
      plugins/openresty/versions/install.sh
  5. 3
      plugins/php/info.json
  6. 6
      plugins/redis/js/redis.js
  7. 2
      plugins/score/info.json
  8. 13
      route/plugins.py
  9. 208
      static/js/soft.js

@ -68,14 +68,45 @@ class plugin_api:
def checkStatus(self, info): def checkStatus(self, info):
pass pass
def checkDisplayIndex(self, name, version):
if not os.path.exists(self.__index):
public.writeFile(self.__index, '[]')
indexList = json.loads(public.readFile(self.__index))
if type(version) == list:
for index in range(len(version)):
vname = name + '-' + version[index]
if vname in indexList:
return True
else:
vname = name + '-' + version
if vname in indexList:
return True
return False
def getVersion(self, path):
pass
# 构造本地插件信息 # 构造本地插件信息
def getPluginInfo(self, info): def getPluginInfo(self, info):
checks = '' checks = ''
path = ''
coexist = False
if info["checks"][0:1] == '/': if info["checks"][0:1] == '/':
checks = info["checks"] checks = info["checks"]
else: else:
checks = public.getRootDir() + '/' + info['checks'] checks = public.getRootDir() + '/' + info['checks']
if info.has_key('path'):
path = info['path']
if path[0:1] != '/':
path = public.getRootDir() + '/' + path
if info.has_key('coexist') and info['coexist']:
coexist = True
pluginInfo = { pluginInfo = {
"id": 10000, "id": 10000,
"pid": info['pid'], "pid": info['pid'],
@ -85,11 +116,15 @@ class plugin_api:
"ps": info['ps'], "ps": info['ps'],
"dependnet": "", "dependnet": "",
"mutex": "", "mutex": "",
"path": path,
"install_checks": checks, "install_checks": checks,
"uninsatll_checks": checks, "uninsatll_checks": checks,
"coexist": coexist,
"versions": info['versions'], "versions": info['versions'],
# "updates": info['updates'], # "updates": info['updates'],
"display": False,
"setup": False, "setup": False,
"setup_version": "",
"status": False, "status": False,
} }
@ -99,10 +134,54 @@ class plugin_api:
pluginInfo['install_checks'] = checks.replace( pluginInfo['install_checks'] = checks.replace(
'VERSION', info['versions']) 'VERSION', info['versions'])
if path.find('VERSION') > -1:
pluginInfo['path'] = path.replace(
'VERSION', info['versions'])
pluginInfo['display'] = self.checkDisplayIndex(
info['name'], pluginInfo['versions'])
pluginInfo['setup'] = os.path.exists(pluginInfo['install_checks']) pluginInfo['setup'] = os.path.exists(pluginInfo['install_checks'])
pluginInfo['status'] = os.path.exists(pluginInfo['install_checks']) # pluginInfo['status'] = os.path.exists(pluginInfo['install_checks'])
return pluginInfo return pluginInfo
def makeCoexist(self, data):
plugins_info = []
for index in range(len(data['versions'])):
tmp = data.copy()
tmp['title'] = tmp['title'] + \
'-' + data['versions'][index]
tmp['versions'] = data['versions'][index]
pg = self.getPluginInfo(tmp)
plugins_info.append(pg)
return plugins_info
def makeList(self, data, sType):
plugins_info = []
if (data['pid'] == sType):
if type(data['versions']) == list and data.has_key('coexist') and data['coexist']:
tmp_data = self.makeCoexist(data)
for index in range(len(tmp_data)):
plugins_info.append(tmp_data[index])
else:
pg = self.getPluginInfo(data)
plugins_info.append(pg)
pass
return plugins_info
if sType == '0':
if type(data['versions']) == list and data.has_key('coexist') and data['coexist']:
tmp_data = self.makeCoexist(data)
for index in range(len(tmp_data)):
plugins_info.append(tmp_data[index])
else:
pg = self.getPluginInfo(data)
plugins_info.append(pg)
return plugins_info
def getAllList(self, sType='0'): def getAllList(self, sType='0'):
ret = {} ret = {}
ret['type'] = json.loads(public.readFile(self.__type)) ret['type'] = json.loads(public.readFile(self.__type))
@ -111,37 +190,18 @@ class plugin_api:
for dirinfo in os.listdir(self.__plugin_dir): for dirinfo in os.listdir(self.__plugin_dir):
if dirinfo[0:1] == '.': if dirinfo[0:1] == '.':
continue continue
path = self.__plugin_dir + '/' + dirinfo path = self.__plugin_dir + '/' + dirinfo
if os.path.isdir(path): if os.path.isdir(path):
json_file = path + '/info.json' json_file = path + '/info.json'
if os.path.exists(json_file): if os.path.exists(json_file):
try: try:
data = json.loads(public.readFile(json_file)) data = json.loads(public.readFile(json_file))
if type(data['versions']) == list and data['name'] == 'php': tmp_data = self.makeList(data, sType)
for index in range(len(data['versions'])): for index in range(len(tmp_data)):
tmp = data.copy() plugins_info.append(tmp_data[index])
tmp['title'] = tmp['title'] + \
'-' + data['versions'][index]
tmp['versions'] = data['versions'][index]
pg = self.getPluginInfo(tmp)
if sType == '0':
plugins_info.append(pg)
else:
if pg['pid'] == sType:
plugins_info.append(pg)
else:
pg = self.getPluginInfo(data)
if sType == '0':
plugins_info.append(pg)
else:
if pg['pid'] == sType:
plugins_info.append(pg)
except Exception, e: except Exception, e:
print e print e
# pass # pass
return plugins_info return plugins_info
def getPluginList(self, sType, sPage=1, sPageSize=15): def getPluginList(self, sType, sPage=1, sPageSize=15):
@ -158,7 +218,32 @@ class plugin_api:
return ret return ret
def addIndex(self, name, version): def addIndex(self, name, version):
pass if not os.path.exists(self.__index):
public.writeFile(self.__index, '[]')
indexList = json.loads(public.readFile(self.__index))
vname = name + '-' + version
if vname in indexList:
return public.returnJson(False, '请不要重复添加!')
if len(indexList) >= 12:
return public.returnJson(False, '首页最多只能显示12个软件!')
indexList.append(vname)
public.writeFile(self.__index, json.dumps(indexList))
return public.returnJson(True, '添加成功!')
def removeIndex(self, name, version):
if not os.path.exists(self.__index):
public.writeFile(self.__index, '[]')
indexList = json.loads(public.readFile(self.__index))
vname = name + '-' + version
if not vname in indexList:
return public.returnJson(True, '删除成功!')
indexList.remove(vname)
public.writeFile(self.__index, json.dumps(indexList))
return public.returnJson(True, '删除成功!')
def run(self): def run(self):
pass pass

@ -0,0 +1 @@
["php-72", "php-56", "memcached-1.5"]

@ -1,5 +1,5 @@
{ {
"title":"openresty", "title":"OpenResty",
"tip":"soft", "tip":"soft",
"name":"openresty", "name":"openresty",
"type":"其他插件", "type":"其他插件",
@ -10,6 +10,6 @@
"home":"http://openresty.org", "home":"http://openresty.org",
"date":"2017-11-24", "date":"2017-11-24",
"pid": "1", "pid": "1",
"versions": ["1.13.6"], "versions": ["1.11.2", "1.13.6"],
"updates": ["1.13.6.2"] "updates": ["1.11.2.5", "1.13.6.2"]
} }

@ -0,0 +1,42 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
install_tmp=${rootPath}/tmp/bt_install.pl
openrestyDir=${serverPath}/source/openresty
Install_openresty()
{
mkdir -p ${openrestyDir}
echo '正在安装脚本文件...' > $install_tmp
if [ ! -f ${openrestyDir}/openresty-1.13.6.2.tar.gz ];then
wget -O ${openrestyDir}/openresty-1.13.6.2.tar.gz https://openresty.org/download/openresty-1.13.6.2.tar.gz
fi
cd ${openrestyDir} && tar -zxvf openresty-1.13.6.2.tar.gz
cd ${openrestyDir}/openresty* && ./configure --prefix=$serverPath/openresty \
--with-openssl=$serverPath/source/lib/openssl-1.0.2q && make && make install
echo '安装完成' > $install_tmp
}
Uninstall_openresty()
{
rm -rf $serverPath/openresty
echo '卸载完成' > $install_tmp
}
action=$1
host=$2
if [ "${1}" == 'install' ];then
Install_openresty
else
Uninstall_openresty
fi

@ -4,11 +4,12 @@
"shell": "install.sh", "shell": "install.sh",
"name": "php", "name": "php",
"title": "PHP", "title": "PHP",
"default": false, "coexist": true,
"versions": ["52","56","72"], "versions": ["52","56","72"],
"updates": ["5.2.17","5.6.36","7.2.0"], "updates": ["5.2.17","5.6.36","7.2.0"],
"tip": "soft", "tip": "soft",
"checks": "server/php/VERSION/bin/php", "checks": "server/php/VERSION/bin/php",
"path": "server/php/VERSION",
"display": 1, "display": 1,
"author": "Zend", "author": "Zend",
"date": "2017-04-01", "date": "2017-04-01",

@ -151,9 +151,9 @@ function redisStatus() {
<tr><th>uptime_in_days</th><td>' + rdata.uptime_in_days + '</td><td></td></tr>\ <tr><th>uptime_in_days</th><td>' + rdata.uptime_in_days + '</td><td></td></tr>\
<tr><th>tcp_port</th><td>' + rdata.tcp_port + '</td><td></td></tr>\ <tr><th>tcp_port</th><td>' + rdata.tcp_port + '</td><td></td></tr>\
<tr><th>connected_clients</th><td>' + rdata.connected_clients + '</td><td></td></tr>\ <tr><th>connected_clients</th><td>' + rdata.connected_clients + '</td><td></td></tr>\
<tr><th>used_memory_rss</th><td>' + ToSize(rdata.used_memory_rss) + '</td><td>Redis</td></tr>\ <tr><th>used_memory_rss</th><td>' + toSize(rdata.used_memory_rss) + '</td><td>Redis</td></tr>\
<tr><th>used_memory</th><td>' + ToSize(rdata.used_memory) + '</td><td>Redis</td></tr>\ <tr><th>used_memory</th><td>' + toSize(rdata.used_memory) + '</td><td>Redis</td></tr>\
<tr><th>used_memory_peak</th><td>' + ToSize(rdata.used_memory_peak) + '</td><td>Redis</td></tr>\ <tr><th>used_memory_peak</th><td>' + toSize(rdata.used_memory_peak) + '</td><td>Redis</td></tr>\
<tr><th>mem_fragmentation_ratio</th><td>' + rdata.mem_fragmentation_ratio + '%</td><td></td></tr>\ <tr><th>mem_fragmentation_ratio</th><td>' + rdata.mem_fragmentation_ratio + '%</td><td></td></tr>\
<tr><th>total_connections_received</th><td>' + rdata.total_connections_received + '</td><td></td></tr>\ <tr><th>total_connections_received</th><td>' + rdata.total_connections_received + '</td><td></td></tr>\
<tr><th>total_commands_processed</th><td>' + rdata.total_commands_processed + '</td><td></td></tr>\ <tr><th>total_commands_processed</th><td>' + rdata.total_commands_processed + '</td><td></td></tr>\

@ -4,7 +4,7 @@
"name":"score", "name":"score",
"type":"扩展", "type":"扩展",
"ps":"测试服务器基础性能!", "ps":"测试服务器基础性能!",
"versions":"1.3", "versions": "1.3",
"shell":"install.sh", "shell":"install.sh",
"checks":"server/score", "checks":"server/score",
"author":"mdserver-web", "author":"mdserver-web",

@ -141,11 +141,14 @@ def checkInstalled():
return "False" return "False"
@plugins.route('/add_index', methods=['GET']) @plugins.route('/set_index', methods=['POST'])
def addIndex(): def setIndex():
name = request.args.get('name', '') name = request.form.get('name', '')
html = __plugin_name + '/' + name + '/index.html' status = request.form.get('status', '0')
return public.readFile(html) version = request.form.get('version', '')
if status == '1':
return plugin_api.plugin_api().addIndex(name, version)
return plugin_api.plugin_api().removeIndex(name, version)
@plugins.route('/setting', methods=['GET']) @plugins.route('/setting', methods=['GET'])

@ -1,5 +1,5 @@
//转换单们到MB //转换单们到MB
function ToSizeM(byteLen) { function toSizeM(byteLen) {
var a = parseInt(byteLen) / 1024 / 1024; var a = parseInt(byteLen) / 1024 / 1024;
return a || 0; return a || 0;
} }
@ -65,17 +65,6 @@ function pluginMan(name, title) {
}); });
} }
//设置插件
function SetPluginConfig(name, param, def) {
if (def == undefined) def = 'SetConfig';
loadT = layer.msg(lan.config.config_save, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/plugin?action=a&name=' + name + '&s=' + def, param, function(rdata) {
layer.close(loadT);
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
});
}
//取软件列表 //取软件列表
function GetSList(isdisplay) { function GetSList(isdisplay) {
if (isdisplay !== true) { if (isdisplay !== true) {
@ -134,8 +123,6 @@ function GetSList(isdisplay) {
var checked = ''; var checked = '';
checked = plugin.display ? 'checked' : ''; checked = plugin.display ? 'checked' : '';
console.log(plugin.versions);
if (typeof plugin.versions == "string"){ if (typeof plugin.versions == "string"){
version_info += plugin.versions + '|'; version_info += plugin.versions + '|';
@ -148,44 +135,42 @@ function GetSList(isdisplay) {
version_info = version_info.substring(0, version_info.length - 1); version_info = version_info.substring(0, version_info.length - 1);
} }
console.log(version_info);
var handle = '<a class="btlink" onclick="addVersion(\'' + plugin.name + '\',\'' + version_info + '\',\'' + plugin.tip + '\',this,\'' + plugin.title + '\')">安装</a>'; 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.setup == 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"';
// }
softPath = '<span class="glyphicon glyphicon-folder-open" title="' + plugin.path + '" onclick="openPath(\'' + plugin.path + '\')"></span>';
indexshow = '<div class="index-item"><input class="btswitch btswitch-ios" id="index_' + plugin.name + '" type="checkbox" ' + checked + '><label class="btswitch-btn" for="index_' + plugin.name + '" onclick="toIndexDisplay(\'' + plugin.name + '\',\'' + plugin.versions + '\')"></label></div>';
if (plugin.status == true) { if (plugin.status == true) {
isSetup = true; state = '<span style="color:#20a53a" class="glyphicon glyphicon-play"></span>'
// if (plugin.tip == 'lib') { } else {
// var mupdate = (plugin.versions[n].no == plugin.versions[n].version) ? '' : '<a class="btlink" onclick="SoftUpdate(\'' + plugin.name + '\',\'' + plugin.versions + '\',\'' + plugin.versions[n].version + '\')">更新</a> | '; state = '<span style="color:red" class="glyphicon glyphicon-pause"></span>'
// 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"';
// }
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>';
} }
} }
var plugin_title = plugin.title var isTask = plugin.task;
if (isSetup){ if (plugin.task == '-2') {
handle = '<a style="color:green;" href="javascript:task();">正在卸载...</a>';
} else 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>';
}
var plugin_title = plugin.title;
if (plugin.setup && !plugin.coexist){
plugin_title = plugin.title + ' ' + version_info; plugin_title = plugin.title + ' ' + version_info;
} }
@ -238,127 +223,32 @@ function softUpdate(name, version, update) {
}, msg); }, msg);
} }
//独立安装
function oneInstall(name, version) {
var isError = false
var optw = '';
if (name == 'mysql') {
optw = "<br><br><li style='color:red;'>" + lan.soft.mysql_f + "</li>"
var sUrl = '/data?action=getData&table=databases';
$.ajax({
url: sUrl,
type: "GET",
async: false,
success: function(dataD) {
if (dataD.data.length > 0) {
layer.msg(lan.soft.mysql_d, { icon: 5, time: 5000 })
isError = true;;
}
}
});
}
if (isError) return;
var one = layer.open({
type: 1,
title: '选择安装方式',
area: '350px',
closeBtn: 2,
shadeClose: true,
content: "<div class='bt-form pd20 pb70 c6'>\
<div class='version line'>安装版本<span style='margin-left:30px'>" + name + " " + version + "</span>" + optw + "</div>\
<div class='bt-form-submit-btn'>\
<button type='button' class='btn btn-danger btn-sm btn-title one-close'>关闭</button>\
<button type='button' id='bi-btn' class='btn btn-success btn-sm btn-title bi-btn'>提交</button>\
</div>\
</div>"
})
$('.fangshi input').click(function() {
$(this).attr('checked', 'checked').parent().siblings().find("input").removeAttr('checked');
});
$("#bi-btn").click(function() {
var type = $('.fangshi input').prop("checked") ? '1' : '0';
var data = "name=" + name + "&version=" + version + "&type=" + type;
var loadT = layer.msg(lan.soft.add_install, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/files?action=InstallSoft', data, function(rdata) {
layer.closeAll();
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
GetSList();
})
});
$(".one-close").click(function() {
layer.close(one);
})
InstallTips();
fly("bi-btn");
}
function addVersion(name, ver, type, obj, title) { function addVersion(name, ver, type, obj, title) {
// console.log(ver.indexOf('|'));
var SelectVersion = ''; var option = '';
// if (ver.indexOf('|') >= 0){ if (ver.indexOf('|') >= 0){
var titlename = name; var titlename = name;
var veropt = ver.split("|"); var veropt = ver.split("|");
var SelectVersion = '';
for (var i = 0; i < veropt.length; i++) { for (var i = 0; i < veropt.length; i++) {
SelectVersion += '<option>' + name + ' ' + veropt[i] + '</option>'; SelectVersion += '<option>' + name + ' ' + veropt[i] + '</option>';
} }
//} else { option = "<select id='SelectVersion' class='bt-input-text' style='margin-left:30px'>" + SelectVersion + "</select>";
// SelectVersion = ver; } else {
//} option = '<span id="SelectVersion">' + name + ' ' + ver + '</span>';
if (name == 'phpmyadmin' || name == 'nginx' || name == 'apache') {
var isError = false
$.ajax({
url: '/ajax?action=GetInstalled',
type: 'get',
async: false,
success: function(rdata) {
if (name == 'nginx') {
if (rdata.webserver != name.toLowerCase() && rdata.webserver != false) {
layer.msg(lan.soft.err_install1, { icon: 2 })
isError = true;
return;
}
}
if (name == 'apache') {
if (rdata.webserver != name.toLowerCase() && rdata.webserver != false) {
layer.msg(lan.soft.err_install2, { icon: 2 })
isError = true;
return;
}
}
if (name == 'phpmyadmin') {
if (rdata.php.length < 1) {
layer.msg(lan.soft.err_install3, { icon: 2 })
isError = true;
return;
}
if (!rdata.mysql.setup) {
layer.msg(lan.soft.err_install4, { icon: 2 })
isError = true;
return;
}
}
}
});
if (isError) return;
} }
layer.open({ layer.open({
type: 1, type: 1,
title: titlename + lan.soft.install_title, title: titlename + "软件安装",
area: '350px', area: '350px',
closeBtn: 2, closeBtn: 2,
shadeClose: true, shadeClose: true,
content: "<div class='bt-form pd20 pb70 c6'>\ content: "<div class='bt-form pd20 pb70 c6'>\
<div class='version line'>安装版本<select id='SelectVersion' class='bt-input-text' style='margin-left:30px'>" + SelectVersion + "</select></div>\ <div class='version line'>安装版本" + option + "</div>\
<div class='bt-form-submit-btn'>\ <div class='bt-form-submit-btn'>\
<button type='button' class='btn btn-danger btn-sm btn-title' onclick='layer.closeAll()'>" + lan.public.close + "</button>\ <button type='button' class='btn btn-danger btn-sm btn-title' onclick='layer.closeAll()'>关闭</button>\
<button type='button' id='bi-btn' class='btn btn-success btn-sm btn-title bi-btn'>" + lan.public.submit + "</button>\ <button type='button' id='bi-btn' class='btn btn-success btn-sm btn-title bi-btn'>提交</button>\
</div>\ </div>\
</div>" </div>"
}); });
@ -367,7 +257,11 @@ function addVersion(name, ver, type, obj, title) {
$(this).attr('checked', 'checked').parent().siblings().find("input").removeAttr('checked'); $(this).attr('checked', 'checked').parent().siblings().find("input").removeAttr('checked');
}); });
$("#bi-btn").click(function() { $("#bi-btn").click(function() {
var info = $("#SelectVersion").val().toLowerCase(); var info = $("#SelectVersion").val().toLowerCase();
if (info == ''){
info = $("#SelectVersion").text().toLowerCase();
}
var name = info.split(" ")[0]; var name = info.split(" ")[0];
var version = info.split(" ")[1]; var version = info.split(" ")[1];
var type = $('.fangshi input').prop("checked") ? '1' : '0'; var type = $('.fangshi input').prop("checked") ? '1' : '0';
@ -384,10 +278,8 @@ function addVersion(name, ver, type, obj, title) {
fly("bi-btn"); fly("bi-btn");
} }
//卸载软件 //卸载软件
function UninstallVersion(name, version, title) { function uninstallVersion(name, version, title) {
layer.confirm(msgTpl('您真的要卸载[{1}-{2}]吗?', [title, version]), { icon: 3, closeBtn: 2 }, function() { layer.confirm(msgTpl('您真的要卸载[{1}-{2}]吗?', [title, version]), { icon: 3, closeBtn: 2 }, function() {
var data = 'name=' + name + '&version=' + version; var data = 'name=' + name + '&version=' + version;
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] }); var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] });
@ -407,8 +299,10 @@ function toIndexDisplay(name, version) {
var verinfo = version.replace(/\./, ""); var verinfo = version.replace(/\./, "");
status = $("#index_" + name + verinfo).prop("checked") ? "0" : "1"; status = $("#index_" + name + verinfo).prop("checked") ? "0" : "1";
} }
var data = "name=" + name + "&status=" + status + "&version=" + version; var data = "name=" + name + "&status=" + status + "&version=" + version;
$.post("/plugins/set_plugin_status", data, function(rdata) { $.post("/plugins/set_index", data, function(rdata) {
if (rdata.status) { if (rdata.status) {
layer.msg(rdata.msg, { icon: 1 }) layer.msg(rdata.msg, { icon: 1 })
} }

Loading…
Cancel
Save