feat: add lottery post type options

This commit is contained in:
Tim
2025-08-11 01:45:23 +08:00
parent 0cf1bf187a
commit e0291868bc
4 changed files with 259 additions and 5 deletions

View File

@@ -0,0 +1,46 @@
<template>
<Dropdown v-model="selected" :fetch-options="fetchTypes" placeholder="选择帖子类型" :initial-options="providedOptions" />
</template>
<script>
import { computed, ref, watch } from 'vue'
import Dropdown from '~/components/Dropdown.vue'
export default {
name: 'PostTypeSelect',
components: { Dropdown },
props: {
modelValue: { type: String, default: 'NORMAL' },
options: { type: Array, default: () => [] }
},
emits: ['update:modelValue'],
setup(props, { emit }) {
const providedOptions = ref(Array.isArray(props.options) ? [...props.options] : [])
watch(
() => props.options,
val => {
providedOptions.value = Array.isArray(val) ? [...val] : []
}
)
const fetchTypes = async () => {
return [
{ id: 'NORMAL', name: '普通帖子', icon: 'fa-regular fa-file' },
{ id: 'LOTTERY', name: '抽奖帖子', icon: 'fa-solid fa-gift' }
]
}
const selected = computed({
get: () => props.modelValue,
set: v => emit('update:modelValue', v)
})
return { fetchTypes, selected, providedOptions }
}
}
</script>
<style scoped>
</style>