Просмотр исходного кода

fix: same edit/toggle hotkeys in popup and dashboard

* Enter/e = edit
* Space = toggle
* also deduplicate registration code
tophf 4 лет назад
Родитель
Сommit
7a7eb8a2d7
1 измененных файлов с 7 добавлено и 20 удалено
  1. 7 20
      src/popup/views/app.vue

+ 7 - 20
src/popup/views/app.vue

@@ -93,6 +93,8 @@
             :tabIndex="tabIndex"
             :data-message="item.name"
             @focus="focusedItem = item"
+            @keydown.enter.exact.stop="onEditScript(item)"
+            @keydown.space.exact.stop="onToggleScript(item)"
             @click="onToggleScript(item)">
             <img class="script-icon" :src="item.data.safeIcon">
             <icon :name="getSymbolCheck(item.data.config.enabled)"></icon>
@@ -493,26 +495,11 @@ export default {
           window.close();
         }
       }),
-      keyboardService.register('up', () => {
-        this.navigate('u');
-      }, {
-        condition: '!inputFocus',
-      }),
-      keyboardService.register('down', () => {
-        this.navigate('d');
-      }, {
-        condition: '!inputFocus',
-      }),
-      keyboardService.register('left', () => {
-        this.navigate('l');
-      }, {
-        condition: '!inputFocus',
-      }),
-      keyboardService.register('right', () => {
-        this.navigate('r');
-      }, {
-        condition: '!inputFocus',
-      }),
+      ...['up', 'down', 'left', 'right'].map(key => (
+        keyboardService.register(key,
+          this.navigate.bind(this, key[0]),
+          { condition: '!inputFocus' })
+      )),
       keyboardService.register('e', () => {
         this.onEditScript(this.focusedItem);
       }, {