install.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <section class="section">
  2. <div class="step">
  3. <ul>
  4. <li class="on"><em>1</em>检测环境</li>
  5. <li class="on"><em>2</em>创建数据</li>
  6. <li class="current"><em>3</em>完成安装</li>
  7. </ul>
  8. </div>
  9. <div class="install" id="log">
  10. <ul id="log-inner"></ul>
  11. </div>
  12. <div class="bottom tac">
  13. <a href="javascript:" class="btn_old">
  14. <img src="{__INSTALL_PATH__}/images/loading.gif" align="absmiddle"/>
  15. <span style="color: #fff">正在安装...</span>
  16. </a>
  17. </div>
  18. </section>
  19. <script type="text/javascript">
  20. $.ajaxSetup({cache: false});
  21. $(document).ready(function () {
  22. reloads();
  23. });
  24. function reloads(next, type) {
  25. $.ajax({
  26. type: "post",
  27. url: next || "{:str_replace('/install/','/',createUrl('index/install'))}",
  28. data: {type: type},
  29. dataType: "json",
  30. success: function (res) {
  31. try {
  32. if (res.code && res.data) {
  33. if (res.msg) {
  34. insert_log(res.msg);
  35. }
  36. if (res.data.status) {
  37. reloads(res.url, res.data.type);
  38. } else {
  39. setTimeout(function () {
  40. self.location.href = res.url;
  41. }, 2000);
  42. }
  43. } else {
  44. insert_log(res.msg, true);
  45. }
  46. } catch(e) {
  47. insert_log(e.message, true);
  48. }
  49. },
  50. error: function (err) {
  51. insert_log('网络请求错误或内部服务器错误:', true);
  52. console.info('error:' + err.responseText);
  53. }
  54. });
  55. }
  56. function dateFormat(fmt) {
  57. const date = new Date();
  58. let format = fmt || "mm-dd HH:MM:SS";
  59. const opt = {
  60. "Y+": date.getFullYear().toString(), // 年
  61. "m+": (date.getMonth() + 1).toString(), // 月
  62. "d+": date.getDate().toString(), // 日
  63. "H+": date.getHours().toString(), // 时
  64. "M+": date.getMinutes().toString(), // 分
  65. "S+": date.getSeconds().toString() // 秒
  66. };
  67. if (/(y+)/.test(format)) {
  68. format.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
  69. }
  70. for (let k in opt) {
  71. if (new RegExp("(" + k + ")").test(format)) {
  72. format = format.replace(RegExp.$1, RegExp.$1.length === 1
  73. ? opt[k]
  74. : ("00" + opt[k]).substr(("" + opt[k]).length));
  75. }
  76. }
  77. return format;
  78. }
  79. function insert_log(msg, error) {
  80. let date = dateFormat();
  81. const icon = error ? "icon_error" : "icon_check";
  82. const message = '<li><i class="' + icon + '"/>' + msg + '<span class="fr">' + date + '</span></li>';
  83. $("#log-inner").append(message);
  84. $("#log").scrollTop(function () {
  85. return $(this)[0].scrollHeight
  86. });
  87. }
  88. </script>