Przeglądaj źródła

fix: can't access localStorage error in edge (#861)

Ahmad Kholid 2 lat temu
rodzic
commit
628837eb43
1 zmienionych plików z 19 dodań i 1 usunięć
  1. 19 1
      src/content/commandPalette/App.vue

+ 19 - 1
src/content/commandPalette/App.vue

@@ -150,10 +150,10 @@ import {
   inject,
 } from 'vue';
 import browser from 'webextension-polyfill';
-import { getReadableShortcut } from '@/composable/shortcut';
 import { sendMessage } from '@/utils/message';
 import { debounce } from '@/utils/helper';
 
+const os = navigator.appVersion.indexOf('Mac') !== -1 ? 'mac' : 'win';
 const defaultPlaceholders = {
   string: 'Text',
   number: '123123',
@@ -185,6 +185,24 @@ const workflows = computed(() =>
   )
 );
 
+function getReadableShortcut(str) {
+  const list = {
+    option: {
+      win: 'alt',
+      mac: 'option',
+    },
+    mod: {
+      win: 'ctrl',
+      mac: '⌘',
+    },
+  };
+  const regex = /option|mod/g;
+  const replacedStr = str.replace(regex, (match) => {
+    return list[match][os];
+  });
+
+  return replacedStr;
+}
 function clearParamsState() {
   Object.assign(paramsState, {
     items: [],