fix: route home view-all links

This commit is contained in:
TerryM
2026-05-28 16:49:30 +08:00
parent 4c15e01460
commit 5fec82dbba
6 changed files with 90 additions and 68 deletions

View File

@@ -19,11 +19,10 @@ export function MessageStream({ scope }: MessageStreamProps) {
const type = sp.get("type") || "all";
const q = (sp.get("q") || "").trim();
const sort = sp.get("sort") || "";
const tag = sp.get("tag") || "";
const params = useMemo(
() => ({ scope, type, q, sort, tag, lang }),
[scope, type, q, sort, tag, lang],
() => ({ scope, type, q, sort, lang }),
[scope, type, q, sort, lang],
);
const { items, isLoading, error, hasMore, loadMore, reset } =

View File

@@ -16,7 +16,6 @@ export type PostStreamParams = {
language?: string;
q?: string;
sort?: string;
tag?: string;
lang: Lang;
};
@@ -61,9 +60,6 @@ function filterMock(params: PostStreamParams): Post[] {
return false;
const q = params.q?.trim().toLowerCase();
if (params.language && p.language !== params.language) return false;
const tag = params.tag?.trim().toLowerCase();
if (tag && !(p.tags ?? []).some((t) => t.toLowerCase() === tag))
return false;
if (q) {
const haystack = [
p.text ?? "",
@@ -93,7 +89,6 @@ function buildRealUrl(params: PostStreamParams, cursor?: string): string {
if (params.scope.kind === "category") sp.set("category", params.scope.slug);
if (params.type && params.type !== "all") sp.set("type", params.type);
if (params.sort) sp.set("sort", params.sort);
if (params.tag) sp.set("tag", params.tag);
if (params.language) sp.set("language", sourceLanguageQuery(params.language));
if (cursor) sp.set("cursor", cursor);
return `${q ? "/api/posts/search" : "/api/posts"}?${sp.toString()}`;
@@ -171,7 +166,6 @@ export function usePostStream(params: PostStreamParams): PostStreamResult {
params.language,
params.q,
params.sort,
params.tag,
params.lang,
]);