Skip to content

Commit 6dd610c

Browse files
committed
mod: ad location
1 parent 8241ebe commit 6dd610c

File tree

8 files changed

+163
-123
lines changed

8 files changed

+163
-123
lines changed

app/actions.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
import { getNSFWHeader } from '~/utils/actions/getNSFWHeader'
44
import { getHomeData } from '~/app/api/home/route'
5+
import { verifyHeaderCookie } from '~/utils/actions/verifyHeaderCookie'
56

67
export const kunGetActions = async () => {
78
const nsfwEnable = await getNSFWHeader()
9+
const payload = await verifyHeaderCookie()
10+
811
const response = await getHomeData(nsfwEnable)
9-
return response
12+
return { response, payload }
1013
}

app/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default async function Kun() {
88

99
return (
1010
<div className="container mx-auto my-4 space-y-6">
11-
<HomeContainer {...response} />
11+
<HomeContainer {...response.response} payload={response.payload} />
1212
</div>
1313
)
1414
}

components/home/Container.tsx

Lines changed: 108 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,108 @@
1-
import { Button } from '@heroui/button'
2-
import { ChevronRight } from 'lucide-react'
3-
import { GalgameCard } from '~/components/galgame/Card'
4-
import { ResourceCard } from '~/components/resource/ResourceCard'
5-
import { CommentCard } from '~/components/comment/CommentCard'
6-
import Link from 'next/link'
7-
import { HomeHero } from './Hero'
8-
import type { HomeComment, HomeResource } from '~/types/api/home'
9-
10-
interface Props {
11-
galgames: GalgameCard[]
12-
resources: HomeResource[]
13-
comments: HomeComment[]
14-
}
15-
16-
export const HomeContainer = ({ galgames, resources, comments }: Props) => {
17-
return (
18-
<div className="mx-auto space-y-16 max-w-7xl">
19-
<HomeHero />
20-
21-
<section className="space-y-3 sm:space-y-6">
22-
<div className="flex items-center space-x-4">
23-
<h2 className="text-2xl font-bold">最新 Galgame</h2>
24-
<Button
25-
variant="light"
26-
as={Link}
27-
color="primary"
28-
endContent={<ChevronRight className="size-4" />}
29-
href="/galgame"
30-
>
31-
查看更多
32-
</Button>
33-
</div>
34-
<div className="grid grid-cols-2 gap-2 mx-auto mb-8 sm:gap-6 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
35-
{galgames.map((galgame) => (
36-
<GalgameCard key={galgame.id} patch={galgame} />
37-
))}
38-
</div>
39-
</section>
40-
41-
<section className="space-y-3 sm:space-y-6">
42-
<div className="flex items-center space-x-4">
43-
<h2 className="text-2xl font-bold">最新补丁资源下载</h2>
44-
<Button
45-
variant="light"
46-
as={Link}
47-
color="primary"
48-
endContent={<ChevronRight className="size-4" />}
49-
href="/resource"
50-
>
51-
查看更多
52-
</Button>
53-
</div>
54-
55-
<div className="grid grid-cols-1 gap-3 sm:gap-6 md:grid-cols-2">
56-
{resources.map((resource) => (
57-
<ResourceCard key={resource.id} resource={resource} />
58-
))}
59-
</div>
60-
</section>
61-
62-
<section className="space-y-3 sm:space-y-6">
63-
<div className="flex items-center space-x-4">
64-
<h2 className="text-2xl font-bold">最新评论</h2>
65-
<Button
66-
variant="light"
67-
as={Link}
68-
color="primary"
69-
endContent={<ChevronRight className="size-4" />}
70-
href="/comment"
71-
>
72-
查看更多
73-
</Button>
74-
</div>
75-
76-
<div className="space-y-4">
77-
{comments.map((comment) => (
78-
<CommentCard key={comment.id} comment={comment} />
79-
))}
80-
</div>
81-
</section>
82-
</div>
83-
)
84-
}
1+
import { Button } from '@heroui/button'
2+
import { Image } from '@heroui/image'
3+
import { ChevronRight } from 'lucide-react'
4+
import { GalgameCard } from '~/components/galgame/Card'
5+
import { ResourceCard } from '~/components/resource/ResourceCard'
6+
import { CommentCard } from '~/components/comment/CommentCard'
7+
import Link from 'next/link'
8+
import { HomeHero } from './Hero'
9+
import { kunMoyuMoe } from '~/config/moyu-moe'
10+
import type { HomeComment, HomeResource } from '~/types/api/home'
11+
import type { KunGalgamePayload } from '~/app/api/utils/jwt'
12+
13+
interface Props {
14+
galgames: GalgameCard[]
15+
resources: HomeResource[]
16+
comments: HomeComment[]
17+
payload: KunGalgamePayload | null
18+
}
19+
20+
export const HomeContainer = ({
21+
galgames,
22+
resources,
23+
comments,
24+
payload
25+
}: Props) => {
26+
return (
27+
<div className="mx-auto space-y-8 max-w-7xl">
28+
<HomeHero />
29+
30+
{(!payload || payload.role < 2) && (
31+
<div className="shadow-xl rounded-2xl">
32+
<a
33+
target="_blank"
34+
className="h-full w-full"
35+
href={kunMoyuMoe.ad[0].url}
36+
>
37+
<Image
38+
className="pointer-events-none select-none"
39+
src="/a/moyumoe1.avif"
40+
/>
41+
</a>
42+
</div>
43+
)}
44+
45+
<section className="space-y-3 sm:space-y-6">
46+
<div className="flex items-center space-x-4">
47+
<h2 className="text-2xl font-bold">最新 Galgame</h2>
48+
<Button
49+
variant="light"
50+
as={Link}
51+
color="primary"
52+
endContent={<ChevronRight className="size-4" />}
53+
href="/galgame"
54+
>
55+
查看更多
56+
</Button>
57+
</div>
58+
<div className="grid grid-cols-2 gap-2 mx-auto mb-8 sm:gap-6 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
59+
{galgames.map((galgame) => (
60+
<GalgameCard key={galgame.id} patch={galgame} />
61+
))}
62+
</div>
63+
</section>
64+
65+
<section className="space-y-3 sm:space-y-6">
66+
<div className="flex items-center space-x-4">
67+
<h2 className="text-2xl font-bold">最新补丁资源下载</h2>
68+
<Button
69+
variant="light"
70+
as={Link}
71+
color="primary"
72+
endContent={<ChevronRight className="size-4" />}
73+
href="/resource"
74+
>
75+
查看更多
76+
</Button>
77+
</div>
78+
79+
<div className="grid grid-cols-1 gap-3 sm:gap-6 md:grid-cols-2">
80+
{resources.map((resource) => (
81+
<ResourceCard key={resource.id} resource={resource} />
82+
))}
83+
</div>
84+
</section>
85+
86+
<section className="space-y-3 sm:space-y-6">
87+
<div className="flex items-center space-x-4">
88+
<h2 className="text-2xl font-bold">最新评论</h2>
89+
<Button
90+
variant="light"
91+
as={Link}
92+
color="primary"
93+
endContent={<ChevronRight className="size-4" />}
94+
href="/comment"
95+
>
96+
查看更多
97+
</Button>
98+
</div>
99+
100+
<div className="space-y-4">
101+
{comments.map((comment) => (
102+
<CommentCard key={comment.id} comment={comment} />
103+
))}
104+
</div>
105+
</section>
106+
</div>
107+
)
108+
}

components/kun/top-bar/Brand.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,25 @@ export const KunTopBarBrand = () => {
2020
</div>
2121
}
2222
>
23-
<NavbarBrand className="hidden mr-16 grow-0 md:flex">
23+
<NavbarBrand className="hidden grow-0 md:flex">
2424
<Link className="flex items-center" href="/">
2525
<Image
2626
src="/favicon.webp"
2727
alt={kunMoyuMoe.titleShort}
2828
width={50}
2929
height={50}
3030
priority
31-
className="rounded-2xl"
31+
className="rounded-2xl shrink-0"
3232
/>
33-
<p className="ml-4 mr-2 font-bold text-inherit">
33+
<p className="ml-4 hidden lg:block mr-2 font-bold text-inherit">
3434
{kunMoyuMoe.creator.name}
3535
</p>
36-
<Chip size="sm" variant="flat" color="primary">
36+
<Chip
37+
className="hidden lg:flex"
38+
size="sm"
39+
variant="flat"
40+
color="primary"
41+
>
3742
补丁
3843
</Chip>
3944
</Link>

components/kun/top-bar/KunMobileMenu.tsx

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import Image from 'next/image'
77
import { kunMoyuMoe } from '~/config/moyu-moe'
88
import { kunMobileNavItem } from '~/constants/top-bar'
99
import { Divider } from '@heroui/react'
10-
import { Heart } from 'lucide-react'
10+
import { useUserStore } from '~/store/userStore'
1111

1212
export const KunMobileMenu = () => {
13+
const currentUser = useUserStore((state) => state.user)
14+
1315
return (
1416
<NavbarMenu>
1517
<NavbarMenuItem>
@@ -40,24 +42,26 @@ export const KunMobileMenu = () => {
4042

4143
<Divider className="my-3" />
4244

43-
<NavbarMenuItem>
44-
<div className="space-y-2">
45-
<p>为什么现在的 AI 比人还要 H</p>
46-
<a
47-
className="flex items-center gap-2"
48-
target="_blank"
49-
href="https://s.iloveren.link/s/moyumoe1"
50-
>
51-
<img
52-
src="/a/moyumoe1-button.avif"
53-
className="h-11 dark:opacity-80"
54-
/>
55-
<span className="gap-2 flex items-center text-lg text-secondary px-4 py-2 rounded-2xl bg-secondary/15">
56-
尝试一下 AI 女友
57-
</span>
58-
</a>
59-
</div>
60-
</NavbarMenuItem>
45+
{(!currentUser.uid || currentUser.role < 2) && (
46+
<NavbarMenuItem>
47+
<div className="space-y-2">
48+
<p>为什么现在的 AI 比人还要 H</p>
49+
<a
50+
className="flex items-center gap-2"
51+
target="_blank"
52+
href="https://s.iloveren.link/s/moyumoe1"
53+
>
54+
<img
55+
src="/a/moyumoe1-button.avif"
56+
className="h-11 dark:opacity-80"
57+
/>
58+
<span className="gap-2 flex items-center text-lg text-secondary px-4 py-2 rounded-2xl bg-secondary/15">
59+
尝试一下 AI 女友
60+
</span>
61+
</a>
62+
</div>
63+
</NavbarMenuItem>
64+
)}
6165
</NavbarMenu>
6266
)
6367
}

components/kun/top-bar/TopBar.tsx

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@ import {
2020
Tags,
2121
BookUser,
2222
Clapperboard,
23-
ChartColumnBig,
24-
Heart
23+
ChartColumnBig
2524
} from 'lucide-react'
2625
import { cn } from '~/utils/cn'
2726
import { kunMoyuMoe } from '~/config/moyu-moe'
27+
import { useUserStore } from '~/store/userStore'
2828

2929
export const KunTopBar = () => {
3030
const pathname = usePathname()
31+
const currentUser = useUserStore((state) => state.user)
32+
3133
const [isMenuOpen, setIsMenuOpen] = useState(false)
3234

3335
const items: Array<{ href: string; label: string; icon: React.ReactNode }> = [
@@ -107,7 +109,7 @@ export const KunTopBar = () => {
107109
<Link
108110
href="/galgame"
109111
className={cn(
110-
'text-base',
112+
'text-base shrink-0',
111113
pathname === '/galgame' ? 'text-primary' : 'text-foreground'
112114
)}
113115
>
@@ -119,7 +121,7 @@ export const KunTopBar = () => {
119121
<Link
120122
key={item.href}
121123
className={cn(
122-
'text-base',
124+
'text-base shrink-0',
123125
pathname === item.href ? 'text-primary' : 'text-foreground'
124126
)}
125127
href={item.href}
@@ -129,14 +131,16 @@ export const KunTopBar = () => {
129131
</Link>
130132
))}
131133

132-
<Tooltip disableAnimation content="为什么现在的 AI 比人还要 H">
133-
<a target="_blank" href={kunMoyuMoe.ad[0].url}>
134-
<img
135-
className="h-10 dark:opacity-80"
136-
src="/a/moyumoe1-button.avif"
137-
/>
138-
</a>
139-
</Tooltip>
134+
{(!currentUser.uid || currentUser.role < 2) && (
135+
<Tooltip disableAnimation content="为什么现在的 AI 比人还要 H">
136+
<a target="_blank" href={kunMoyuMoe.ad[0].url}>
137+
<img
138+
className="h-10 dark:opacity-80"
139+
src="/a/moyumoe1-button.avif"
140+
/>
141+
</a>
142+
</Tooltip>
143+
)}
140144
</div>
141145

142146
<KunTopBarUser />

components/resource/detail/ResourceDetail.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import { KunUser } from '~/components/kun/floating-card/KunUser'
1212
import { ResourceLikeButton } from '~/components/patch/resource/ResourceLike'
1313
import { ResourceDownloadCard } from './DownloadCard'
1414
import { Link } from '@heroui/react'
15-
import { KunGalgamePayload } from '~/app/api/utils/jwt'
1615
import { kunMoyuMoe } from '~/config/moyu-moe'
16+
import type { KunGalgamePayload } from '~/app/api/utils/jwt'
1717
import type { PatchResourceDetail } from '~/types/api/resource'
1818

1919
interface Props {

config/moyu-moe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export const kunMoyuMoe: KunSiteConfig = {
6060
ad: [
6161
{
6262
name: 'DZMM',
63-
url: 'https://s.iloveren.link/s/moyumoe1'
63+
url: 'https://www.xn--i8s951di30azba.com/?rf=8e6ec4cf'
6464
}
6565
]
6666
}

0 commit comments

Comments
 (0)