Skip to content

Commit 3fd1ea4

Browse files
committed
feat: persist galgame rating short summary publish
1 parent ac7b4b2 commit 3fd1ea4

File tree

7 files changed

+38
-5
lines changed

7 files changed

+38
-5
lines changed

components/galgame/rating/Publish.vue

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
createGalgameRatingSchema,
1515
updateGalgameRatingSchema
1616
} from '~/validations/galgame-rating'
17+
import { usePersistEditGalgameRatingStore } from '~/store/modules/edit/rating'
1718
import type { GalgamePageRatingCard } from '~/types/api/galgame-rating'
1819
1920
type RatingInitialData = {
@@ -46,6 +47,10 @@ const emits = defineEmits<{
4647
onPublished: [GalgamePageRatingCard]
4748
}>()
4849
50+
const { shortSummary: shortSummaryStore } = storeToRefs(
51+
usePersistEditGalgameRatingStore()
52+
)
53+
4954
const recommend =
5055
ref<(typeof KUN_GALGAME_RATING_RECOMMEND_CONST)[number]>('neutral')
5156
const playStatus =
@@ -95,6 +100,15 @@ watch(
95100
}
96101
)
97102
103+
watch(
104+
() => shortSummary.value,
105+
() => {
106+
if (!props.initialData) {
107+
shortSummaryStore.value = shortSummary.value
108+
}
109+
}
110+
)
111+
98112
const isSubmitting = ref(false)
99113
100114
const recommendOptions = computed(() =>
@@ -140,6 +154,8 @@ watch(
140154
}
141155
selectedTypes.value = [...(props.initialData.galgameType ?? [])]
142156
showAdvanced.value = true
157+
} else {
158+
shortSummary.value = shortSummaryStore.value
143159
}
144160
}
145161
)
@@ -238,6 +254,7 @@ const submit = async () => {
238254
resetForm()
239255
close()
240256
emits('onPublished', res)
257+
shortSummaryStore.value = ''
241258
}
242259
}
243260
}
@@ -317,7 +334,7 @@ const submit = async () => {
317334

318335
<KunTextarea
319336
v-model="shortSummary"
320-
label="短评 (可选, 请勿包含 R18 内容)"
337+
label="短评 (可选, 请勿包含 R18 内容, 您的短评在编写的同时会被自动保存在本地, 关掉面板不会丢失)"
321338
:rows="4"
322339
placeholder="「 枯れない世界と終わる花 」莲真的是我遇见最好的女孩子, 想和她结婚天长地久恩恩爱爱百年好合, 想和她翻云覆雨、干湿分离、水乳交融、干柴烈火, 日日夜夜每时每刻每个开心难过七滋八味苦辣麻香咸的日子里都在想念、挚爱、铭记着莲, 你们懂这种心情吗!!!这已经不是爱了, 这种东西叫本能, 我只是本能的爱着这个孩子而已, 我无法控制自己的本能, 我已经病入膏肓了, 病名为莲。"
323340
:maxlength="1314"

components/kun/Popover.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ onBeforeUnmount(() => {
259259
</script>
260260

261261
<template>
262-
<div ref="containerRef" class="relative z-20 inline-block">
262+
<div ref="containerRef" class="relative inline-block">
263263
<div
264264
ref="triggerRef"
265265
@click="toggle"

components/kun/select/Select.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ const props = withDefaults(defineProps<KunSelectProps>(), {
1313
disabled: false,
1414
error: '',
1515
darkBorder: true,
16-
ariaLabel: ''
16+
ariaLabel: '',
17+
className: ''
1718
})
1819
1920
const emit = defineEmits<{
@@ -80,7 +81,7 @@ const selectOption = (value: string | number, index: number) => {
8081
</script>
8182

8283
<template>
83-
<div class="relative w-full">
84+
<div :class="cn('relative w-full', props.className)">
8485
<label
8586
v-if="label"
8687
:for="kunUniqueId"

components/kun/select/type.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ export interface KunSelectProps {
1212
disabled?: boolean
1313
darkBorder?: boolean
1414
ariaLabel?: string
15+
className?: string
1516
}

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.64",
3+
"version": "4.4.65",
44
"packageManager": "[email protected]",
55
"private": true,
66
"scripts": {

store/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import { usePersistEditGalgameRatingStore } from './modules/edit/rating'
12
import { usePersistKUNGalgameAdvancedFilterStore } from './modules/galgame'
23

34
export const kungalgameStoreReset = () => {
45
usePersistEditGalgameStore().$reset()
56
usePersistEditTopicStore().$reset()
7+
usePersistEditGalgameRatingStore().$reset()
68
usePersistKUNGalgameReplyStore().$reset()
79
usePersistKUNGalgameTopicStore().$reset()
810
usePersistCategoryStore().$reset()

store/modules/edit/rating.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export const usePersistEditGalgameRatingStore = defineStore(
2+
'KUNGalgameEditGalgameRating',
3+
{
4+
persist: {
5+
storage: piniaPluginPersistedstate.localStorage()
6+
},
7+
state: () => ({
8+
shortSummary: ''
9+
}),
10+
actions: {}
11+
}
12+
)

0 commit comments

Comments
 (0)