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.

275 lines
9.3 KiB

1 year ago
1 year ago
4 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/win/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, os:'Windows'},
  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?os=Windows',
  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. $.downloadCount++;
  154. var plugin = $.preDownload[0];
  155. var ii = layer.msg('['+$.downloadCount+'/'+$.preDownloadCount+']正在下载'+plugin.name+'-'+plugin.version, {icon: 16, shade:0.1, time: 0});
  156. $.ajax({
  157. type : 'POST',
  158. url : '/admin/download_plugin',
  159. data: { name:plugin.name, version:plugin.version, os:'Windows'},
  160. dataType : 'json',
  161. success : function(data) {
  162. layer.close(ii)
  163. if(data.code == 0){
  164. $.preDownload.shift();
  165. download_item();
  166. }else{
  167. layer.alert(data.msg, {icon:2});
  168. }
  169. },
  170. error:function(data){
  171. layer.close(ii)
  172. layer.msg('服务器错误', {icon:2});
  173. }
  174. });
  175. }
  176. function searchByType(type){
  177. $("input[name=keyword]").val('');
  178. $("select[name=type]").val(type);
  179. searchSubmit()
  180. }
  181. $(document).ready(function(){
  182. updateToolbar();
  183. const defaultPageSize = 20;
  184. $("#listTable").bootstrapTable({
  185. url: '/admin/plugins_data?os=Windows',
  186. pageNumber: 1,
  187. pageSize: 15,
  188. sidePagination: 'client',
  189. classes: 'table table-striped table-hover table-bottom-border',
  190. columns: [
  191. {
  192. field: 'name',
  193. title: '软件标识',
  194. formatter: function(value, row, index) {
  195. return '<b>'+value+'</b>';
  196. }
  197. },
  198. {
  199. field: 'title',
  200. title: '软件名称'
  201. },
  202. {
  203. field: 'type',
  204. title: '软件分类',
  205. formatter: function(value, row, index) {
  206. return '<a href="javascript:searchByType('+value+')" title="查看该分类下的插件">'+row.typename+'</a>';
  207. }
  208. },
  209. {
  210. field: 'desc',
  211. title: '说明',
  212. },
  213. {
  214. field: 'price',
  215. title: '价格',
  216. formatter: function(value, row, index) {
  217. return value > 0 ? '<span style="color:#fc6d26">¥'+value+'</span>' : '免费';
  218. }
  219. },
  220. {
  221. field: 'author',
  222. title: '开发商'
  223. },
  224. {
  225. field: 'versions',
  226. title: '版本与状态',
  227. formatter: function(value, row, index) {
  228. var html = '';
  229. if(row.type == 5){
  230. html += '<a href="javascript:" class="btn btn-xs btn-success" disabled>无需下载</a>';
  231. }else{
  232. $.each(value, function(index,item){
  233. if(item.status)
  234. html += '<a href="javascript:download_version(\''+row.name+'\',\''+item.version+'\','+item.status+')" class="btn btn-xs btn-success">'+item.version+'</a>&nbsp;';
  235. else
  236. html += '<a href="javascript:download_version(\''+row.name+'\',\''+item.version+'\','+item.status+')" class="btn btn-xs btn-danger">'+item.version+'</a>&nbsp;';
  237. })
  238. }
  239. return html
  240. }
  241. },
  242. ],
  243. onLoadSuccess: function(data){
  244. $.preDownload = [];
  245. var type = $("select[name=type] option:selected").text();
  246. if(type != '全部插件' && type != '运行环境' && type != '第三方应用'){
  247. $("#batch_down").show();
  248. if(data.length > 0){
  249. $.each(data, function(index, plugin){
  250. if(plugin.versions.length > 0){
  251. $.each(plugin.versions, function(index, version){
  252. if(!version.status){
  253. $.preDownload.push({name:plugin.name, version:version.version})
  254. }
  255. });
  256. }
  257. });
  258. }
  259. }else{
  260. $("#batch_down").hide();
  261. }
  262. }
  263. })
  264. })
  265. </script>
  266. {/block}