国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
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.

130 lines
3.4KB

  1. var currentStep = 1;
  2. var hasNewVer = false;
  3. function dedeAlter(msg, t = 'info', loading = false) {
  4. let loadingStr = loading ? '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>' : '';
  5. return `<div class="alert alert-${t}">${loadingStr}
  6. ${msg}
  7. </div>`;
  8. }
  9. function showStepArea(step) {
  10. $(".stepArea").hide();
  11. $(".btnStep").hide();
  12. $("#stepArea" + step).show();
  13. $("#btnStep" + step).show();
  14. }
  15. function update() {
  16. $.get("api.php?action=update", function(rs) {
  17. if (rs.code === 0) {
  18. $("#_updateMsg").html(rs.msg);
  19. if (rs.data.finish === false) {
  20. setTimeout(() => {
  21. update();
  22. }, 500);
  23. } else {
  24. currentStep++
  25. $("#_msgInfo").html('');
  26. $("#_msgInfo").hide();
  27. showStepArea(currentStep);
  28. }
  29. }
  30. });
  31. }
  32. function hasNewVersion() {
  33. $.get("api.php?action=has_new_version", function(rs) {
  34. try {
  35. if (rs.code === 0) {
  36. if (rs.result.HasNew === true) {
  37. hasNewVer = true;
  38. $(".updates-dot").show();
  39. } else {
  40. hasNewVer = false;
  41. $(".updates-dot").hide();
  42. }
  43. } else {
  44. $(".updates-dot").hide();
  45. showStepArea(0);
  46. }
  47. } catch (error) {
  48. console.log("获取软件信息失败");
  49. }
  50. });
  51. }
  52. $(document).ready(function() {
  53. hasNewVersion();
  54. $("#btnCancel").click(function() {
  55. currentStep = 1;
  56. $("#_fileList").html(``);
  57. })
  58. $("#btnBackup").click(function() {
  59. let alertMsg = dedeAlter("正在备份差异文件", 'info', true);
  60. $("#_msgInfo").html(alertMsg);
  61. $("#_msgInfo").show();
  62. $.get("api.php?action=update_backup", function(rs) {
  63. if (rs.code === 0) {
  64. alertMsg = dedeAlter(`成功备份差异文件,目录:${rs.data.backupdir}`, 'success');
  65. $("#_msgInfo").html(alertMsg);
  66. }
  67. });
  68. });
  69. $("#systemUpdate").click(function() {
  70. if (hasNewVer === false) {
  71. currentStep = 5;
  72. showStepArea(currentStep);
  73. $("#mdlUpdate").modal("show");
  74. return;
  75. }
  76. $("#mdlUpdate").modal("show");
  77. showStepArea(currentStep);
  78. currentStep++;
  79. $.get("api.php?action=get_changed_files", function(rs) {
  80. if (rs.code === 0) {
  81. let fstr = '<ul class="list-group list-group-flush">';
  82. let i = 1;
  83. rs.data.files.forEach(file => {
  84. fstr += `<li class='list-group-item'>第${i}个文件:${file['filename']}</li>`;
  85. i++;
  86. });
  87. fstr += '</ul>';
  88. $("#_fileList").html(fstr);
  89. showStepArea(currentStep);
  90. } else {
  91. showStepArea(0);
  92. }
  93. });
  94. });
  95. $('#mdlUpdate').on('hidden.bs.modal', function(event) {
  96. currentStep = 1;
  97. $("#_msgInfo").html('');
  98. $("#_msgInfo").hide();
  99. })
  100. $("#btnGoStep3").click(function() {
  101. currentStep++
  102. $("#_msgInfo").html('');
  103. $("#_msgInfo").hide();
  104. showStepArea(currentStep);
  105. $.get("api.php?action=get_update_versions", function(rs) {
  106. if (rs.code === 0) {
  107. let fstr = '<ul class="list-group list-group-flush">';
  108. let i = 1;
  109. rs.result.Versions.forEach(ver => {
  110. fstr += `<li class='list-group-item'>版本号:${ver.ver},发布日期:${ver.r} <a href='https://www.zhelixie.com/DedeBIZ/DedeV6/commits/tag/${ver.ver}' class='btn btn-outline-success btn-sm float-right' target='_blank'>更新记录</a></li>`;
  111. i++;
  112. });
  113. fstr += '</ul>';
  114. $("#_verList").html(fstr);
  115. } else {
  116. showStepArea(0);
  117. }
  118. });
  119. });
  120. $("#btnGoStep4").click(function() {
  121. currentStep++
  122. $("#_msgInfo").html('');
  123. $("#_msgInfo").hide();
  124. showStepArea(currentStep);
  125. update();
  126. })
  127. $("#btnOK").click(function() {
  128. hasNewVersion();
  129. });
  130. });