You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

280 lines
9.4 KiB

1 year ago
1 year ago
3 months ago
1 year ago
1 year ago
  1. {extend name="admin/layout" /}
  2. {block name="title"}插件列表{/block}
  3. {block name="main"}
  4. <style>
  5. td{overflow: hidden;text-overflow: ellipsis;white-space: nowrap;max-width:340px;}
  6. .bt-ico-ask {
  7. border: 1px solid #fb7d00;
  8. border-radius: 8px;
  9. color: #fb7d00;
  10. cursor: help;
  11. display: inline-block;
  12. font-family: arial;
  13. font-size: 11px;
  14. font-style: normal;
  15. height: 16px;
  16. line-height: 16px;
  17. margin-left: 5px;
  18. text-align: center;
  19. width: 16px
  20. }
  21. .bt-ico-ask:hover {
  22. background-color: #fb7d00;
  23. color: #fff
  24. }
  25. </style>
  26. <div class="modal fade" id="help" tabindex="-1" role="dialog">
  27. <div class="modal-dialog" role="document">
  28. <div class="modal-content">
  29. <div class="modal-header">
  30. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  31. <span aria-hidden="true">&times;</span>
  32. </button>
  33. <h4 class="modal-title">帮助</h4>
  34. </div>
  35. <div class="modal-body">
  36. <p>“版本与状态”一列中,红色的按钮代表本地不存在该版本插件包,需要点击下载;绿色的按钮代表已存在。</p>
  37. <p>官方插件包本地存储路径是/data/plugins/package/软件标识-版本号.zip,第三方插件包路径是/data/plugins/other/other/,对于部分包含二次验证的插件可以自行修改。</p>
  38. </div>
  39. <div class="modal-footer">
  40. <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. <div class="container" style="padding-top:70px;">
  46. <div class="col-xs-12 center-block" style="float: none;">
  47. <div id="searchToolbar">
  48. <form onsubmit="return searchSubmit()" method="GET" class="form-inline">
  49. <div class="form-group">
  50. <label>搜索</label>
  51. <input type="text" class="form-control" name="keyword" placeholder="应用名称">
  52. </div>
  53. <div class="form-group">
  54. <select name="type" class="form-control"><option value="0">全部插件</option>
  55. {foreach $typelist as $k=>$v}<option value="{$k}">{$v}</option>{/foreach} </select>
  56. </div>
  57. <div class="form-group">
  58. <button class="btn btn-primary" type="submit"><i class="fa fa-search"></i> 搜索</button>&nbsp;
  59. <a href="javascript:searchClear()" class="btn btn-default"><i class="fa fa-repeat"></i> 重置</a>&nbsp;
  60. <a href="javascript:refresh_plugins()" class="btn btn-success"><i class="fa fa-refresh"></i> 刷新列表</a>&nbsp;
  61. <a href="javascript:download_plugins()" class="btn btn-warning" id="batch_down" style="display:none;"><i class="fa fa-download"></i> 批量下载</a>&nbsp;
  62. <button type="button" class="btn btn-default" data-toggle="modal" data-target="#help"><i class="fa fa-info-circle"></i> 帮助</button>
  63. </div>
  64. </form>
  65. </div>
  66. <table id="listTable">
  67. </table>
  68. </div>
  69. </div>
  70. <script src="{$cdnpublic}layer/3.5.1/layer.js"></script>
  71. <script src="{$cdnpublic}bootstrap-table/1.19.1/bootstrap-table.min.js"></script>
  72. <script src="{$cdnpublic}bootstrap-table/1.19.1/extensions/page-jump-to/bootstrap-table-page-jump-to.min.js"></script>
  73. <script src="/static/js/custom.js"></script>
  74. <script>
  75. function download_version(name, version, status){
  76. if(status == true){
  77. var confirm = layer.confirm('是否确定重新下载'+version+'版本插件包?', {
  78. btn: ['确定','取消']
  79. }, function(){
  80. download_plugin(name, version)
  81. }, function(){
  82. layer.close(confirm)
  83. });
  84. }else{
  85. download_plugin(name, version)
  86. }
  87. }
  88. function download_plugin(name, version){
  89. var ii = layer.msg('正在下载,请稍候...', {icon: 16, shade:0.1, time: 0});
  90. $.ajax({
  91. type : 'POST',
  92. url : '/admin/download_plugin',
  93. data: { name:name, version:version},
  94. dataType : 'json',
  95. success : function(data) {
  96. layer.close(ii)
  97. if(data.code == 0){
  98. layer.alert(data.msg, {icon:1}, function(){layer.closeAll();searchSubmit();});
  99. }else{
  100. layer.alert(data.msg, {icon:2});
  101. }
  102. },
  103. error:function(data){
  104. layer.close(ii)
  105. layer.msg('服务器错误', {icon:2});
  106. }
  107. });
  108. }
  109. function refresh_plugins(){
  110. var confirm = layer.confirm('是否确定从宝塔官方获取最新插件列表?', {
  111. btn: ['确定','取消']
  112. }, function(){
  113. layer.close(confirm)
  114. var ii = layer.msg('正在获取插件列表,请稍候...', {icon: 16, shade:0.1, time: 0});
  115. $.ajax({
  116. type : 'GET',
  117. url : '/admin/refresh_plugins',
  118. dataType : 'json',
  119. success : function(data) {
  120. layer.close(ii)
  121. if(data.code == 0){
  122. layer.alert(data.msg, {icon:1}, function(){layer.closeAll();searchSubmit();});
  123. }else{
  124. layer.alert(data.msg, {icon:2});
  125. }
  126. },
  127. error:function(data){
  128. layer.close(ii)
  129. layer.msg('服务器错误', {icon:2});
  130. }
  131. });
  132. }, function(){
  133. layer.close(confirm)
  134. });
  135. }
  136. function download_plugins(){
  137. var confirm = layer.confirm('批量下载当前分类下未下载的插件包', {
  138. btn: ['确定','取消']
  139. }, function(){
  140. layer.close(confirm)
  141. $.downloadCount = 0;
  142. $.preDownloadCount = $.preDownload.length;
  143. download_item();
  144. }, function(){
  145. layer.close(confirm)
  146. });
  147. }
  148. function download_item(){
  149. if($.preDownload.length == 0){
  150. layer.alert('成功下载'+$.downloadCount+'个插件包!', {icon:1}, function(){layer.closeAll();searchSubmit();});
  151. return;
  152. }
  153. var plugin = $.preDownload[0];
  154. if(plugin.name == 'firewall'){
  155. $.preDownload.shift();
  156. download_item();
  157. return;
  158. }
  159. $.downloadCount++;
  160. var ii = layer.msg('['+$.downloadCount+'/'+$.preDownloadCount+']正在下载'+plugin.name+'-'+plugin.version, {icon: 16, shade:0.1, time: 0});
  161. $.ajax({
  162. type : 'POST',
  163. url : '/admin/download_plugin',
  164. data: { name:plugin.name, version:plugin.version},
  165. dataType : 'json',
  166. success : function(data) {
  167. layer.close(ii)
  168. if(data.code == 0){
  169. $.preDownload.shift();
  170. download_item();
  171. }else{
  172. layer.alert(data.msg, {icon:2});
  173. }
  174. },
  175. error:function(data){
  176. layer.close(ii)
  177. layer.msg('服务器错误', {icon:2});
  178. }
  179. });
  180. }
  181. function searchByType(type){
  182. $("input[name=keyword]").val('');
  183. $("select[name=type]").val(type);
  184. searchSubmit()
  185. }
  186. $(document).ready(function(){
  187. updateToolbar();
  188. const defaultPageSize = 20;
  189. $("#listTable").bootstrapTable({
  190. url: '/admin/plugins_data',
  191. pageNumber: 1,
  192. pageSize: 15,
  193. sidePagination: 'client',
  194. classes: 'table table-striped table-hover table-bottom-border',
  195. columns: [
  196. {
  197. field: 'name',
  198. title: '软件标识',
  199. formatter: function(value, row, index) {
  200. return '<b>'+value+'</b>';
  201. }
  202. },
  203. {
  204. field: 'title',
  205. title: '软件名称'
  206. },
  207. {
  208. field: 'type',
  209. title: '软件分类',
  210. formatter: function(value, row, index) {
  211. return '<a href="javascript:searchByType('+value+')" title="查看该分类下的插件">'+row.typename+'</a>';
  212. }
  213. },
  214. {
  215. field: 'desc',
  216. title: '说明',
  217. },
  218. {
  219. field: 'price',
  220. title: '价格',
  221. formatter: function(value, row, index) {
  222. return value > 0 ? '<span style="color:#fc6d26">¥'+value+'</span>' : '免费';
  223. }
  224. },
  225. {
  226. field: 'author',
  227. title: '开发商'
  228. },
  229. {
  230. field: 'versions',
  231. title: '版本与状态',
  232. formatter: function(value, row, index) {
  233. var html = '';
  234. if(row.type == 5){
  235. html += '<a href="javascript:" class="btn btn-xs btn-success" disabled>无需下载</a>';
  236. }else{
  237. $.each(value, function(index,item){
  238. if(item.status)
  239. html += '<a href="javascript:download_version(\''+row.name+'\',\''+item.version+'\','+item.status+')" class="btn btn-xs btn-success">'+item.version+'</a>&nbsp;';
  240. else
  241. html += '<a href="javascript:download_version(\''+row.name+'\',\''+item.version+'\','+item.status+')" class="btn btn-xs btn-danger">'+item.version+'</a>&nbsp;';
  242. })
  243. }
  244. return html
  245. }
  246. },
  247. ],
  248. onLoadSuccess: function(data){
  249. $.preDownload = [];
  250. var type = $("select[name=type] option:selected").text();
  251. if(type != '全部插件' && type != '运行环境' && type != '第三方应用'){
  252. $("#batch_down").show();
  253. if(data.length > 0){
  254. $.each(data, function(index, plugin){
  255. if(plugin.versions.length > 0){
  256. $.each(plugin.versions, function(index, version){
  257. if(!version.status){
  258. $.preDownload.push({name:plugin.name, version:version.version})
  259. }
  260. });
  261. }
  262. });
  263. }
  264. }else{
  265. $("#batch_down").hide();
  266. }
  267. }
  268. })
  269. })
  270. </script>
  271. {/block}