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) { if (isSystemKey) {
return addError( return addError(
t("settings.advanced.shortcuts.hits.isSystem"), t("settings.advanced.shortcuts.hints.isSystem"),
"warning" "warning"
); );
} }
if (isUsed) { if (isUsed) {
return addError(t("settings.advanced.shortcuts.hits.isUse"), "warning"); return addError(t("settings.advanced.shortcuts.hints.isUse"), "warning");
} }
setValue(value); setValue(value);

View File

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

View File

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

View File

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

View File

@@ -147,7 +147,7 @@
"title": "Detach Window", "title": "Detach Window",
"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."
}, },
"hits": { "hints": {
"isSystem": "This shortcut is reserved by the system, please choose another key.", "isSystem": "This shortcut is reserved by the system, please choose another key.",
"isUse": "This shortcut is already in use, please choose another key." "isUse": "This shortcut is already in use, please choose another key."
}, },
@@ -204,7 +204,7 @@
"hotkey": "Hotkey", "hotkey": "Hotkey",
"enabled": "Enabled" "enabled": "Enabled"
}, },
"hits": { "hints": {
"addAlias": "Add Alias", "addAlias": "Add Alias",
"recordHotkey": "Record Hotkey" "recordHotkey": "Record Hotkey"
}, },
@@ -224,6 +224,10 @@
"created": "Created", "created": "Created",
"modified": "Modified", "modified": "Modified",
"lastOpened": "Last Opened" "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": { "calculator": {
@@ -259,7 +263,7 @@
} }
}, },
"directoryScope": { "directoryScope": {
"hits": { "hints": {
"pathDuplication": "Path \"{{0}}\" is already in search scope.", "pathDuplication": "Path \"{{0}}\" is already in search scope.",
"pathIncluded": "Path \"{{0}}\" is already covered by another search directory." "pathIncluded": "Path \"{{0}}\" is already covered by another search directory."
}, },

View File

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