Skip to content

Commit d6dd959

Browse files
committed
feat: support NSFW topic
1 parent afd17ba commit d6dd959

File tree

35 files changed

+190
-72
lines changed

35 files changed

+190
-72
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
"Deatte",
7070
"Dedup",
7171
"defu",
72+
"demi",
7273
"desu",
7374
"dfan",
7475
"discordbot",
@@ -100,6 +101,7 @@
100101
"Flowlove",
101102
"fontawesome",
102103
"formkit",
104+
"frontmatter",
103105
"Frontwing",
104106
"Fureraba",
105107
"Futaba",
@@ -264,6 +266,7 @@
264266
"nitropack",
265267
"nmid",
266268
"noarchive",
269+
"nolyfill",
267270
"non-moe",
268271
"nonmoe",
269272
"noopener",

components/edit/topic/MetadataEditor.vue

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
const MAX_SECTIONS = 3
1010
const MAX_TAGS = 7
1111
12-
const { category, section, tags } = useTopicEditorStore()
12+
const { category, section, tags, isNSFW } = useTopicEditorStore()
1313
const tagInput = ref('')
1414
const isTagInputFocused = ref(false)
1515
@@ -201,5 +201,24 @@ const handleTagInputBackspace = () => {
201201
话题至少选择一个标签,最多 {{ MAX_TAGS }} 个
202202
</p>
203203
</div>
204+
205+
<div class="space-y-4">
206+
<h3 class="flex items-center gap-2 text-lg font-semibold">
207+
<Icon name="lucide:shield-alert" class="h-5 w-5" />
208+
NSFW 设置
209+
</h3>
210+
<KunCheckBox
211+
v-model="isNSFW"
212+
type="single"
213+
label="该话题包含 NSFW 内容 (R18 等)"
214+
color="primary"
215+
/>
216+
<p class="text-default-500 mt-2 text-sm">
217+
勾选后, 未开启网站 NSFW 模式的用户将无法看到该话题, 和 Galgame 的 NSFW
218+
标准一样, 看起来不能在公司报告大会上放在 PPT 里展示的话题都是 NSFW,
219+
总之就是越严越好,可以错杀不可以放过 (另外, 只允许萌萌的涩涩,
220+
不允许纯粹的色情废料)
221+
</p>
222+
</div>
204223
</div>
205224
</template>

components/galgame/Tag.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const filteredTags = computed(() => {
6464
:key="key"
6565
@click="toggleCategory(key)"
6666
:model-value="selectedCategories.includes(key)"
67+
color="primary"
6768
>
6869
{{ name }}
6970
</KunCheckBox>
@@ -74,6 +75,7 @@ const filteredTags = computed(() => {
7475
class-name="gap-2"
7576
@click="toggleSpoilerLevel(Number(key) as KunGalgameTagSpoiler)"
7677
:model-value="selectedSpoilerLevels.includes(Number(key) as 0)"
78+
color="primary"
7779
>
7880
{{ name }}
7981
</KunCheckBox>

components/home/topic/Card.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ defineProps<{
3232
:upvote-time="topic.upvoteTime"
3333
:has-best-answer="topic.hasBestAnswer"
3434
:is-poll-topic="topic.isPollTopic"
35+
:is-n-s-f-w-topic="topic.isNSFWTopic"
3536
/>
3637

3738
<div class="text-default-700 flex items-center gap-4 text-sm">

components/kun/CheckBox.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const emit = defineEmits<{
3030
change: [value: boolean]
3131
}>()
3232
33+
const kunUniqueId = useKunUniqueId('kun-checkbox')
3334
const updateValue = (event: Event) => {
3435
const target = event.target as HTMLInputElement
3536
emit('update:modelValue', target.checked)
@@ -57,7 +58,7 @@ const colorClasses: Record<KunUIColor, string> = {
5758
<div class="relative flex items-center">
5859
<input
5960
type="checkbox"
60-
:id="id"
61+
:id="kunUniqueId"
6162
:name="name"
6263
:value="value"
6364
:checked="modelValue"
@@ -80,7 +81,7 @@ const colorClasses: Record<KunUIColor, string> = {
8081
<slot />
8182
<label
8283
v-if="label"
83-
:for="id"
84+
:for="kunUniqueId"
8485
:class="
8586
cn(
8687
'text-default-700 ml-2 cursor-pointer text-sm select-none',

components/section/Container.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ watch(
9393
:tags="topic.tag"
9494
:has-best-answer="topic.hasBestAnswer"
9595
:is-poll-topic="topic.isPollTopic"
96+
:is-n-s-f-w-topic="topic.isNSFWTopic"
9697
/>
9798

9899
<div class="text-default-500 line-clamp-2 text-sm break-all">

components/topic/Card.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const actionsCount = computed(
2626
:tags="props.topic.tag"
2727
:has-best-answer="topic.hasBestAnswer"
2828
:is-poll-topic="topic.isPollTopic"
29+
:is-n-s-f-w-topic="topic.isNSFWTopic"
2930
/>
3031

3132
<div class="text-default-700 flex items-center gap-4 text-sm">

components/topic/TagGroup.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const props = defineProps<{
55
upvoteTime?: Date | string | null
66
hasBestAnswer?: boolean
77
isPollTopic?: boolean
8+
isNSFWTopic?: boolean
89
}>()
910
1011
const isRecentlyUpvoted = computed(() => hourDiff(props.upvoteTime || 0, 10))
@@ -35,6 +36,13 @@ const isRecentlyUpvoted = computed(() => hourDiff(props.upvoteTime || 0, 10))
3536
</KunBadge>
3637
</span>
3738

39+
<span v-if="isNSFWTopic" class="flex gap-1">
40+
<KunBadge variant="solid" color="primary" class-name="bg-orange-600">
41+
<KunIcon name="uil:18-plus" class="size-4 text-inherit" />
42+
NSFW 话题
43+
</KunBadge>
44+
</span>
45+
3846
<TopicDetailSection :section="props.section" />
3947

4048
<template v-if="props.tags">

components/topic/detail/Master.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ defineProps<{
3838
:upvote-time="topic.upvoteTime"
3939
:has-best-answer="!!topic.bestAnswer"
4040
:is-poll-topic="topic.isPollTopic"
41+
:is-n-s-f-w-topic="topic.isNSFW"
4142
/>
4243

4344
<div class="text-default-500 flex items-center space-x-4 text-sm">

components/topic/footer/Rewrite.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const props = defineProps<{
66
topic: TopicDetail
77
}>()
88
9-
const { id, title, content, tags, category, section, isTopicRewriting } =
9+
const { id, title, content, tags, category, section, isNSFW, isTopicRewriting } =
1010
storeToRefs(useTempEditStore())
1111
const { id: userId } = usePersistUserStore()
1212
const isShowRewrite = computed(() => userId === props.topic.user.id)
@@ -18,6 +18,7 @@ const rewriteTopic = async () => {
1818
tags.value = props.topic.tag
1919
category.value = props.topic.category
2020
section.value = props.topic.section ?? []
21+
isNSFW.value = !!props.topic.isNSFW
2122
isTopicRewriting.value = true
2223
2324
await navigateTo('/edit/topic')

0 commit comments

Comments
 (0)