From 5814fb673aa3cd5719cfa594351c9c14d59c6315 Mon Sep 17 00:00:00 2001 From: Tim <135014430+nagisa77@users.noreply.github.com> Date: Mon, 1 Sep 2025 01:06:51 +0800 Subject: [PATCH] feat: add join button for single polls --- frontend_nuxt/components/PostPoll.vue | 37 ++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/frontend_nuxt/components/PostPoll.vue b/frontend_nuxt/components/PostPoll.vue index d038957c4..0dcec1463 100644 --- a/frontend_nuxt/components/PostPoll.vue +++ b/frontend_nuxt/components/PostPoll.vue @@ -59,11 +59,26 @@ v-for="(opt, idx) in poll.options" :key="idx" class="poll-option" - @click="voteOption(idx)" + @click="selectOption(idx)" > - + {{ opt }} + +
+
+ + 该投票为单选 +
+
+ 加入投票 +
+
@@ -198,6 +213,18 @@ const voteOption = async (idx) => { } } +const selectedOption = ref(null) +const selectOption = (idx) => { + selectedOption.value = idx +} +const submitSinglePoll = async () => { + if (selectedOption.value === null) { + toast.error('请选择一个选项') + return + } + await voteOption(selectedOption.value) +} + const selectedOptions = ref([]) const toggleOption = (idx) => { const i = selectedOptions.value.indexOf(idx) @@ -368,14 +395,16 @@ const submitMultiPoll = async () => { color: var(--text-color); } -.multi-selection-container { +.multi-selection-container, +.single-selection-container { padding: 20px 15px 20px 5px; display: flex; flex-direction: row; justify-content: space-between; } -.multi-selection-title { +.multi-selection-title, +.single-selection-title { font-size: 13px; color: var(--text-color); }