国内流行的内容管理系统(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.

132 lines
3.4KB

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