Skip to content

Commit c5b6949

Browse files
committed
feat: migrate galgame page except pull request
1 parent db3d593 commit c5b6949

30 files changed

Lines changed: 191 additions & 170 deletions

components/galgame/Favorite.vue

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
<script setup lang="ts">
22
const props = defineProps<{
3-
gid: number
4-
toUid: number
5-
favoritesCount: number
6-
isFavorite: boolean
3+
galgameId: number
4+
targetUserId: number
5+
favoriteCount: number
6+
isFavorited: boolean
77
}>()
88
99
const { id } = usePersistUserStore()
10-
const isFavorite = ref(props.isFavorite)
11-
const favoritesCount = ref(props.favoritesCount)
10+
const isFavorited = ref(props.isFavorited)
11+
const favoriteCount = ref(props.favoriteCount)
1212
1313
const toggleFavoriteGalgame = async () => {
14-
const result = await $fetch(`/api/galgame/${props.gid}/favorite`, {
14+
const result = await $fetch(`/api/galgame/${props.galgameId}/favorite`, {
1515
method: 'PUT',
1616
watch: false,
17+
body: { galgameId: props.galgameId },
1718
...kungalgameResponseHandler
1819
})
1920
2021
if (result) {
21-
favoritesCount.value += isFavorite.value ? -1 : 1
22+
favoriteCount.value += isFavorited.value ? -1 : 1
2223
23-
if (!isFavorite.value) {
24+
if (!isFavorited.value) {
2425
useMessage(10526, 'success')
2526
} else {
2627
useMessage(10527, 'success')
2728
}
2829
29-
isFavorite.value = !isFavorite.value
30+
isFavorited.value = !isFavorited.value
3031
}
3132
}
3233
@@ -47,14 +48,14 @@ const handleClickFavorite = () => {
4748
<KunTooltip text="收藏">
4849
<KunButton
4950
:is-icon-only="true"
50-
:variant="isFavorite ? 'flat' : 'light'"
51-
:color="isFavorite ? 'secondary' : 'default'"
52-
:size="favoritesCount ? 'md' : 'lg'"
51+
:variant="isFavorited ? 'flat' : 'light'"
52+
:color="isFavorited ? 'secondary' : 'default'"
53+
:size="favoriteCount ? 'md' : 'lg'"
5354
class-name="gap-1"
5455
@click="handleClickFavorite"
5556
>
5657
<KunIcon name="lucide:heart" />
57-
<span v-if="favoritesCount">{{ favoritesCount }}</span>
58+
<span v-if="favoriteCount">{{ favoriteCount }}</span>
5859
</KunButton>
5960
</KunTooltip>
6061
</template>

components/galgame/Footer.vue

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@ const galgame = inject<GalgameDetail>('galgame')
1414
</KunBadge>
1515

1616
<div class="flex gap-1">
17-
<KunTooltip :text="`浏览量: ${galgame.views}`">
17+
<KunTooltip :text="`浏览量: ${galgame.view}`">
1818
<KunBadge size="md">
1919
<KunIcon name="lucide:eye" />
20-
<span>{{ formatNumber(galgame.views) }}</span>
20+
<span>{{ formatNumber(galgame.view) }}</span>
2121
</KunBadge>
2222
</KunTooltip>
2323

2424
<GalgameLike
25-
:gid="galgame.gid"
26-
:to-uid="galgame.user.uid"
27-
:likes-count="galgame.likes.count"
28-
:is-liked="galgame.likes.isLiked"
25+
:galgame-id="galgame.id"
26+
:target-user-id="galgame.user.id"
27+
:like-count="galgame.likeCount"
28+
:is-liked="galgame.isLiked"
2929
/>
3030

3131
<GalgameFavorite
32-
:gid="galgame.gid"
33-
:to-uid="galgame.user.uid"
34-
:favorites-count="galgame.favorites.count"
35-
:is-favorite="galgame.favorites.isFavorite"
32+
:galgame-id="galgame.id"
33+
:target-user-id="galgame.user.id"
34+
:favorite-count="galgame.favoriteCount"
35+
:is-favorited="galgame.isFavorited"
3636
/>
3737

3838
<GalgameRewrite :galgame="galgame" />

components/galgame/Galgame.vue

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,6 @@ const props = defineProps<{
1111
1212
provide<GalgameDetail>('galgame', props.galgame)
1313
14-
const { data } = await useFetch(
15-
`/api/galgame/${props.galgame.gid}/contributor`,
16-
{
17-
method: 'GET',
18-
watch: false,
19-
...kungalgameResponseHandler
20-
}
21-
)
22-
2314
const activeTab = ref<GalgameDetailSectionTabType>('comment')
2415
</script>
2516

@@ -35,9 +26,9 @@ const activeTab = ref<GalgameDetailSectionTabType>('comment')
3526

3627
<div class="space-y-3">
3728
<p>本游戏项目的贡献者</p>
38-
<div class="flex items-center gap-1" v-if="data">
29+
<div class="flex items-center gap-1">
3930
<KunTooltip
40-
v-for="(user, index) in data"
31+
v-for="(user, index) in galgame.contributor"
4132
:key="index"
4233
:text="user.name"
4334
>
@@ -50,7 +41,7 @@ const activeTab = ref<GalgameDetailSectionTabType>('comment')
5041

5142
<GalgameResource />
5243

53-
<GalgameSeries v-if="galgame.series.length" />
44+
<GalgameSeries v-if="galgame.series" />
5445

5546
<KunTab
5647
:items="galgameDetailSectionTabs"
@@ -60,9 +51,9 @@ const activeTab = ref<GalgameDetailSectionTabType>('comment')
6051
/>
6152
<KunCard :is-hoverable="false">
6253
<GalgameCommentContainer
63-
v-if="data && activeTab === 'comment'"
64-
:user-data="data"
65-
:to-user="galgame.user"
54+
v-if="activeTab === 'comment'"
55+
:user-data="galgame.contributor"
56+
:target-user="galgame.user"
6657
/>
6758
<GalgameHistory v-if="activeTab === 'history'" />
6859
<GalgameLink v-if="activeTab === 'link'" />

components/galgame/Like.vue

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
<script setup lang="ts">
22
const props = defineProps<{
3-
gid: number
4-
toUid: number
5-
likesCount: number
3+
galgameId: number
4+
targetUserId: number
5+
likeCount: number
66
isLiked: boolean
77
}>()
88
99
const { id } = usePersistUserStore()
1010
const isLiked = ref(props.isLiked)
11-
const likesCount = ref(props.likesCount)
11+
const likesCount = ref(props.likeCount)
1212
1313
const toggleLikeGalgame = async () => {
14-
const result = await $fetch(`/api/galgame/${props.gid}/like`, {
14+
const result = await $fetch(`/api/galgame/${props.galgameId}/like`, {
1515
method: 'PUT',
1616
watch: false,
17+
body: { galgameId: props.galgameId },
1718
...kungalgameResponseHandler
1819
})
1920
@@ -39,7 +40,7 @@ const handleClickLike = () => {
3940
useMessage(10532, 'warn', 5000)
4041
return
4142
}
42-
if (id === props.toUid) {
43+
if (id === props.targetUserId) {
4344
useMessage(10533, 'warn')
4445
return
4546
}

components/galgame/Rewrite.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const handleRewriteGalgame = async (galgame: GalgameDetail) => {
1111
const { introduction, markdown, series, ...rest } = galgame
1212
galgamePR.value[0] = {
1313
introduction: markdown,
14-
series: series.map((s) => s.toString()),
14+
series: [],
1515
...rest
1616
}
1717
await navigateTo('/edit/galgame/rewrite')

components/galgame/Title.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,15 @@ const props = defineProps<{
55
galgame: GalgameDetail
66
}>()
77
8-
const { uid, roles } = usePersistUserStore()
8+
const { id, role } = usePersistUserStore()
99
1010
const initialImageUrl = ref('')
1111
const isShowUpload = ref(false)
1212
const route = useRoute()
1313
const gid = computed(() => {
1414
return parseInt((route.params as { gid: string }).gid)
1515
})
16-
const hasPermission = computed(
17-
() => props.galgame.user.uid === uid || roles >= 2
18-
)
16+
const hasPermission = computed(() => props.galgame.user.id === id || role >= 2)
1917
2018
const handleChangeBanner = async () => {
2119
const imageBlob = await getImage('kun-galgame-rewrite-banner')

components/galgame/comment/Comment.vue

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,30 @@ const props = defineProps<{
1111
const galgame = inject<GalgameDetail>('galgame')
1212
1313
const { commentToUid } = storeToRefs(useTempGalgameResourceStore())
14-
const { uid, roles } = usePersistUserStore()
14+
const { id, role } = usePersistUserStore()
1515
1616
const isShowComment = ref(false)
1717
const isShowDelete = computed(
18-
() =>
19-
props.comment.user?.uid === uid || galgame?.user.uid === uid || roles >= 2
18+
() => props.comment.user?.id === id || galgame?.user.id === id || role >= 2
2019
)
2120
2221
const handleClickComment = (uid: number) => {
2322
isShowComment.value = !isShowComment.value
2423
commentToUid.value = uid
2524
}
2625
27-
const handleDeleteComment = async (gid: number, gcid: number) => {
26+
const handleDeleteComment = async (
27+
galgameId: number,
28+
galgameCommentId: number
29+
) => {
2830
const res = await useComponentMessageStore().alert('您确定删除评论吗?')
2931
if (!res) {
3032
return
3133
}
3234
33-
const result = await $fetch(`/api/galgame/${gid}/comment`, {
35+
const result = await $fetch(`/api/galgame/${galgameId}/comment`, {
3436
method: 'DELETE',
35-
query: { gcid },
37+
query: { galgameCommentId },
3638
watch: false,
3739
...kungalgameResponseHandler
3840
})
@@ -51,10 +53,13 @@ const handleDeleteComment = async (gid: number, gcid: number) => {
5153
<div class="flex w-full flex-col space-y-2">
5254
<div class="flex flex-wrap items-center">
5355
<span class="text-default-700">{{ comment.user.name }}</span>
54-
<div v-if="comment.toUser">
56+
<div v-if="comment.targetUser">
5557
<span class="mx-2">=></span>
56-
<KunLink underline="hover" :to="`/user/${comment.toUser.uid}/info`">
57-
{{ `${comment.toUser.name}` }}
58+
<KunLink
59+
underline="hover"
60+
:to="`/user/${comment.targetUser.id}/info`"
61+
>
62+
{{ `${comment.targetUser.name}` }}
5863
</KunLink>
5964
</div>
6065
</div>
@@ -63,14 +68,14 @@ const handleDeleteComment = async (gid: number, gcid: number) => {
6368

6469
<div class="flex items-end justify-between">
6570
<span class="text-default-500 text-sm">
66-
发布于 {{ formatTimeDifference(comment.time) }}
71+
发布于 {{ formatTimeDifference(comment.created) }}
6772
</span>
6873

6974
<div class="flex items-center justify-end gap-1">
7075
<KunButton
7176
variant="flat"
7277
class-name="gap-1"
73-
@click="handleClickComment(comment.user.uid)"
78+
@click="handleClickComment(comment.user.id)"
7479
>
7580
回复
7681
</KunButton>
@@ -85,19 +90,28 @@ const handleDeleteComment = async (gid: number, gcid: number) => {
8590
color="danger"
8691
size="lg"
8792
class-name="gap-1"
88-
@click="handleDeleteComment(comment.gid, comment.gcid)"
93+
@click="handleDeleteComment(comment.galgameId, comment.id)"
8994
>
9095
<KunIcon name="lucide:trash-2" />
9196
</KunButton>
9297
</KunTooltip>
9398
</div>
9499
</div>
95100

96-
<GalgameCommentPanel
97-
v-if="isShowComment"
98-
:refresh="refresh"
99-
@close="isShowComment = false"
100-
/>
101+
<Transition
102+
enter-active-class="transition-all duration-300 ease-out"
103+
enter-from-class="opacity-0 max-h-0"
104+
enter-to-class="opacity-100 max-h-96"
105+
leave-active-class="transition-all duration-300 ease-in"
106+
leave-from-class="opacity-100 max-h-96"
107+
leave-to-class="opacity-0 max-h-0"
108+
>
109+
<GalgameCommentPanel
110+
v-if="isShowComment"
111+
:refresh="refresh"
112+
@close="isShowComment = false"
113+
/>
114+
</Transition>
101115
</div>
102116
</KunCard>
103117
</template>

0 commit comments

Comments
 (0)