refactor: rebuild app index with improved suggestions (#771)

This commit is contained in:
ayangweb
2025-07-18 16:15:28 +08:00
committed by GitHub
parent 7d0e7cd7dc
commit af0b98a41b
6 changed files with 33 additions and 14 deletions

View File

@@ -215,13 +215,13 @@ const Shortcuts = () => {
if (isSystemKey) {
return addError(
t("settings.advanced.shortcuts.hits.isSystem"),
t("settings.advanced.shortcuts.hints.isSystem"),
"warning"
);
}
if (isUsed) {
return addError(t("settings.advanced.shortcuts.hits.isUse"), "warning");
return addError(t("settings.advanced.shortcuts.hints.isUse"), "warning");
}
setValue(value);

View File

@@ -158,7 +158,7 @@ const Item: FC<ItemProps> = (props) => {
>
<SettingsInput
defaultValue={alias}
placeholder={t("settings.extensions.hits.addAlias")}
placeholder={t("settings.extensions.hints.addAlias")}
className="!w-[90%] !h-6 !border-transparent rounded-[4px]"
onChange={(value) => {
handleChange(String(value));
@@ -203,7 +203,7 @@ const Item: FC<ItemProps> = (props) => {
>
<Shortcut
value={hotkey}
placeholder={t("settings.extensions.hits.recordHotkey")}
placeholder={t("settings.extensions.hints.recordHotkey")}
onChange={handleChange}
/>
</div>

View File

@@ -5,10 +5,12 @@ import { useTranslation } from "react-i18next";
import platformAdapter from "@/utils/platformAdapter";
import DirectoryScope from "../DirectoryScope";
import { useAppStore } from "@/stores/appStore";
const Applications = () => {
const { t } = useTranslation();
const [paths, setPaths] = useState<string[]>([]);
const { addError } = useAppStore();
useMount(async () => {
const paths = await platformAdapter.invokeBackend<string[]>(
@@ -18,8 +20,17 @@ const Applications = () => {
setPaths(paths);
});
const handleReindex = () => {
platformAdapter.invokeBackend("reindex_applications");
const handleReindex = async () => {
try {
await platformAdapter.invokeBackend("reindex_applications");
addError(
t("settings.extensions.application.hints.reindexSuccess"),
"info"
);
} catch {
addError(t("settings.extensions.application.hints.reindexFailed"));
}
};
return (

View File

@@ -34,7 +34,7 @@ const DirectoryScope: FC<DirectoryScopeProps> = (props) => {
const selectedPaths = castArray(selected).filter((selectedPath) => {
if (paths.includes(selectedPath)) {
addError(
t("settings.extensions.directoryScope.hits.pathDuplication", {
t("settings.extensions.directoryScope.hints.pathDuplication", {
replace: [selectedPath],
})
);
@@ -48,7 +48,7 @@ const DirectoryScope: FC<DirectoryScopeProps> = (props) => {
if (isChildPath) {
addError(
t("settings.extensions.directoryScope.hits.pathIncluded", {
t("settings.extensions.directoryScope.hints.pathIncluded", {
replace: [selectedPath],
})
);

View File

@@ -147,7 +147,7 @@
"title": "Detach Window",
"description": "Shortcut to open the current conversation as an independent window in chat mode."
},
"hits": {
"hints": {
"isSystem": "This shortcut is reserved by the system, please choose another key.",
"isUse": "This shortcut is already in use, please choose another key."
},
@@ -204,7 +204,7 @@
"hotkey": "Hotkey",
"enabled": "Enabled"
},
"hits": {
"hints": {
"addAlias": "Add Alias",
"recordHotkey": "Record Hotkey"
},
@@ -224,6 +224,10 @@
"created": "Created",
"modified": "Modified",
"lastOpened": "Last Opened"
},
"hints": {
"reindexSuccess": "Index rebuilt successfully. The latest application list is now updated.",
"reindexFailed": "Failed to rebuild the index. Please try again later."
}
},
"calculator": {
@@ -259,7 +263,7 @@
}
},
"directoryScope": {
"hits": {
"hints": {
"pathDuplication": "Path \"{{0}}\" is already in search scope.",
"pathIncluded": "Path \"{{0}}\" is already covered by another search directory."
},

View File

@@ -147,7 +147,7 @@
"title": "独立窗口",
"description": "在聊天模式下将当前对话打开为一个独立窗口的快捷按键。"
},
"hits": {
"hints": {
"isSystem": "该快捷键已被系统保留,请选择其他按键。",
"isUse": "该快捷键已被占用,请选择其他按键。"
},
@@ -204,7 +204,7 @@
"hotkey": "热键",
"enabled": "启用状态"
},
"hits": {
"hints": {
"addAlias": "添加别名",
"recordHotkey": "录制热键"
},
@@ -224,6 +224,10 @@
"created": "创建时间",
"modified": "修改时间",
"lastOpened": "上次打开时间"
},
"hints": {
"reindexSuccess": "索引重建成功,最新应用列表已更新。",
"reindexFailed": "索引重建失败,请稍后重试。"
}
},
"calculator": {
@@ -259,7 +263,7 @@
}
},
"directoryScope": {
"hits": {
"hints": {
"pathDuplication": "路径 \"{{0}}\" 已存在于搜索范围中。",
"pathIncluded": "路径 \"{{0}}\" 已被其他搜索目录包含。"
},