SoftwareUpdate.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <div class="software-update">
  3. <el-dialog
  4. title="正在下载新版本,请稍候......"
  5. :visible.sync="centerDialogVisible"
  6. width="50%"
  7. :show-close=false
  8. :close-on-click-modal=false
  9. :close-on-press-escape=false
  10. >
  11. <el-progress :percentage="uploadPercent"></el-progress>
  12. </el-dialog>
  13. </div>
  14. </template>
  15. <script>
  16. import mixin from '../mixin'
  17. export default {
  18. mixins: [mixin],
  19. created () {
  20. this.$electron.ipcRenderer.send('checkForUpdate')
  21. this.$electron.ipcRenderer.on('msgBox', (event, status) => {
  22. if (status === 2) {
  23. this.openUpdateDialog()
  24. }
  25. })
  26. this.$electron.ipcRenderer.on('isUpdateNow', function (event, index) {
  27. event.sender.send('isUpdateNow')
  28. })
  29. },
  30. data () {
  31. return {
  32. uploadPercent: 0,
  33. centerDialogVisible: false
  34. }
  35. },
  36. methods: {
  37. openUpdateDialog () {
  38. this.$confirm('更新内容:1:添加XXX功能<br>' +
  39. '2:修改XXXbug<br>' +
  40. '3:提高了响应速度', '新版本更新提示', {
  41. confirmButtonText: '马上更新',
  42. cancelButtonText: '稍后再说',
  43. center: true,
  44. showClose: false,
  45. closeOnClickModal: false,
  46. dangerouslyUseHTMLString: true
  47. }).then(() => {
  48. setTimeout(() => {
  49. this.ProcessDialog()
  50. }, 200)
  51. }).catch(() => {
  52. })
  53. },
  54. ProcessDialog () {
  55. this.$electron.ipcRenderer.send('downloadUpdate')
  56. this.centerDialogVisible = true
  57. this.$electron.ipcRenderer.on('downloadProgress', (event, progressObj) => {
  58. this.uploadPercent = parseInt(progressObj.percent)
  59. })
  60. }
  61. }
  62. }
  63. </script>