Skip to content

Commit e4bfb56

Browse files
committed
fix: game covers marked as NSFW will not be replaced
1 parent 08fd61b commit e4bfb56

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/components/Cards/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import type { GameData } from "@/types";
4545
import {
4646
getGameCover,
4747
getGameDisplayName,
48-
isNsfwGame,
48+
getGameNsfwStatus,
4949
saveScrollPosition,
5050
} from "@/utils";
5151

@@ -319,7 +319,7 @@ export const CardItem = memo(
319319
ref,
320320
) => {
321321
const nsfwCoverReplace = useStore((s) => s.nsfwCoverReplace);
322-
const isNsfw = isNsfwGame(card.tags || []);
322+
const isNsfw = getGameNsfwStatus(card);
323323

324324
const { isLongPressing, handlers } = useCardInteraction({
325325
onClick,

src/utils/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ export async function moveBackupFolder(
675675
* 根据tags判断是否为NSFW
676676
* @param tags
677677
*/
678-
export function isNsfwGame(tags: string[]): boolean {
678+
const isNsfwGame = (tags: string[]): boolean => {
679679
if (tags.length === 0) return false;
680680

681681
if (tags.some((tag) => tag.includes("R18") || tag === "拔作")) {
@@ -687,15 +687,15 @@ export function isNsfwGame(tags: string[]): boolean {
687687
// biome-ignore lint/suspicious/noControlCharactersInRegex: 允许 ASCII 范围检查
688688
const isAllEnglish = tags.every((tag) => /^[\x00-\x7F]+$/.test(tag));
689689
return isAllEnglish && !tags.includes("No Sexual Content");
690-
}
690+
};
691691

692692
/**
693693
* 统一判断单个游戏是否为 NSFW
694694
* 策略:优先读取 game.nsfw 字段,如果为 null/undefined 则回退到标签判断
695695
*/
696-
export function getGameNsfwStatus(game: GameData): boolean {
696+
export const getGameNsfwStatus = (game: GameData): boolean => {
697697
return game.nsfw ?? isNsfwGame(game.tags || []);
698-
}
698+
};
699699

700700
/**
701701
* 应用 NSFW 过滤器

0 commit comments

Comments
 (0)