fix(home): use configured featured categories only + rename 惊喜 to 精选
This commit is contained in:
parent
d5ad5faa5f
commit
e8bfbbf286
@ -418,7 +418,7 @@ export function AdminSettingsClient() {
|
|||||||
lovartHeroTitle: "由壹点AI 让设计更简单",
|
lovartHeroTitle: "由壹点AI 让设计更简单",
|
||||||
lovartHeroSubtitle: "懂你的设计代理,帮你搞定一切",
|
lovartHeroSubtitle: "懂你的设计代理,帮你搞定一切",
|
||||||
homeVariant: "classic",
|
homeVariant: "classic",
|
||||||
surpriseCategories: ["全部", "惊喜"],
|
surpriseCategories: ["全部", "精选"],
|
||||||
membershipConfig: defaultMembershipConfig,
|
membershipConfig: defaultMembershipConfig,
|
||||||
membershipUserOverrides: defaultMembershipUserOverrides,
|
membershipUserOverrides: defaultMembershipUserOverrides,
|
||||||
});
|
});
|
||||||
@ -2690,7 +2690,7 @@ export function AdminSettingsClient() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<Label htmlFor="surpriseCategories">惊喜相册分类(逗号分隔)</Label>
|
<Label htmlFor="surpriseCategories">精选相册分类(逗号分隔)</Label>
|
||||||
<Input
|
<Input
|
||||||
id="surpriseCategories"
|
id="surpriseCategories"
|
||||||
value={siteSettings.surpriseCategories.join(", ")}
|
value={siteSettings.surpriseCategories.join(", ")}
|
||||||
@ -2702,10 +2702,10 @@ export function AdminSettingsClient() {
|
|||||||
const unique = Array.from(new Set(parsed));
|
const unique = Array.from(new Set(parsed));
|
||||||
setSiteSettings({
|
setSiteSettings({
|
||||||
...siteSettings,
|
...siteSettings,
|
||||||
surpriseCategories: unique.length > 0 ? unique : ["全部", "惊喜"],
|
surpriseCategories: unique.length > 0 ? unique : ["全部", "精选"],
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
placeholder="全部, 惊喜, 海报, 电商"
|
placeholder="全部, 精选, 海报, 电商"
|
||||||
/>
|
/>
|
||||||
<div className="text-xs text-muted-foreground">
|
<div className="text-xs text-muted-foreground">
|
||||||
新版首页“精选”模块会按这些分类显示筛选标签。
|
新版首页“精选”模块会按这些分类显示筛选标签。
|
||||||
|
|||||||
@ -39,7 +39,7 @@ async function NewChatPage() {
|
|||||||
? surpriseCategoriesSetting?.value
|
? surpriseCategoriesSetting?.value
|
||||||
.map((item: unknown) => String(item || "").trim())
|
.map((item: unknown) => String(item || "").trim())
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
: ["全部", "惊喜"];
|
: ["全部", "精选"];
|
||||||
|
|
||||||
if (!session?.user && homeVariant !== "lovart") {
|
if (!session?.user && homeVariant !== "lovart") {
|
||||||
redirect("/login");
|
redirect("/login");
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import {
|
|||||||
} from "@/lib/membership/config";
|
} from "@/lib/membership/config";
|
||||||
|
|
||||||
const HOME_VARIANT_KEY = "home_variant";
|
const HOME_VARIANT_KEY = "home_variant";
|
||||||
|
// Historically stored as "home_surprise_categories" but used for the featured gallery categories.
|
||||||
const HOME_SURPRISE_CATEGORIES_KEY = "home_surprise_categories";
|
const HOME_SURPRISE_CATEGORIES_KEY = "home_surprise_categories";
|
||||||
const LOVART_COMPOSER_PREVIEW_TEXTS_KEY = "lovart_composer_preview_texts";
|
const LOVART_COMPOSER_PREVIEW_TEXTS_KEY = "lovart_composer_preview_texts";
|
||||||
const MEMBERSHIP_CONFIG_KEY = "membership_config";
|
const MEMBERSHIP_CONFIG_KEY = "membership_config";
|
||||||
@ -23,16 +24,18 @@ function normalizeHomeVariant(value: unknown): "classic" | "lovart" {
|
|||||||
|
|
||||||
function normalizeSurpriseCategories(value: unknown): string[] {
|
function normalizeSurpriseCategories(value: unknown): string[] {
|
||||||
if (!Array.isArray(value)) {
|
if (!Array.isArray(value)) {
|
||||||
return ["全部", "惊喜"];
|
return ["全部", "精选"];
|
||||||
}
|
}
|
||||||
|
|
||||||
const normalized = value
|
const normalized = value
|
||||||
.map((item) => String(item || "").trim())
|
.map((item) => String(item || "").trim())
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
|
// legacy typo compatibility: treat "惊喜" as "精选"
|
||||||
|
.map((item) => (item === "惊喜" ? "精选" : item))
|
||||||
.slice(0, 12);
|
.slice(0, 12);
|
||||||
|
|
||||||
if (normalized.length === 0) {
|
if (normalized.length === 0) {
|
||||||
return ["全部", "惊喜"];
|
return ["全部", "精选"];
|
||||||
}
|
}
|
||||||
|
|
||||||
const unique = Array.from(new Set(normalized));
|
const unique = Array.from(new Set(normalized));
|
||||||
|
|||||||
@ -328,11 +328,23 @@ export function LovartHome({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const discoveryTabs = useMemo(() => {
|
const discoveryTabs = useMemo(() => {
|
||||||
const merged = [
|
const configured = (surpriseCategories || [])
|
||||||
"全部",
|
.map((item) => String(item || "").trim())
|
||||||
...surpriseCategories.filter((item) => item && item !== "全部"),
|
.filter(Boolean)
|
||||||
...DISCOVERY_DEFAULT_TABS,
|
// legacy typo compatibility: treat "惊喜" as "精选"
|
||||||
];
|
.map((item) => (item === "惊喜" ? "精选" : item));
|
||||||
|
|
||||||
|
const uniqueConfigured = Array.from(new Set(configured));
|
||||||
|
const hasRealConfig =
|
||||||
|
uniqueConfigured.length > 0 &&
|
||||||
|
!(uniqueConfigured.length === 1 && uniqueConfigured[0] === "全部");
|
||||||
|
|
||||||
|
const fallback = ["全部", "精选", ...DISCOVERY_DEFAULT_TABS];
|
||||||
|
const base = hasRealConfig ? uniqueConfigured : fallback;
|
||||||
|
|
||||||
|
const withoutAll = base.filter((item) => item !== "全部");
|
||||||
|
const merged = ["全部", ...withoutAll];
|
||||||
|
|
||||||
return Array.from(new Set(merged)).slice(0, 12);
|
return Array.from(new Set(merged)).slice(0, 12);
|
||||||
}, [surpriseCategories]);
|
}, [surpriseCategories]);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user