فهرست منبع

部署后提示用户更新30

tyler 2 سال پیش
والد
کامیت
85569c2fba
3فایلهای تغییر یافته به همراه78 افزوده شده و 41 حذف شده
  1. 70 39
      src/App.vue
  2. 4 1
      src/lang/en.js
  3. 4 1
      src/lang/zh.js

+ 70 - 39
src/App.vue

@@ -1,6 +1,17 @@
 <template>
   <div id="app">
     <router-view />
+    <el-dialog
+      :title="$t('notificationProps.title')"
+      :visible.sync="dialogVisible"
+      width="30%"
+    >
+      <span>{{ $t('notificationProps.description') }}</span>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="dialogVisible = false">{{ $t('notificationProps.cancelButtonText') }}</el-button>
+        <el-button type="primary" @click="notificationreRresh">{{ $t('notificationProps.confirmButtonText') }}</el-button>
+      </span>
+    </el-dialog>
   </div>
 </template>
 
@@ -9,52 +20,72 @@ import store from './store'
 
 export default {
   name: 'App',
+  data() {
+    return {
+      dialogVisible: false
+    }
+  },
   created() {
     const self = this
     const language = store.state.app.language
     document.body.addEventListener('plugin_web_update_notice', (e) => {
       const { version, options } = e.detail
       console.log(version, options)
-      if (language === 'en') {
-        self.$confirm('System update detected, please refresh the page?', '📢 System update', {
-          distinguishCancelAndClose: true,
-          closeOnClickModal: false,
-          customClass: 'message_refresh',
-          confirmButtonText: 'refresh',
-          cancelButtonText: 'dismiss'
-        })
-          .then(() => {
-            location.reload()
-          })
-          .catch(action => {
-            self.$message({
-              type: 'info',
-              message: action === 'cancel'
-                ? 'Abandon'
-                : 'Stay on the current page'
-            })
-          })
-      } else {
-        self.$confirm('检测到系统更新,请刷新页面?', '📢 系统更新', {
-          distinguishCancelAndClose: true,
-          closeOnClickModal: false,
-          customClass: 'message_refresh',
-          confirmButtonText: '刷新',
-          cancelButtonText: '放弃'
-        })
-          .then(() => {
-            location.reload()
-          })
-          .catch(action => {
-            self.$message({
-              type: 'info',
-              message: action === 'cancel'
-                ? '放弃'
-                : '停留在当前页面'
-            })
-          })
-      }
+      self.dialogVisible = true
+      // if (language === 'en') {
+      //   self.$confirm('System update detected, please refresh the page?', '📢 System update', {
+      //     distinguishCancelAndClose: true,
+      //     closeOnClickModal: false,
+      //     customClass: 'message_refresh',
+      //     confirmButtonText: 'refresh',
+      //     cancelButtonText: 'dismiss'
+      //   })
+      //     .then(() => {
+      //       location.reload()
+      //     })
+      //     .catch(action => {
+      //       self.$message({
+      //         type: 'info',
+      //         message: action === 'cancel'
+      //           ? 'Abandon'
+      //           : 'Stay on the current page'
+      //       })
+      //     })
+      // } else {
+      //   self.$confirm('检测到系统更新,请刷新页面?', '📢 系统更新', {
+      //     distinguishCancelAndClose: true,
+      //     closeOnClickModal: false,
+      //     customClass: 'message_refresh',
+      //     confirmButtonText: '刷新',
+      //     cancelButtonText: '放弃'
+      //   })
+      //     .then(() => {
+      //       location.reload()
+      //     })
+      //     .catch(action => {
+      //       self.$message({
+      //         type: 'info',
+      //         message: action === 'cancel'
+      //           ? '放弃'
+      //           : '停留在当前页面'
+      //       })
+      //     })
+      // }
     })
+  },
+  methods: {
+    notificationreRresh() {
+      // setTimeout()
+      location.reload()
+      this.dialogVisible = false
+    },
+    handleClose(done) {
+      this.$confirm('确认关闭?')
+        .then(_ => {
+          done()
+        })
+        .catch(_ => {})
+    }
   }
 }
 </script>

+ 4 - 1
src/lang/en.js

@@ -527,6 +527,9 @@ export default {
     accountName: 'Account Name'
   },
   notificationProps: {
-    title: '📢 system update'
+    title: '📢 system update',
+    description: 'System update detected, please refresh the page',
+    confirmButtonText: 'refresh',
+    cancelButtonText: 'dismiss'
   }
 }

+ 4 - 1
src/lang/zh.js

@@ -523,6 +523,9 @@ export default {
     accountName: '开户支行'
   },
   notificationProps: {
-    title: '📢 系统更新'
+    title: '📢 系统更新',
+    description: '检测到系统更新,请刷新页面',
+    confirmButtonText: '刷新',
+    cancelButtonText: '放弃'
   }
 }