Skip to content

Commit 11b64f6

Browse files
committed
mod: optimizing patch detail tags and screenshots display
1 parent b7e0b20 commit 11b64f6

File tree

7 files changed

+91
-45
lines changed

7 files changed

+91
-45
lines changed

app/patch/[id]/introduction/metadata.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,10 @@ export const generateKunMetadataTemplate = (detail: PatchDetail): Metadata => {
1111
selectors: [{ selector: 'p', format: 'inline' }]
1212
}).slice(0, 170)
1313

14-
const title = detail.alias.length
15-
? `${patchName} | ${detail.alias[0]}`
16-
: `${patchName}`
17-
1814
return {
19-
title,
20-
keywords: [patchName, ...detail.alias],
15+
keywords: [patchName, ...detail.alias.map((a) => a.name)],
2116
description: patchIntro.slice(0, 170),
2217
openGraph: {
23-
title,
2418
description: patchIntro.slice(0, 170),
2519
type: 'article',
2620
images: [
@@ -34,7 +28,6 @@ export const generateKunMetadataTemplate = (detail: PatchDetail): Metadata => {
3428
},
3529
twitter: {
3630
card: 'summary',
37-
title,
3831
description: patchIntro.slice(0, 170),
3932
images: [detail.banner]
4033
},

app/patch/[id]/metadata.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import type { PatchHeader } from '~/types/api/patch'
77

88
export const generateKunMetadataTemplate = (patch: PatchHeader): Metadata => {
99
const patchName = getPreferredLanguageText(patch.name)
10-
const pageTitle = patch.alias.length
11-
? `${patchName} | ${patch.alias[0]}`
12-
: `${patchName}`
10+
const patchNameJa = patch.name['ja-jp'] ? patch.name['ja-jp'] : ''
11+
const pageTitle =
12+
patchNameJa && patchName !== patchNameJa
13+
? `${patchName} | ${patchNameJa}`
14+
: `${patchName}`
1315

1416
if (patch.content_limit === 'nsfw') {
1517
return generateNullMetadata(pageTitle)

components/patch/header/Actions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export const PatchHeaderActions = ({ patch }: PatchHeaderActionsProps) => {
152152
</div>
153153

154154
<p className="text-xs text-default-500">
155-
收藏后, 有新补丁资源发布时, 您将收到通知
155+
收藏游戏后, 有新补丁资源发布时, 您将收到通知
156156
</p>
157157

158158
<Modal isOpen={isOpen} onClose={onClose} placement="center">

components/patch/header/Info.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client'
22

3-
import { Chip, Tooltip } from '@heroui/react'
3+
import { Chip, Divider, Tooltip } from '@heroui/react'
44
import { KunCardStats } from '~/components/kun/CardStats'
55
import { KunUser } from '~/components/kun/floating-card/KunUser'
66
import { formatDistanceToNow } from '~/utils/formatDistanceToNow'
@@ -122,6 +122,10 @@ export const PatchHeaderInfo = ({ patch }: PatchHeaderInfoProps) => {
122122
<Tags patch={patch} />
123123
</div>
124124

125+
<PatchHeaderActions patch={patch} />
126+
127+
<Divider />
128+
125129
<div className="flex flex-col items-start justify-between gap-4 sm:flex-row sm:items-center">
126130
<KunUser
127131
user={patch.user}
@@ -152,8 +156,6 @@ export const PatchHeaderInfo = ({ patch }: PatchHeaderInfoProps) => {
152156
isMobile={false}
153157
/>
154158
</div>
155-
156-
<PatchHeaderActions patch={patch} />
157159
</div>
158160

159161
<Modal

components/patch/introduction/section/Gallery.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client'
22

3-
import { Checkbox, Image } from '@heroui/react'
3+
import { Checkbox, Chip, Image } from '@heroui/react'
44
import { useMemo, useState } from 'react'
55
import type { PatchDetail } from '~/types/api/patch'
66

@@ -51,6 +51,20 @@ export const GallerySection = ({ detail }: { detail: PatchDetail }) => {
5151
alt={s.image_id}
5252
className="w-full h-full object-cover"
5353
/>
54+
55+
<div className="absolute space-x-2 bottom-2 right-2 z-10">
56+
{s.sexual > 0 && (
57+
<Chip size="sm" variant="solid" color="warning">
58+
色情
59+
</Chip>
60+
)}
61+
62+
{s.violence > 0 && (
63+
<Chip size="sm" variant="solid" color="danger">
64+
暴力
65+
</Chip>
66+
)}
67+
</div>
5468
</div>
5569
))}
5670
</div>

components/patch/introduction/section/Overview.tsx

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,39 @@ export const OverviewSection = ({ detail }: { detail: PatchDetail }) => {
8989
{detail.vndbId && (
9090
<div className="flex items-center gap-2 text-sm text-default-500">
9191
<Link className="size-4" />
92-
<span>VNDB ID: {detail.vndbId}</span>
92+
<span>
93+
VNDB ID:{' '}
94+
{
95+
<HeroLink
96+
isExternal
97+
showAnchorIcon
98+
underline="always"
99+
href={`https://vndb.org/${detail.vndbId}`}
100+
size="sm"
101+
>
102+
{detail.vndbId}
103+
</HeroLink>
104+
}
105+
</span>
93106
</div>
94107
)}
95108
{detail.bid && (
96109
<div className="flex items-center gap-2 text-sm text-default-500">
97110
<Tv className="size-4" />
98-
<span>Bangumi ID: {detail.bid}</span>
111+
<div>
112+
Bangumi ID:{' '}
113+
{
114+
<HeroLink
115+
isExternal
116+
showAnchorIcon
117+
underline="always"
118+
href={`https://bangumi.tv/subject/${detail.bid}`}
119+
size="sm"
120+
>
121+
{detail.bid}
122+
</HeroLink>
123+
}
124+
</div>
99125
</div>
100126
)}
101127
</div>

components/patch/introduction/section/Tag.tsx

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
'use client'
22

33
import { Tabs, Tab } from '@heroui/tabs'
4-
import { Chip, Tooltip, Link, Checkbox } from '@heroui/react'
4+
import { Chip, Tooltip, Link, Checkbox, ScrollShadow } from '@heroui/react'
55
import { useMemo, useState } from 'react'
66
import { getPreferredLanguageText } from '~/utils/getPreferredLanguageText'
77
import type { PatchDetail } from '~/types/api/patch'
8+
import { KunNull } from '~/components/kun/Null'
89

910
export const TagSection = ({ detail }: { detail: PatchDetail }) => {
1011
const [provider, setProvider] = useState<'vndb' | 'bangumi'>('vndb')
@@ -41,33 +42,41 @@ export const TagSection = ({ detail }: { detail: PatchDetail }) => {
4142
</div>
4243
</div>
4344

44-
<div className="flex flex-wrap gap-2">
45-
{tags.map((tag) => (
46-
<Tooltip
47-
key={`${tag.provider}-${tag.id}`}
48-
content={`分类: ${tag.category}`}
49-
>
50-
<Chip
51-
as={Link}
52-
href={
53-
tag.provider === 'vndb' ? `/tag/${tag.id}` : `/tag/${tag.id}`
54-
}
55-
color={
56-
tag.category === 'content'
57-
? 'primary'
58-
: tag.category === 'sexual'
59-
? 'danger'
60-
: 'success'
61-
}
62-
variant="flat"
45+
<ScrollShadow className="max-h-[300px]">
46+
<div className="flex flex-wrap gap-2">
47+
{tags.map((tag) => (
48+
<Tooltip
49+
key={`${tag.provider}-${tag.id}`}
50+
content={`${tag.count} 个 Galgame 含有此标签`}
6351
>
64-
{`${getPreferredLanguageText(tag.name)}+${tag.count}`}
65-
{tag.spoiler_level > 0 ? ' · 剧透' : ''}
66-
</Chip>
67-
</Tooltip>
68-
))}
69-
{tags.length === 0 && <Chip>暂无标签</Chip>}
70-
</div>
52+
<Chip
53+
as={Link}
54+
href={
55+
tag.provider === 'vndb' ? `/tag/${tag.id}` : `/tag/${tag.id}`
56+
}
57+
color={
58+
tag.category === 'content'
59+
? 'primary'
60+
: tag.category === 'sexual'
61+
? 'danger'
62+
: 'success'
63+
}
64+
variant="flat"
65+
>
66+
{`${getPreferredLanguageText(tag.name)} +${tag.count}`}
67+
{tag.spoiler_level > 0 ? (
68+
<span className="font-bold text-warning-600"> *剧透</span>
69+
) : (
70+
''
71+
)}
72+
</Chip>
73+
</Tooltip>
74+
))}
75+
{tags.length === 0 && (
76+
<KunNull message="暂无标签, 或者您未开启网站 NSFW 模式" />
77+
)}
78+
</div>
79+
</ScrollShadow>
7180
</section>
7281
)
7382
}

0 commit comments

Comments
 (0)