feat: ignore filters on fallback routes

This commit is contained in:
RhenCloud 2026-08-03 00:02:29 +08:00
parent bd33fa6835
commit 38daf7bc83
No known key found for this signature in database
GPG key ID: A574A617378C4E0B
6 changed files with 129 additions and 15 deletions

View file

@ -133,13 +133,25 @@ watch(
form.threadId = r?.target.threadId ?? "";
form.filters = (r && r.filters.length
? r.filters
: [{ type: "event", match: "", exclude: false }]
: form.fallback
? []
: [{ type: "event", match: "", exclude: false }]
).map((f) => ({ ...f, matchText: fmtMatch(f.match) })) as FilterForm[];
filterError.value = "";
formError.value = "";
},
);
watch(
() => form.fallback,
(v) => {
if (v && form.filters.every((f) => f.matchText.trim() === "")) {
form.filters = [];
filterError.value = "";
}
},
);
function close(): void {
emit("close");
}
@ -156,7 +168,7 @@ function collect(): Route | null {
filters.push({ type: f.type, match, exclude: f.exclude });
}
filterError.value = "";
if (!filters.length) {
if (!form.fallback && !filters.length) {
filterError.value = t("routeEditor.errAddFilter");
return null;
}