feat: context menu type

This commit is contained in:
Gabe Yuan
2024-02-05 11:28:34 +08:00
parent e74883e9c2
commit 3083d8e147
7 changed files with 82 additions and 70 deletions

View File

@@ -7,7 +7,11 @@ import { isGm, isExt } from "../../libs/client";
import { MSG_OPEN_TRANBOX, DEFAULT_TRANBOX_SHORTCUT } from "../../config";
import { isMobile } from "../../libs/mobile";
export default function Slection({ contextMenus, tranboxSetting, transApis }) {
export default function Slection({
contextMenuType,
tranboxSetting,
transApis,
}) {
const boxWidth = limitNumber(window.innerWidth, 300, 600);
const boxHeight = limitNumber(window.innerHeight, 200, 400);
@@ -106,7 +110,7 @@ export default function Slection({ contextMenus, tranboxSetting, transApis }) {
// 注册菜单
try {
const menuCommandIds = [];
contextMenus &&
contextMenuType !== 0 &&
menuCommandIds.push(
GM.registerMenuCommand(
"Translate Selected Text",
@@ -125,7 +129,7 @@ export default function Slection({ contextMenus, tranboxSetting, transApis }) {
} catch (err) {
console.log("[registerMenuCommand]", err);
}
}, [handleTranbox, contextMenus]);
}, [handleTranbox, contextMenuType]);
return (
<>