心理咨询网
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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. {include file='common/head.html'}
  2. <div class="layui-body">
  3. <div class="layui-tab layui-tab-brief" lay-filter="tab">
  4. <ul class="layui-tab-title">
  5. <li class="layui-this" lay-id="t1">在线更新</li>
  6. <li lay-id="t2">更新设置</li>
  7. </ul>
  8. <div class="layui-tab-content">
  9. <div class="layui-tab-item layui-show">
  10. <table class="layui-table">
  11. <thead>
  12. <tr>
  13. <th width="30">选择</th>
  14. <th>更新文件</th>
  15. <th>更新方式</th>
  16. <th>本地时间</th>
  17. <th>更新时间</th>
  18. </tr>
  19. </thead>
  20. <tbody id="upfile">
  21. {foreach $upfile(key,value)}
  22. <tr>
  23. <td><input type="checkbox" checked class="checkbox checkitem" lay-ignore name="list" value="[value->path]"></td>
  24. <td>[value->path]</td>
  25. <td>[value->type]</td>
  26. <td>[value->ltime]</td>
  27. <td>[value->ctime]</td>
  28. </tr>
  29. {/foreach}
  30. {if([$upfile] && get('action')=='local')}
  31. <tr>
  32. <td><input type="checkbox" class="checkbox" checked lay-ignore id="checkall" title="全选"></td>
  33. <td colspan="4">已下载更新:[num]个文件</td>
  34. </tr>
  35. {/if}
  36. </tbody>
  37. </table>
  38. {if(get('action')=='local')}
  39. <button class="layui-btn" id="check" data-url='{url./admin/Upgrade/check}'>重新检查</button>
  40. {else}
  41. <button class="layui-btn" id="check" data-url='{url./admin/Upgrade/check}' id="check">检查更新</button>
  42. {/if}
  43. <button class="layui-btn" {if(![$upfile])}style="display:none"{/if} id="update" data-url='{url./admin/Upgrade/update}'>执行更新</button>
  44. <button class="layui-btn" style="display:none" id="down" data-url='{url./admin/Upgrade/down}'>下载更新</button>
  45. </div>
  46. <div class="layui-tab-item">
  47. <form action="{url./admin/Config/index}" method="post" class="layui-form">
  48. <input type="hidden" name="formcheck" value="{$formcheck}" >
  49. <div class="layui-form-item">
  50. <label class="layui-form-label">更新分支</label>
  51. <div class="layui-input-inline">
  52. <select name="upgrade_branch">
  53. <option value="3.X" {if([$branch]=='3.X')}selected{/if}>3.X 稳定版</option>
  54. <option value="3.X.dev" {if([$branch]=='3.X.dev')}selected{/if} >3.X 测试版</option>
  55. </select>
  56. </div>
  57. </div>
  58. <div class="layui-form-item">
  59. <label class="layui-form-label">强制文件同步</label>
  60. <div class="layui-input-block">
  61. <input type="hidden" name="upgrade_force" value="0"><!-- 默认0 -->
  62. <input type="checkbox" name="upgrade_force" value="1" {if([$force])}checked{/if} lay-skin="switch" lay-text="开启|关闭">
  63. </div>
  64. <div class="layui-form-mid layui-word-aux">适用有部分文件更新失败或检查文件与官方一致性。</div>
  65. </div>
  66. <div class="layui-form-item">
  67. <div class="layui-input-block">
  68. <button class="layui-btn" lay-submit name="submit" value="upgrade">保存</button>
  69. <button type="reset" class="layui-btn layui-btn-primary">重选</button>
  70. </div>
  71. </div>
  72. </form>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. <script>
  78. //页面加载时检查更新
  79. $.ajax({
  80. type: 'GET',
  81. url: 'https://www.pbootcms.com/index.php?p=upgrade/check&version={APP_VERSION}.{RELEASE_TIME}.{$revise}&branch={$branch}&snuser={$snuser}&site={$site}',
  82. dataType: 'json',
  83. success: function (response, status) {
  84. if(response.code==1){
  85. $("#check").html($("#check").html()+'<span class="layui-badge-dot"></span>');
  86. }
  87. }
  88. });
  89. //检查更新
  90. $("#check").on("click",check);
  91. //下载更新
  92. $("#update").on("click",update);
  93. //下载更新
  94. $("#down").on("click",down);
  95. //检查更新
  96. function check(){
  97. var lyindex;
  98. layui.use('layer', function(){
  99. var layer = layui.layer;
  100. lyindex = layer.open({
  101. type: 1,
  102. title:'检查更新',
  103. closeBtn:0,
  104. content: '<div style="padding:20px 10px;"><img src="{APP_THEME_DIR}/layui/css/modules/layer/default/loading-0.gif">正在检查更新文件,请稍等...<div>'
  105. });
  106. });
  107. var url= $('#check').data('url');
  108. $.ajax({
  109. type: 'GET',
  110. url: url,
  111. dataType: 'json',
  112. success: function (response, status) {
  113. if(response.code==1){
  114. var data=response.data;
  115. if(!(data instanceof Array)){
  116. layer.close(lyindex);
  117. layer.msg(data, {icon: 1});
  118. }else{
  119. var html='';
  120. for(var i = 0; i < data.length; i++){
  121. html += '<tr><td><input type="checkbox" checked class="checkbox checkitem" lay-ignore name="list" value="'+data[i].path+'"></td><td>'+data[i].path+'</td><td>'+data[i].type+'</td><td>'+data[i].ltime+'</td><td>'+data[i].ctime+'</td></tr>';
  122. }
  123. html += '<tr><td><input type="checkbox" class="checkbox" checked lay-ignore id="checkall" title="全选"></td><td colspan="4">总共检测到 '+i+' 个文件</td></tr>';
  124. $("#upfile").html('');
  125. $("#upfile").append(html);
  126. layer.close(lyindex);
  127. layer.msg('共检测到 '+i+' 个文件需要更新!', {icon: 1});
  128. $('#update').hide();
  129. $('#down').show();
  130. }
  131. $('#check').text('重新检查');
  132. }else{
  133. layer.close(lyindex);
  134. layer.msg(response.data, {icon: 5});
  135. }
  136. },
  137. error:function(xhr,status,error){
  138. layer.close(lyindex);
  139. layer.msg("检查更新发生错误!", {icon: 5});
  140. }
  141. });
  142. }
  143. //下载更新
  144. function down(){
  145. var lyindex;
  146. var layer;
  147. layui.use('layer', function(){
  148. layer = layui.layer;
  149. lyindex = layer.open({
  150. type: 1,
  151. title:'下载更新',
  152. closeBtn:0,
  153. content: '<div style="padding:20px 10px;"><img src="{APP_THEME_DIR}/layui/css/modules/layer/default/loading-0.gif"><span id="layer-content">正在下载更新文件,请稍等...</span><div>'
  154. });
  155. });
  156. var url= $('#down').data('url');
  157. var checked = $(".checkitem:checked");
  158. var len = $(checked).length;
  159. var exe=0;
  160. $(checked).each(function(index,element){
  161. setTimeout(function () { //延迟执行、避免文件太多卡死问题
  162. $.ajax({
  163. type: 'GET',
  164. url: url,
  165. dataType: 'json',
  166. async:true,
  167. data: {
  168. list:$(element).val()
  169. },
  170. success: function (response, status) {
  171. if(response.code==1){
  172. exe++;
  173. $('#layer-content').text(response.data);
  174. }else{
  175. layer.close(lyindex);
  176. layer.msg(response.data, {icon: 5});
  177. }
  178. if(exe==len){
  179. layer.close(lyindex);
  180. layer.open({
  181. type: 0,
  182. title:'下载更新',
  183. closeBtn:0,
  184. btn: ['立即更新', '稍后更新'],
  185. content: '所选文件全部下载完成!',
  186. yes: function(index, layero){
  187. layer.close(index);
  188. $('#update').click();
  189. },
  190. btn2: function(index, layero){
  191. layer.close(index);
  192. window.location.href = '{url./admin/Upgrade/index/action/local}';
  193. }
  194. });
  195. $('#update').show();
  196. $('#down').hide();
  197. }
  198. },
  199. error:function(xhr,status,error){
  200. layer.close(lyindex);
  201. layer.msg("下载更新文件发生错误!", {icon: 5});
  202. }
  203. });
  204. }, index*1000);
  205. });
  206. }
  207. //执行更新
  208. function update(){
  209. var lyindex;
  210. var layer;
  211. layui.use('layer', function(){
  212. layer = layui.layer;
  213. lyindex = layer.open({
  214. type: 1,
  215. title:'执行更新',
  216. closeBtn:0,
  217. content: '<div style="padding:20px 10px;"><img src="{APP_THEME_DIR}/layui/css/modules/layer/default/loading-0.gif"><span id="layer-content">正在执行更新文件,请稍等...</span><div>'
  218. });
  219. });
  220. //由于涉及到数据库升级文件先后顺序,所以必须一次性提交
  221. var url= $('#update').data('url');
  222. var list='';
  223. $(".checkitem:checked").each(function(index,element){
  224. if(index==0){
  225. list += $(element).val();
  226. }else{
  227. list += ','+$(element).val();
  228. }
  229. });
  230. $.ajax({
  231. type: 'POST',
  232. url: url,
  233. dataType: 'json',
  234. data: {
  235. list:list
  236. },
  237. success: function (response, status) {
  238. if(response.code==1){
  239. layer.close(lyindex);
  240. layer.open({
  241. type: 0,
  242. title:'执行更新',
  243. closeBtn:0,
  244. content: '所选文件全部更新完成!',
  245. yes: function(index, layero){
  246. window.location.href = '{url./admin/Upgrade/index}';
  247. layer.close(index);
  248. }
  249. });
  250. }else{
  251. layer.close(lyindex);
  252. layer.msg(response.data, {icon: 5});
  253. }
  254. },
  255. error:function(xhr,status,error){
  256. layer.msg("执行更新文件发生错误!", {icon: 5});
  257. }
  258. });
  259. }
  260. //选择全部
  261. $("#upfile").on("click","#checkall", function () {
  262. if($(this).prop("checked")){
  263. $(".checkitem:enabled").prop("checked", true);
  264. }else{
  265. $(".checkitem").prop("checked", false);
  266. }
  267. });
  268. </script>
  269. {include file='common/foot.html'}