Skip to content

Commit 9108571

Browse files
committed
feat: adding filter bar for galgame companies, tags and resources
1 parent c88883c commit 9108571

File tree

10 files changed

+95
-33
lines changed

10 files changed

+95
-33
lines changed

components/edit/toolset/Toolset.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ const handleUpdatePageLink = (value: string | number) => {
141141
</div>
142142

143143
<div class="space-y-2">
144-
<div class="text-xl font-medium">主页 / 下载链接</div>
144+
<div class="text-xl font-medium">主页</div>
145145
<KunTextarea
146146
:model-value="form.homepage.toString()"
147147
@update:model-value="handleUpdatePageLink"
148-
placeholder="如果有多个链接, 使用英语逗号分隔每个下载链接"
148+
placeholder="工具的官网, GitHub 仓库等等, 如果有多个链接, 使用英语逗号分隔每个下载链接"
149149
/>
150150
</div>
151151

components/galgame/card/Nav.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ const toggleIncludeProvider = (key: ProviderKey) => {
5353
const toggleExcludeOnlyProvider = (key: ProviderKey) => {
5454
advStore.toggleExcludeOnlyProvider(key)
5555
}
56+
const props = defineProps<{ showAdvanced?: boolean }>()
5657
</script>
5758

5859
<template>
@@ -99,6 +100,7 @@ const toggleExcludeOnlyProvider = (key: ProviderKey) => {
99100

100101
<div class="flex shrink-0 items-center gap-2">
101102
<KunPopover
103+
v-if="props.showAdvanced !== false"
102104
:auto-position="true"
103105
position="bottom-end"
104106
:inner-class="'min-w-64 p-3'"

components/galgame/rating/Publish.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,10 @@ const submit = async () => {
342342
auto-grow
343343
/>
344344

345+
<div v-if="showAdvanced" class="pt-2">
346+
<GalgameRatingAdvanced v-model="dims" />
347+
</div>
348+
345349
<div class="flex items-center justify-between">
346350
<KunButton variant="flat" @click="showAdvanced = !showAdvanced">
347351
{{ showAdvanced ? '收起高级评分' : '展开高级评分' }}
@@ -360,10 +364,6 @@ const submit = async () => {
360364
如需长评, 建议前往话题区发布话题后将链接放在短评中。评分可较为随意填写,
361365
我们的算法会帮您摆平一切!
362366
</p>
363-
364-
<div v-if="showAdvanced" class="pt-2">
365-
<GalgameRatingAdvanced v-model="dims" />
366-
</div>
367367
</div>
368368
</KunModal>
369369
</template>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "kun-galgame-nuxt3",
3-
"version": "4.4.75",
3+
"version": "4.4.76",
44
"packageManager": "[email protected]",
55
"private": true,
66
"scripts": {

pages/galgame-official/[id].vue

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@ const officialId = computed(() => {
1111
return Number((route.params as { id: string }).id)
1212
})
1313
14-
const pageData = reactive({
15-
page: 1,
16-
limit: 24,
17-
officialId: officialId.value
18-
})
14+
const { page, limit, type, language, platform, sortField, sortOrder } =
15+
storeToRefs(useTempGalgameStore())
1916
2017
const showOfficialModal = ref(false)
2118
const editingOfficial = ref<UpdateGalgameOfficialPayload>(
@@ -26,7 +23,16 @@ const { data, status } = await useFetch(
2623
`/api/galgame-official/${officialId.value}`,
2724
{
2825
method: 'GET',
29-
query: pageData,
26+
query: {
27+
page,
28+
limit,
29+
type,
30+
language,
31+
platform,
32+
sortField,
33+
sortOrder,
34+
officialId
35+
},
3036
...kungalgameResponseHandler
3137
}
3238
)
@@ -121,6 +127,8 @@ useKunSeoMeta({
121127
</template>
122128
</KunHeader>
123129

130+
<GalgameCardNav :show-advanced="false" />
131+
124132
<GalgameOfficialModal
125133
v-model="showOfficialModal"
126134
:initial-data="editingOfficial"
@@ -134,9 +142,9 @@ useKunSeoMeta({
134142
/>
135143

136144
<KunPagination
137-
v-if="data.galgameCount > pageData.limit"
138-
v-model:current-page="pageData.page"
139-
:total-page="Math.ceil(data.galgameCount / pageData.limit)"
145+
v-if="data.galgameCount > limit"
146+
v-model:current-page="page"
147+
:total-page="Math.ceil(data.galgameCount / limit)"
140148
:is-loading="status === 'pending'"
141149
/>
142150

pages/galgame-tag/[id].vue

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,24 @@ const tagId = computed(() => {
1111
return Number((route.params as { id: string }).id)
1212
})
1313
14-
const pageData = reactive({
15-
page: 1,
16-
limit: 24,
17-
tagId: tagId.value
18-
})
14+
const { page, limit, type, language, platform, sortField, sortOrder } =
15+
storeToRefs(useTempGalgameStore())
1916
2017
const showTagModal = ref(false)
2118
const editingTag = ref<UpdateGalgameTagPayload>({} as UpdateGalgameTagPayload)
2219
2320
const { data, status } = await useFetch(`/api/galgame-tag/${tagId.value}`, {
2421
method: 'GET',
25-
query: pageData,
22+
query: {
23+
page,
24+
limit,
25+
type,
26+
language,
27+
platform,
28+
sortField,
29+
sortOrder,
30+
tagId
31+
},
2632
...kungalgameResponseHandler
2733
})
2834
@@ -124,6 +130,8 @@ if (data.value) {
124130
</template>
125131
</KunHeader>
126132

133+
<GalgameCardNav :show-advanced="false" />
134+
127135
<GalgameTagModal
128136
v-model="showTagModal"
129137
:initial-data="editingTag"
@@ -137,9 +145,9 @@ if (data.value) {
137145
/>
138146

139147
<KunPagination
140-
v-if="data.galgameCount > pageData.limit"
141-
v-model:current-page="pageData.page"
142-
:total-page="Math.ceil(data.galgameCount / pageData.limit)"
148+
v-if="data.galgameCount > limit"
149+
v-model:current-page="page"
150+
:total-page="Math.ceil(data.galgameCount / limit)"
143151
:is-loading="status === 'pending'"
144152
/>
145153

server/api/galgame-official/[name].get.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,23 @@ export default defineEventHandler(async (event) => {
1212

1313
const nsfw = getNSFWCookie(event)
1414

15-
const { officialId, page, limit } = input
15+
const {
16+
officialId,
17+
page,
18+
limit,
19+
type,
20+
language,
21+
platform,
22+
sortField,
23+
sortOrder
24+
} = input
1625
const skip = (page - 1) * limit
1726

27+
const resourceFilters = []
28+
if (type !== 'all') resourceFilters.push({ type })
29+
if (language !== 'all') resourceFilters.push({ language })
30+
if (platform !== 'all') resourceFilters.push({ platform })
31+
1832
const data = await prisma.galgame_official.findUnique({
1933
where: { id: officialId },
2034
include: {
@@ -27,14 +41,16 @@ export default defineEventHandler(async (event) => {
2741
galgame: {
2842
where: {
2943
galgame: {
30-
content_limit: nsfw === 'sfw' ? 'sfw' : undefined
44+
content_limit: nsfw === 'sfw' ? 'sfw' : undefined,
45+
resource: { some: { AND: resourceFilters } }
3146
}
3247
},
3348
skip,
3449
take: limit,
3550
orderBy: {
3651
galgame: {
37-
resource_update_time: 'desc'
52+
[sortField === 'time' ? 'resource_update_time' : sortField]:
53+
sortOrder
3854
}
3955
},
4056
include: {

server/api/galgame-tag/[name].get.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@ export default defineEventHandler(async (event) => {
1212

1313
const nsfw = getNSFWCookie(event)
1414

15-
const { tagId, page, limit } = input
15+
const { tagId, page, limit, type, language, platform, sortField, sortOrder } =
16+
input
1617
const skip = (page - 1) * limit
1718

19+
const resourceFilters = []
20+
if (type !== 'all') resourceFilters.push({ type })
21+
if (language !== 'all') resourceFilters.push({ language })
22+
if (platform !== 'all') resourceFilters.push({ platform })
23+
1824
const data = await prisma.galgame_tag.findUnique({
1925
where: { id: tagId },
2026
include: {
@@ -27,14 +33,16 @@ export default defineEventHandler(async (event) => {
2733
galgame: {
2834
where: {
2935
galgame: {
30-
content_limit: nsfw === 'sfw' ? 'sfw' : undefined
36+
content_limit: nsfw === 'sfw' ? 'sfw' : undefined,
37+
resource: { some: { AND: resourceFilters } }
3138
}
3239
},
3340
skip,
3441
take: limit,
3542
orderBy: {
3643
galgame: {
37-
resource_update_time: 'desc'
44+
[sortField === 'time' ? 'resource_update_time' : sortField]:
45+
sortOrder
3846
}
3947
},
4048
include: {

validations/galgame-official.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { z } from 'zod'
22
import { KUN_GALGAME_OFFICIAL_TYPE } from '~/constants/galgameOfficial'
3+
import {
4+
KUN_RESOURCE_LANGUAGE_CONST,
5+
KUN_RESOURCE_PLATFORM_CONST,
6+
KUN_RESOURCE_TYPE_CONST
7+
} from '~/constants/galgame'
38

49
export const getGalgameOfficialSchema = z.object({
510
page: z.coerce.number().min(1).max(9999999),
@@ -9,7 +14,12 @@ export const getGalgameOfficialSchema = z.object({
914
export const getGalgameByOfficialSchema = getGalgameOfficialSchema.merge(
1015
z.object({
1116
officialId: z.coerce.number().min(1).max(9999999),
12-
limit: z.coerce.number().min(1).max(24)
17+
limit: z.coerce.number().min(1).max(24),
18+
type: z.enum([...KUN_RESOURCE_TYPE_CONST, 'all']),
19+
language: z.enum([...KUN_RESOURCE_LANGUAGE_CONST, 'all']),
20+
platform: z.enum([...KUN_RESOURCE_PLATFORM_CONST, 'all']),
21+
sortField: z.enum(['time', 'created', 'view']),
22+
sortOrder: z.enum(['asc', 'desc'])
1323
})
1424
)
1525

validations/galgame-tag.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { z } from 'zod'
22
import { KUN_GALGAME_TAG_TYPE } from '~/constants/galgameTag'
3+
import {
4+
KUN_RESOURCE_LANGUAGE_CONST,
5+
KUN_RESOURCE_PLATFORM_CONST,
6+
KUN_RESOURCE_TYPE_CONST
7+
} from '~/constants/galgame'
38

49
export const getGalgameTagSchema = z.object({
510
page: z.coerce.number().min(1).max(9999999),
@@ -9,7 +14,12 @@ export const getGalgameTagSchema = z.object({
914
export const getGalgameByTagSchema = getGalgameTagSchema.merge(
1015
z.object({
1116
tagId: z.coerce.number().min(1).max(9999999),
12-
limit: z.coerce.number().min(1).max(24)
17+
limit: z.coerce.number().min(1).max(24),
18+
type: z.enum([...KUN_RESOURCE_TYPE_CONST, 'all']),
19+
language: z.enum([...KUN_RESOURCE_LANGUAGE_CONST, 'all']),
20+
platform: z.enum([...KUN_RESOURCE_PLATFORM_CONST, 'all']),
21+
sortField: z.enum(['time', 'created', 'view']),
22+
sortOrder: z.enum(['asc', 'desc'])
1323
})
1424
)
1525

0 commit comments

Comments
 (0)