feat: move open_tranbox shortcurt to browser commands

This commit is contained in:
Gabe Yuan
2024-01-03 11:59:41 +08:00
parent 2cb20b5cc0
commit cff8b2fe39
6 changed files with 18 additions and 37 deletions

View File

@@ -1,10 +1,9 @@
import { useState, useEffect, useCallback } from "react";
import TranBtn from "./TranBtn";
import TranBox from "./TranBox";
import { shortcutRegister } from "../../libs/shortcut";
import { sleep, limitNumber } from "../../libs/utils";
import { isGm } from "../../libs/client";
import { MSG_OPEN_TRANBOX, DEFAULT_TRANBOX_SHORTCUT } from "../../config";
import { MSG_OPEN_TRANBOX } from "../../config";
import { isMobile } from "../../libs/mobile";
export default function Slection({ contextMenus, tranboxSetting, transApis }) {
@@ -76,17 +75,6 @@ export default function Slection({ contextMenus, tranboxSetting, transApis }) {
};
}, [tranboxSetting.hideTranBtn]);
useEffect(() => {
const clearShortcut = shortcutRegister(
tranboxSetting.tranboxShortcut || DEFAULT_TRANBOX_SHORTCUT,
handleTranbox
);
return () => {
clearShortcut();
};
}, [tranboxSetting.tranboxShortcut, handleTranbox]);
useEffect(() => {
window.addEventListener(MSG_OPEN_TRANBOX, handleTranbox);
return () => {