feat: 更新搜索逻辑

现在更换app类别时将默认清空搜索。
This commit is contained in:
Elysia
2026-02-12 20:11:54 +08:00
parent c3ae477497
commit d5266c6af8
4 changed files with 17 additions and 31 deletions

View File

@@ -12,8 +12,8 @@
id="searchBox"
v-model="localSearchQuery"
class="w-full rounded-2xl border border-slate-200/70 bg-white/80 py-3 pl-12 pr-4 text-sm text-slate-700 shadow-sm outline-none transition placeholder:text-slate-400 focus:border-brand/50 focus:ring-4 focus:ring-brand/10 dark:border-slate-800/70 dark:bg-slate-900/60 dark:text-slate-200"
placeholder="搜索应用名 / 包名 / 标签"
@input="debounceSearch"
placeholder="搜索应用名 / 包名 / 标签,按回车键搜索"
@keydown.enter="handleSearch"
/>
</div>
</div>
@@ -30,6 +30,7 @@ import TopActions from "./TopActions.vue";
const props = defineProps<{
searchQuery: string;
activeCategory: string;
appsCount: number;
}>();
@@ -40,13 +41,9 @@ const emit = defineEmits<{
}>();
const localSearchQuery = ref(props.searchQuery || "");
const timeoutId = ref<ReturnType<typeof setTimeout> | null>(null);
const debounceSearch = () => {
if (timeoutId.value) clearTimeout(timeoutId.value);
timeoutId.value = setTimeout(() => {
emit("update-search", localSearchQuery.value);
}, 220);
const handleSearch = () => {
emit("update-search", localSearchQuery.value);
};
watch(
@@ -55,4 +52,11 @@ watch(
localSearchQuery.value = newVal || "";
},
);
watch(
() => props.activeCategory,
() => {
localSearchQuery.value = "";
},
);
</script>

View File

@@ -159,10 +159,9 @@ const onProgress = (_event: any, chunk: string) => {
scrollToBottom();
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const onComplete = (
_event: any,
result: { success: boolean; message: any },
_event: unknown,
result: { success: boolean; message: unknown },
) => {
if (!uninstalling.value) return; // Ignore if not current session