update.html 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <!DOCTYPE html>
  2. <html lang="zh_CN">
  3. <head>
  4. <title>软件更新 - U企云服</title>
  5. <style>
  6. body {
  7. margin: 0;
  8. font-family: 'Microsoft YaHei';
  9. font-size: 16px;
  10. overflow: hidden;
  11. }
  12. .block {
  13. position: relative;
  14. transition: .2s;
  15. padding: 24px;
  16. }
  17. .progress {
  18. position: relative;
  19. line-height: 1;
  20. }
  21. .progress-circle {
  22. height: 126px;
  23. width: 126px;
  24. margin: 103px auto;
  25. }
  26. .progress-text {
  27. position: absolute;
  28. top: 50%;
  29. left: 0;
  30. width: 100%;
  31. text-align: center;
  32. color: #606266;
  33. display: inline-block;
  34. vertical-align: middle;
  35. line-height: 1;
  36. transform: translateY(-50%);
  37. }
  38. .message {
  39. position: absolute;
  40. bottom: 20px;
  41. left: 0;
  42. width: 100%;
  43. text-align: center;
  44. color: #9c9c9c;
  45. }
  46. </style>
  47. </head>
  48. <body>
  49. <div class="block">
  50. <div class="progress">
  51. <div class="progress-circle">
  52. <svg viewBox="0 0 100 100">
  53. <path d="M 50 50 m 0 -47 a 47 47 0 1 1 0 94 a 47 47 0 1 1 0 -94" stroke="#e5e9f2" stroke-width="4.8" fill="none" class="progress-circle-track"></path>
  54. <path d="M 50 50 m 0 -47 a 47 47 0 1 1 0 94 a 47 47 0 1 1 0 -94" stroke-linecap="round" stroke="#20a0ff" stroke-width="4.8" fill="none" class="progress-circle-path"
  55. style="stroke-dasharray: 299.08px, 299.08px; stroke-dashoffset: 299.08px; transition: stroke-dashoffset 0.6s ease 0s, stroke 0.6s ease 0s;"></path>
  56. </svg>
  57. </div>
  58. <div class="progress-text">0%</div>
  59. </div>
  60. <div class="message">
  61. <span class="version"></span><span class="action">正在更新</span>,请稍等
  62. </div>
  63. </div>
  64. <script>
  65. const ipcRenderer = require('electron').ipcRenderer;
  66. ipcRenderer.on("message", (event, text) => {
  67. document.querySelector('.version').innerHTML = '版本' + text.version;
  68. });
  69. ipcRenderer.on("downloadProgress", (event, progressObj)=> {
  70. const percent = Math.round(progressObj.percent || 0);
  71. const pathEl = document.querySelector('.progress-circle-path');
  72. pathEl.style.strokeDashoffset = 299.08*(1 - percent/100) + 'px';
  73. if (percent >= 100) {
  74. pathEl.style.stroke = '#13ce66';
  75. document.querySelector('.action').innerHTML = '下载完毕,准备安装';
  76. } else if (percent >= 50) {
  77. pathEl.style.stroke = '#8e71c7';
  78. }
  79. const textEl = document.querySelector('.progress-text');
  80. textEl.innerHTML = percent >= 100 ? '√' : (percent + '%');
  81. });
  82. </script>
  83. </body>
  84. </html>