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.

213 lines
7.1 KiB

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. <p>点击【重新获取】按钮会从宝塔官方获取最新插件列表,但是插件包需要手动点击下载。如果需要批量下载插件包,可查看<a href="/admin/set/mod/task">定时任务设置</a></p>
  39. </div>
  40. <div class="modal-footer">
  41. <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. <div class="container" style="padding-top:70px;">
  47. <div class="col-xs-12 center-block" style="float: none;">
  48. <div id="searchToolbar">
  49. <form onsubmit="return searchSubmit()" method="GET" class="form-inline">
  50. <div class="form-group">
  51. <label>搜索</label>
  52. <input type="text" class="form-control" name="keyword" placeholder="应用名称">
  53. </div>
  54. <div class="form-group">
  55. <select name="type" class="form-control"><option value="0">全部插件</option>
  56. {foreach $typelist as $k=>$v}<option value="{$k}">{$v}</option>{/foreach} </select>
  57. </div>
  58. <div class="form-group">
  59. <button class="btn btn-primary" type="submit"><i class="fa fa-search"></i>搜索</button>&nbsp;
  60. <a href="javascript:searchClear()" class="btn btn-default"><i class="fa fa-repeat"></i>重置</a>&nbsp;
  61. <a href="javascript:refresh_plugins()" class="btn btn-success"><i class="fa fa-refresh"></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="//cdn.staticfile.org/layer/3.5.1/layer.js"></script>
  71. <script src="//cdn.staticfile.org/bootstrap-table/1.20.2/bootstrap-table.min.js"></script>
  72. <script src="//cdn.staticfile.org/bootstrap-table/1.20.2/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 searchByType(type){
  137. $("input[name=keyword]").val('');
  138. $("select[name=type]").val(type);
  139. searchSubmit()
  140. }
  141. $(document).ready(function(){
  142. updateToolbar();
  143. const defaultPageSize = 20;
  144. $("#listTable").bootstrapTable({
  145. url: '/admin/plugins_data?os=Windows',
  146. pageNumber: 1,
  147. pageSize: 15,
  148. sidePagination: 'client',
  149. classes: 'table table-striped table-hover table-bottom-border',
  150. columns: [
  151. {
  152. field: 'name',
  153. title: '软件标识',
  154. formatter: function(value, row, index) {
  155. return '<b>'+value+'</b>';
  156. }
  157. },
  158. {
  159. field: 'title',
  160. title: '软件名称'
  161. },
  162. {
  163. field: 'type',
  164. title: '软件分类',
  165. formatter: function(value, row, index) {
  166. return '<a href="javascript:searchByType('+value+')" title="查看该分类下的插件">'+row.typename+'</a>';
  167. }
  168. },
  169. {
  170. field: 'desc',
  171. title: '说明',
  172. },
  173. {
  174. field: 'price',
  175. title: '价格',
  176. formatter: function(value, row, index) {
  177. return value > 0 ? '<span style="color:#fc6d26">¥'+value+'</span>' : '免费';
  178. }
  179. },
  180. {
  181. field: 'author',
  182. title: '开发商'
  183. },
  184. {
  185. field: 'versions',
  186. title: '版本与状态',
  187. formatter: function(value, row, index) {
  188. var html = '';
  189. if(row.type == 5){
  190. html += '<a href="javascript:" class="btn btn-xs btn-success" disabled>无需下载</a>';
  191. }else{
  192. $.each(value, function(index,item){
  193. if(item.status)
  194. html += '<a href="javascript:download_version(\''+row.name+'\',\''+item.version+'\','+item.status+')" class="btn btn-xs btn-success">'+item.version+'</a>&nbsp;';
  195. else
  196. html += '<a href="javascript:download_version(\''+row.name+'\',\''+item.version+'\','+item.status+')" class="btn btn-xs btn-danger">'+item.version+'</a>&nbsp;';
  197. })
  198. }
  199. return html
  200. }
  201. },
  202. ],
  203. })
  204. })
  205. </script>
  206. {/block}