瀏覽代碼

feat: ctrl + click save in editor to save and close

NGPixel 5 年之前
父節點
當前提交
d0706b376b
共有 1 個文件被更改,包括 13 次插入3 次删除
  1. 13 3
      client/components/editor.vue

+ 13 - 3
client/components/editor.vue

@@ -9,7 +9,8 @@
         v-btn.animated.fadeInDown(
         v-btn.animated.fadeInDown(
           text
           text
           color='green'
           color='green'
-          @click.native.stop='save'
+          @click='save'
+          @click.ctrl.exact='saveAndClose'
           :class='{ "is-icon": $vuetify.breakpoint.mdAndDown }'
           :class='{ "is-icon": $vuetify.breakpoint.mdAndDown }'
           )
           )
           v-icon(color='green', :left='$vuetify.breakpoint.lgAndUp') mdi-check
           v-icon(color='green', :left='$vuetify.breakpoint.lgAndUp') mdi-check
@@ -17,7 +18,7 @@
         v-btn.animated.fadeInDown.wait-p1s(
         v-btn.animated.fadeInDown.wait-p1s(
           text
           text
           color='blue'
           color='blue'
-          @click.native.stop='openPropsModal'
+          @click='openPropsModal'
           :class='{ "is-icon": $vuetify.breakpoint.mdAndDown, "mx-0": !welcomeMode, "ml-0": welcomeMode }'
           :class='{ "is-icon": $vuetify.breakpoint.mdAndDown, "mx-0": !welcomeMode, "ml-0": welcomeMode }'
           )
           )
           v-icon(color='blue', :left='$vuetify.breakpoint.lgAndUp') mdi-tag-text-outline
           v-icon(color='blue', :left='$vuetify.breakpoint.lgAndUp') mdi-tag-text-outline
@@ -27,7 +28,7 @@
           text
           text
           color='red'
           color='red'
           :class='{ "is-icon": $vuetify.breakpoint.mdAndDown }'
           :class='{ "is-icon": $vuetify.breakpoint.mdAndDown }'
-          @click.native.stop='exit'
+          @click='exit'
           )
           )
           v-icon(color='red', :left='$vuetify.breakpoint.lgAndUp') mdi-close
           v-icon(color='red', :left='$vuetify.breakpoint.lgAndUp') mdi-close
           span.white--text(v-if='$vuetify.breakpoint.lgAndUp') {{ $t('common:actions.close') }}
           span.white--text(v-if='$vuetify.breakpoint.lgAndUp') {{ $t('common:actions.close') }}
@@ -270,9 +271,18 @@ export default {
           style: 'error',
           style: 'error',
           icon: 'warning'
           icon: 'warning'
         })
         })
+        throw err
       }
       }
       this.hideProgressDialog()
       this.hideProgressDialog()
     },
     },
+    async saveAndClose() {
+      try {
+        await this.save()
+        await this.exit()
+      } catch (err) {
+        // Error is already handled
+      }
+    },
     async exit() {
     async exit() {
       if (this.initContentParsed !== this.$store.get('editor/content')) {
       if (this.initContentParsed !== this.$store.get('editor/content')) {
         this.dialogUnsaved = true
         this.dialogUnsaved = true