fix: update ui when shortcut changed

This commit is contained in:
Gabe Yuan
2024-01-22 13:11:02 +08:00
parent 30efb6ee7a
commit 63b5f707e2
8 changed files with 66 additions and 18 deletions

View File

@@ -9,6 +9,7 @@ import {
MSG_TRANS_TOGGLE_STYLE,
MSG_OPEN_TRANBOX,
MSG_CONTEXT_MENUS,
MSG_COMMAND_SHORTCUTS,
CMD_TOGGLE_TRANSLATE,
CMD_TOGGLE_STYLE,
CMD_OPEN_OPTIONS,
@@ -138,6 +139,16 @@ browser.runtime.onMessage.addListener(
removeContextMenus();
}
break;
case MSG_COMMAND_SHORTCUTS:
browser.commands
.getAll()
.then((commands) => {
sendResponse({ data: commands });
})
.catch((error) => {
sendResponse({ error: error.message });
});
break;
default:
sendResponse({ error: `message action is unavailable: ${action}` });
}