refactor: show specific values in shortcut key conflict tips (#778)

* refactor: show specific values in shortcut key conflict tips

* update

* update

* update

* update

* update

* update

* update
This commit is contained in:
ayangweb
2025-07-19 11:05:17 +08:00
committed by GitHub
parent 5e536e1444
commit f4f7732927
3 changed files with 18 additions and 9 deletions

View File

@@ -205,23 +205,32 @@ const Shortcuts = () => {
const handleChange = (value: string, setValue: (value: string) => void) => { const handleChange = (value: string, setValue: (value: string) => void) => {
if (value.length > 1) return; 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 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) { if (isSystemKey) {
return addError( return addError(
t("settings.advanced.shortcuts.hints.isSystem"), t("settings.advanced.shortcuts.hints.isSystem", {
replace: [value],
}),
"warning" "warning"
); );
} }
if (isUsed) { 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); setValue(value);

View File

@@ -148,8 +148,8 @@
"description": "Shortcut to open the current conversation as an independent window in chat mode." "description": "Shortcut to open the current conversation as an independent window in chat mode."
}, },
"hints": { "hints": {
"isSystem": "This shortcut is reserved by the system, please choose another key.", "isSystem": "The shortcut key \"{{0}}\" is reserved by the system. Please choose a different key.",
"isUse": "This shortcut is already in use, please choose another key." "isUse": "The shortcut key \"{{0}}\" is already used by \"{{1}}\". Please choose a different key."
}, },
"aiOverview": { "aiOverview": {
"title": "AI Overview", "title": "AI Overview",

View File

@@ -148,8 +148,8 @@
"description": "在聊天模式下将当前对话打开为一个独立窗口的快捷按键。" "description": "在聊天模式下将当前对话打开为一个独立窗口的快捷按键。"
}, },
"hints": { "hints": {
"isSystem": "快捷键已被系统保留,请选择其他按键。", "isSystem": "快捷键“{{0}}”已被系统保留,请选择其他按键。",
"isUse": "快捷键已被占用,请选择其他按键。" "isUse": "快捷键“{{0}}”已被“{{1}}”占用,请选择其他按键。"
}, },
"aiOverview": { "aiOverview": {
"title": "AI 总结", "title": "AI 总结",