Skip to content

Commit 639df6a

Browse files
committed
feat(galgame): mini gallery thumbnails, min-width grid, per-rating ring badges
- Thumbnails load the image_service `mini` variant (~31KB) instead of the full 1920x1080 image; the lightbox still opens full-res. - Replace the fixed 5-col grid with auto-fill minmax(180px, 1fr) so tiles never shrink below ~180px in a narrow content column (still 2 cols on phones). - Per-tile double rating ring: outer band = 色情 (warning), inner = 暴力 (danger), colour depth = level (轻/中/高); drawn as nested inset box-shadows on a pointer-events-none overlay (a single rated axis draws one edge ring). The 分级筛选 popover gains a legend decoding the colours.
1 parent 88daae8 commit 639df6a

3 files changed

Lines changed: 49 additions & 3 deletions

File tree

apps/web/app/components/galgame/Gallery.vue

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,37 @@ const countLevels = (axis: 'sexual' | 'violence'): Record<number, number> => {
7575
}
7676
const sexualCounts = computed(() => countLevels('sexual'))
7777
const violenceCounts = computed(() => countLevels('violence'))
78+
79+
// Grid thumbnails load the `mini` variant (every screenshot has one in
80+
// image_service — verified) instead of the full 1920×1080 image; the lightbox
81+
// still opens the full-resolution src. withImageVariant only rewrites real
82+
// image_service .webp URLs, so the /image/<hash> fallback (a row without
83+
// cdn_url) returns the full image unchanged — acceptable.
84+
const thumbSrc = (s: GalgameScreenshot) =>
85+
s.cdn_url ? withImageVariant(s.cdn_url, 'mini') : galgameImageSrc(s)
86+
87+
// Per-tile rating rings: outer band = 色情 (warning), inner band = 暴力
88+
// (danger) — same colour mapping as the editor's rating badges; colour depth =
89+
// level (轻/中/高). Rendered as nested INSET box-shadows on a pointer-events-none
90+
// overlay above the image, so they can't be clipped or block clicks. An axis
91+
// with no rating draws nothing; a single rated axis draws one edge ring (its
92+
// colour says which).
93+
const RING_W = 2.5 // px per band
94+
const RING_DEPTH: Record<number, number> = { 1: 60, 2: 80, 3: 100 }
95+
const ringColor = (token: 'warning' | 'danger', level: number) =>
96+
`color-mix(in oklab, var(--color-${token}) ${RING_DEPTH[level] ?? 100}%, transparent)`
97+
98+
const ratingRing = (s: GalgameScreenshot) => {
99+
const shadows: string[] = []
100+
if (s.sexual >= 1) {
101+
shadows.push(`inset 0 0 0 ${RING_W}px ${ringColor('warning', s.sexual)}`)
102+
}
103+
if (s.violence >= 1) {
104+
const inset = s.sexual >= 1 ? RING_W * 2 : RING_W
105+
shadows.push(`inset 0 0 0 ${inset}px ${ringColor('danger', s.violence)}`)
106+
}
107+
return { boxShadow: shadows.join(', ') }
108+
}
78109
</script>
79110

80111
<template>
@@ -91,8 +122,11 @@ const violenceCounts = computed(() => countLevels('violence'))
91122
</div>
92123

93124
<KunLightboxGallery v-if="sorted.length">
125+
<!-- auto-fill min-width grid: tiles never shrink below ~180px (a fixed
126+
5-col grid made them tiny in a narrow content column). 2 cols on
127+
phones, then as many ≥180px columns as fit. -->
94128
<div
95-
class="grid grid-cols-2 gap-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5"
129+
class="grid grid-cols-2 gap-2 sm:grid-cols-[repeat(auto-fill,minmax(180px,1fr))]"
96130
>
97131
<KunLightboxGalleryItem
98132
v-for="s in sorted"
@@ -109,7 +143,7 @@ const violenceCounts = computed(() => countLevels('violence'))
109143
@click="open"
110144
>
111145
<KunImage
112-
:src="galgameImageSrc(s)"
146+
:src="thumbSrc(s)"
113147
:alt="s.caption || ''"
114148
loading="lazy"
115149
object-fit="cover"
@@ -122,6 +156,12 @@ const violenceCounts = computed(() => countLevels('violence'))
122156
>
123157
{{ s.caption }}
124158
</div>
159+
<!-- rating rings: outer=色情 inner=暴力, depth=level -->
160+
<div
161+
v-if="s.sexual >= 1 || s.violence >= 1"
162+
class="pointer-events-none absolute inset-0 rounded-lg"
163+
:style="ratingRing(s)"
164+
/>
125165
</button>
126166
</KunLightboxGalleryItem>
127167
</div>

apps/web/app/components/galgame/GalleryFilter.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@ const confirmViolence = () => {
134134
</div>
135135
</template>
136136
</div>
137+
138+
<KunDivider />
139+
<p class="text-default-400 text-xs leading-relaxed">
140+
缩略图描边:<span class="text-warning-500">外圈 = 色情</span> ·
141+
<span class="text-danger-500">内圈 = 暴力</span>,颜色越深级别越高。
142+
</p>
137143
</div>
138144
</KunPopover>
139145

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-forum",
3-
"version": "6.0.25",
3+
"version": "6.0.26",
44
"private": true,
55
"packageManager": "pnpm@10.12.1",
66
"workspaces": [

0 commit comments

Comments
 (0)