tyler 2 лет назад
Родитель
Сommit
1257c2d953
1 измененных файлов с 42 добавлено и 18 удалено
  1. 42 18
      src/App.vue

+ 42 - 18
src/App.vue

@@ -9,33 +9,57 @@ import store from './store'
 
 export default {
   name: 'App',
-  created() {
+  mounted() {
     const self = this
     console.log(store.state.app.language)
+    const language = store.state.app.language
     document.body.addEventListener('plugin_web_update_notice', (e) => {
       const { version, options } = e.detail
       // write some code, show your custom notification and etc.
       console.log(version, options)
-      // alert('System update!')
-      self.$confirm('检测到未保存的内容,是否在离开页面前保存修改?', '确认信息', {
-        distinguishCancelAndClose: true,
-        confirmButtonText: '保存',
-        cancelButtonText: '放弃修改'
-      })
-        .then(() => {
-          self.$message({
-            type: 'info',
-            message: '保存修改'
-          })
+      if (language === 'en') {
+        self.$confirm('System update detected, please refresh the page?', '📢 System update', {
+          distinguishCancelAndClose: true,
+          confirmButtonText: 'refresh',
+          cancelButtonText: 'dismiss'
         })
-        .catch(action => {
-          self.$message({
-            type: 'info',
-            message: action === 'cancel'
-              ? '放弃保存并离开页面'
-              : '停留在当前页面'
+          .then(() => {
+            self.$router.go(0)
+            self.$message({
+              type: 'info',
+              message: 'Refresh successful'
+            })
+          })
+          .catch(action => {
+            self.$message({
+              type: 'info',
+              message: action === 'cancel'
+                ? 'Abandon saving and leave the page'
+                : 'Stay on the current page'
+            })
           })
+      } else {
+        self.$confirm('检测到系统更新,请刷新页面?', '📢 系统更新', {
+          distinguishCancelAndClose: true,
+          confirmButtonText: '刷新',
+          cancelButtonText: '放弃'
         })
+          .then(() => {
+            self.$router.go(0)
+            self.$message({
+              type: 'info',
+              message: '刷新成功'
+            })
+          })
+          .catch(action => {
+            self.$message({
+              type: 'info',
+              message: action === 'cancel'
+                ? '放弃保存并离开页面'
+                : '停留在当前页面'
+            })
+          })
+      }
     })
   }
 }