index.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <div class="fs-12 p-2">
  3. <div>
  4. {{ stateData[state1].msg }}
  5. </div>
  6. <div class="mt-1 text-view1 pl-2" v-if="state1 == 3">
  7. <el-progress :percentage="percent" class="w-100" color="#67c23a"></el-progress>
  8. </div>
  9. </div>
  10. </template>
  11. <script>
  12. import { mapActions } from 'vuex'
  13. import { ipcRenderer } from 'electron'
  14. export default {
  15. name: 'Settingwin',
  16. data() {
  17. return {
  18. webURL: '',
  19. stateData: [{ code: 0, msg: '正在查询更新...' },
  20. { code: 1, msg: '更新出错,请重启软件' },
  21. { code: 2, msg: '无更新可用' },
  22. { code: 3, msg: '发现有新版本,正在下载' },
  23. { code: 4, msg: '下载完成,重启更新' },
  24. { code: 5, msg: '未设置更新地址' }
  25. ],
  26. state1: 0,
  27. percent: 0,
  28. }
  29. },
  30. created() {
  31. let locationpath = localStorage.getItem('locationpath') ? JSON.parse(localStorage.getItem('locationpath')) : {}
  32. this.baseURL = locationpath.baseURL || '';
  33. this.webURL = locationpath.webURL || '';
  34. this.get1()
  35. this.get2()
  36. this.sendurl()
  37. // console.log(this.$router)
  38. },
  39. methods: {
  40. ...mapActions({
  41. getlocationpath: 'user/getlocationpath',
  42. }),
  43. sendurl(){
  44. console.log(111,this.webURL)
  45. ipcRenderer.send('sendurl',{url:this.webURL})
  46. },
  47. get1() {
  48. let t = this
  49. ipcRenderer.on('state1', (event, data) => {
  50. t.state1 = data
  51. // console.log(59, data, t.state1)
  52. })
  53. },
  54. get2() {
  55. let t = this
  56. ipcRenderer.on('downloadProgress', (event, data) => {
  57. t.percent = (data.percent).toFixed(1);
  58. console.log(t.percent)
  59. if (data.percent >= 100) {
  60. t.state1 = 4;
  61. }
  62. })
  63. },
  64. }
  65. }
  66. </script>
  67. <style lang="less" scoped>
  68. .bg {
  69. background: #fff;
  70. padding: 20px;
  71. border-radius: 50%;
  72. }
  73. </style>