fix: map chinese language requests to zh-CN

This commit is contained in:
TerryM
2026-05-26 08:09:20 +08:00
parent e7a5952d58
commit f2e97c329e
7 changed files with 14 additions and 11 deletions

View File

@@ -1,5 +1,6 @@
import { useCallback, useEffect, useRef, useState } from "react";
import { getJSON } from "../../../api";
import { langQuery, type Lang } from "../../../i18n";
import { MOCK_POSTS } from "../../../mocks/mockPosts";
import type { Post, PostListResponse, PostScope } from "../../../types/post";
@@ -12,7 +13,7 @@ export type PostStreamParams = {
scope: PostScope;
type?: string;
language?: string;
lang: string;
lang: Lang;
};
export type PostStreamResult = {
@@ -65,7 +66,7 @@ function filterMock(params: PostStreamParams): Post[] {
function buildRealUrl(params: PostStreamParams, cursor?: string): string {
const sp = new URLSearchParams();
sp.set("lang", params.lang);
sp.set("lang", langQuery(params.lang));
sp.set("limit", String(PAGE_SIZE));
if (params.scope.kind === "category") sp.set("category", params.scope.slug);
if (params.type && params.type !== "all") sp.set("type", params.type);