Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/config/siteConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ export const siteConfig: SiteConfig = {
// 可选值: "anime" | "book" | "music" | "game" | "real" (暂不支持"real"类型)
// 未列出的类型将按默认顺序排在后面
categoryOrder: ["anime", "book", "music", "game"],
// 控制各分类的启用状态(true/false),未指定的分类默认启用
// categories: {
// game: false, // 禁用游戏分类显示
// },
},

// 追番配置(Bilibili + TMDB)
Expand Down
11 changes: 6 additions & 5 deletions src/pages/bangumi.astro
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ const bangumiConfig = {
apiUrl: siteConfig.bangumi?.apiUrl || "https://api.bangumi.one",
subjectBaseUrl:
siteConfig.bangumi?.subjectBaseUrl || "https://bangumi.one/subject/",
// 从配置文件中读取各分类是否启用,若未配置则使用默认值
categories: {
book: true,
anime: true,
music: true,
game: true,
real: false,
book: siteConfig.bangumi?.categories?.book ?? true,
anime: siteConfig.bangumi?.categories?.anime ?? true,
music: siteConfig.bangumi?.categories?.music ?? true,
game: siteConfig.bangumi?.categories?.game ?? true,
real: siteConfig.bangumi?.categories?.real ?? false,
},
// 数据获取设置
pagination: {
Expand Down
8 changes: 8 additions & 0 deletions src/types/siteConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ export type SiteConfig = {
apiUrl?: string; // Bangumi API 地址
subjectBaseUrl?: string; // 条目详情页地址
categoryOrder?: ("anime" | "game" | "book" | "music" | "real")[]; // 条目类型排序顺序
// 各分类的显示启用状态,未设置时默认启用
categories?: {
book?: boolean;
anime?: boolean;
music?: boolean;
game?: boolean;
real?: boolean;
Comment on lines +154 to +160

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): 文档注释说明分类在未设置时默认启用,但在 bangumiConfig 中,real 实际上是默认禁用的。

在 bangumi.astro 中,real 的取值为 siteConfig.bangumi?.categories?.real ?? false,因此当 real 未设置时会被视为禁用,这与注释中“未设置时默认启用”的描述相矛盾。请更新注释以说明 real 的特殊默认值,或者将 bangumiConfig 中的默认值改为 true,以与文档说明保持一致。

Original comment in English

issue (bug_risk): The doc comment says categories default to enabled, but real is actually defaulted to disabled in bangumiConfig.

In bangumi.astro, real resolves to siteConfig.bangumi?.categories?.real ?? false, so when real is not set it is disabled, contradicting the comment’s "未设置时默认启用". Please either update the comment to mention the special-case default for real, or change the default in bangumiConfig to true to match the documented behavior.

};
};

// 追番配置(Bilibili + TMDB)
Expand Down
Loading