App.vue 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <div id="app">
  3. <router-view />
  4. <el-dialog
  5. v-if="dialogVisible"
  6. :title="$t('notificationProps.title')"
  7. :visible.sync="dialogVisible"
  8. width="320px"
  9. custom-class="message_refresh"
  10. :close-on-click-modal="false"
  11. top="0vh"
  12. >
  13. <span>{{ $t('notificationProps.description') }}</span>
  14. <span slot="footer" class="dialog-footer">
  15. <el-button @click="dialogVisible = false">{{ $t('notificationProps.cancelButtonText') }}</el-button>
  16. <el-button type="primary" @click="notificationRefresh">{{ $t('notificationProps.confirmButtonText') }}</el-button>
  17. </span>
  18. </el-dialog>
  19. </div>
  20. </template>
  21. <script>
  22. import store from './store'
  23. export default {
  24. name: 'App',
  25. data() {
  26. return {
  27. dialogVisible: false
  28. }
  29. },
  30. mounted() {
  31. this.init()
  32. },
  33. methods: {
  34. init() {
  35. const self = this
  36. const language = store.state.app.language
  37. document.body.addEventListener('plugin_web_update_notice', (e) => {
  38. const { version, options } = e.detail
  39. console.log(version, options)
  40. self.dialogVisible = true
  41. // if (language === 'en') {
  42. // self.$confirm('System update detected, please refresh the page?', '📢 System update', {
  43. // distinguishCancelAndClose: true,
  44. // closeOnClickModal: false,
  45. // customClass: 'message_refresh',
  46. // confirmButtonText: 'refresh',
  47. // cancelButtonText: 'dismiss'
  48. // })
  49. // .then(() => {
  50. // location.reload()
  51. // })
  52. // .catch(action => {
  53. // self.$message({
  54. // type: 'info',
  55. // message: action === 'cancel'
  56. // ? 'Abandon'
  57. // : 'Stay on the current page'
  58. // })
  59. // })
  60. // } else {
  61. // self.$confirm('检测到系统更新,请刷新页面?', '📢 系统更新', {
  62. // distinguishCancelAndClose: true,
  63. // closeOnClickModal: false,
  64. // customClass: 'message_refresh',
  65. // confirmButtonText: '刷新',
  66. // cancelButtonText: '放弃'
  67. // })
  68. // .then(() => {
  69. // location.reload()
  70. // })
  71. // .catch(action => {
  72. // self.$message({
  73. // type: 'info',
  74. // message: action === 'cancel'
  75. // ? '放弃'
  76. // : '停留在当前页面'
  77. // })
  78. // })
  79. // }
  80. })
  81. },
  82. notificationRefresh() {
  83. location.reload()
  84. this.dialogVisible = false
  85. }
  86. }
  87. }
  88. </script>
  89. <style lang="scss" >
  90. .message_refresh{
  91. width: 320px;
  92. top: 50%;
  93. transform: translateY(-50%);
  94. }
  95. </style>