diff --git a/src/components/Settings/Advanced/components/Shortcuts/index.tsx b/src/components/Settings/Advanced/components/Shortcuts/index.tsx index 339e14fb..a1fd73ec 100644 --- a/src/components/Settings/Advanced/components/Shortcuts/index.tsx +++ b/src/components/Settings/Advanced/components/Shortcuts/index.tsx @@ -205,23 +205,32 @@ const Shortcuts = () => { const handleChange = (value: string, setValue: (value: string) => void) => { if (value.length > 1) return; - const systemKeys = ["C", "V", "X", "Z", "Q", "H"]; + const systemKeys = ["C", "V", "X", "Z", "Q", "H", "K", ","]; const isSystemKey = systemKeys.includes(value); - const state = useShortcutsStore.getState(); + const usedKeys = list.map((item) => item.value); - const isUsed = Object.values(state).includes(value); + const isUsed = value !== "" && usedKeys.includes(value); if (isSystemKey) { return addError( - t("settings.advanced.shortcuts.hints.isSystem"), + t("settings.advanced.shortcuts.hints.isSystem", { + replace: [value], + }), "warning" ); } if (isUsed) { - return addError(t("settings.advanced.shortcuts.hints.isUse"), "warning"); + const matched = list.find((item) => item.value === value)!; + + return addError( + t("settings.advanced.shortcuts.hints.isUse", { + replace: [value, t(matched.title)], + }), + "warning" + ); } setValue(value); diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json index b2cfee06..60f531ae 100644 --- a/src/locales/en/translation.json +++ b/src/locales/en/translation.json @@ -148,8 +148,8 @@ "description": "Shortcut to open the current conversation as an independent window in chat mode." }, "hints": { - "isSystem": "This shortcut is reserved by the system, please choose another key.", - "isUse": "This shortcut is already in use, please choose another key." + "isSystem": "The shortcut key \"{{0}}\" is reserved by the system. Please choose a different key.", + "isUse": "The shortcut key \"{{0}}\" is already used by \"{{1}}\". Please choose a different key." }, "aiOverview": { "title": "AI Overview", diff --git a/src/locales/zh/translation.json b/src/locales/zh/translation.json index cfba49a8..785efbfe 100644 --- a/src/locales/zh/translation.json +++ b/src/locales/zh/translation.json @@ -148,8 +148,8 @@ "description": "在聊天模式下将当前对话打开为一个独立窗口的快捷按键。" }, "hints": { - "isSystem": "该快捷键已被系统保留,请选择其他按键。", - "isUse": "该快捷键已被占用,请选择其他按键。" + "isSystem": "快捷键“{{0}}”已被系统保留,请选择其他按键。", + "isUse": "快捷键“{{0}}”已被“{{1}}”占用,请选择其他按键。" }, "aiOverview": { "title": "AI 总结",