瀏覽代碼

feat: add toggle sidebar shortcut

Ahmad Kholid 3 年之前
父節點
當前提交
d31e888240

+ 1 - 1
src/components/block/BlockConditions.vue

@@ -87,7 +87,7 @@ function editBlock() {
 }
 function addConditionEmit({ id }) {
   if (id !== block.id) return;
-  console.log(block);
+
   const { length } = block.data.conditions;
 
   if (length >= 10) return;

+ 2 - 2
src/components/newtab/workflow/WorkflowBuilder.vue

@@ -181,8 +181,8 @@ export default {
         block.id,
         block.inputs,
         block.outputs,
-        xPosition,
-        yPosition,
+        xPosition + 25,
+        yPosition - 25,
         block.id,
         block.data,
         block.component,

+ 1 - 5
src/components/newtab/workflow/edit/EditConditions.vue

@@ -54,7 +54,7 @@
   </div>
 </template>
 <script setup>
-import { ref, watch, onUnmounted } from 'vue';
+import { ref, watch } from 'vue';
 import { useI18n } from 'vue-i18n';
 import emitter from '@/lib/mitt';
 
@@ -119,8 +119,4 @@ watch(
   },
   { deep: true }
 );
-
-onUnmounted(() => {
-  emitter.off('conditions-block:delete-cond', handleDelCondition);
-});
 </script>

+ 4 - 0
src/composable/shortcut.js

@@ -43,6 +43,10 @@ export const mapShortcuts = {
     id: 'editor:execute-workflow',
     combo: 'option+enter',
   },
+  'editor:toggle-sidebar': {
+    id: 'editor:toggle-sidebar',
+    combo: 'mod+[',
+  },
 };
 
 const os = navigator.appVersion.indexOf('Win') !== -1 ? 'win' : 'mac';

+ 8 - 2
src/newtab/pages/workflows/[id].vue

@@ -23,7 +23,11 @@
           class="border-none px-2 rounded-lg h-full space-x-1 bg-white"
         >
           <button
-            v-tooltip="t('workflow.toggleSidebar')"
+            v-tooltip="
+              `${t('workflow.toggleSidebar')} (${
+                shortcut['editor:toggle-sidebar'].readable
+              })`
+            "
             class="text-gray-800"
             style="margin-right: 6px"
             @click="toggleSidebar"
@@ -146,7 +150,7 @@
   </ui-modal>
 </template>
 <script setup>
-/* eslint-disable consistent-return */
+/* eslint-disable consistent-return, no-use-before-define */
 import {
   computed,
   reactive,
@@ -162,6 +166,7 @@ import { useI18n } from 'vue-i18n';
 import defu from 'defu';
 import emitter from '@/lib/mitt';
 import { useDialog } from '@/composable/dialog';
+import { useShortcut } from '@/composable/shortcut';
 import { tasks } from '@/utils/shared';
 import { sendMessage } from '@/utils/message';
 import { debounce, isObject } from '@/utils/helper';
@@ -184,6 +189,7 @@ const store = useStore();
 const route = useRoute();
 const router = useRouter();
 const dialog = useDialog();
+const shortcut = useShortcut('editor:toggle-sidebar', toggleSidebar);
 
 const workflowId = route.params.id;
 const workflowModals = {