mirror of
https://github.com/infinilabs/coco-app.git
synced 2025-12-16 19:47:43 +01:00
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:
@@ -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);
|
||||||
|
|||||||
@@ -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",
|
||||||
|
|||||||
@@ -148,8 +148,8 @@
|
|||||||
"description": "在聊天模式下将当前对话打开为一个独立窗口的快捷按键。"
|
"description": "在聊天模式下将当前对话打开为一个独立窗口的快捷按键。"
|
||||||
},
|
},
|
||||||
"hints": {
|
"hints": {
|
||||||
"isSystem": "该快捷键已被系统保留,请选择其他按键。",
|
"isSystem": "快捷键“{{0}}”已被系统保留,请选择其他按键。",
|
||||||
"isUse": "该快捷键已被占用,请选择其他按键。"
|
"isUse": "快捷键“{{0}}”已被“{{1}}”占用,请选择其他按键。"
|
||||||
},
|
},
|
||||||
"aiOverview": {
|
"aiOverview": {
|
||||||
"title": "AI 总结",
|
"title": "AI 总结",
|
||||||
|
|||||||
Reference in New Issue
Block a user