xiongzhu 2 лет назад
Родитель
Сommit
d3720f16e5
1 измененных файлов с 17 добавлено и 12 удалено
  1. 17 12
      src/views/PlayView.vue

+ 17 - 12
src/views/PlayView.vue

@@ -13,7 +13,13 @@
                 <template v-if="index === history.length - 1 && item.choices.length">
                     <br /><br />
                     <el-radio-group v-model="choice" class="ml-4">
-                        <el-radio v-for="c in item.choices" :key="c" :label="c" class="w-full"> </el-radio>
+                        <el-radio
+                            v-for="c in item.choices"
+                            :key="c"
+                            :label="c"
+                            class="w-full !h-auto !whitespace-normal mb-4"
+                        >
+                        </el-radio>
                     </el-radio-group>
                 </template>
                 <template v-if="index === history.length - 1">
@@ -25,8 +31,9 @@
     <div class="text-center">
         <ElButtonGroup v-if="game.status === 'PLAYING'">
             <ElButton :loading="loading" @click="continueGame(false)">继续</ElButton>
+            <ElButton :loading="loading" @click="onAddCharactor(false)">加入角色继续</ElButton>
             <ElButton :loading="loading" @click="continueGame(true)">生成选择</ElButton>
-            <ElButton :loading="loading" @click="onAddCharactor">加入角色</ElButton>
+            <ElButton :loading="loading" @click="onAddCharactor(true)">加入角色生成选择</ElButton>
             <ElButton :loading="loading" @click="revert">回退</ElButton>
         </ElButtonGroup>
         <ElButton v-else @click="start" :loading="loading">开始</ElButton>
@@ -76,14 +83,18 @@ async function start() {
     getData()
 }
 
-async function continueGame(genChoice = false) {
+async function continueGame(genChoice = false, addCharactor = null) {
     if (needChoice.value && !choice.value) {
         ElMessage.info('请选择一个选项')
         return
     }
     loading.value = true
     try {
-        await http.post(`/game/${route.params.id}/continue`, { genChoice: genChoice, choice: choice.value })
+        await http.post(`/game/${route.params.id}/continue`, {
+            genChoice: genChoice,
+            choice: choice.value,
+            addCharactor
+        })
         loading.value = false
         getData()
     } catch (error) {
@@ -99,18 +110,12 @@ async function revert() {
     getData()
 }
 
-async function onAddCharactor() {
+async function onAddCharactor(genChoice = false) {
     const { value } = await ElMessageBox.prompt('基本信息:', '添加角色', {
         inputPattern: /^.+$/,
         inputErrorMessage: '请输入基本信息'
     })
-    try {
-        await http.post(`/game/${route.params.id}/addCharactor`, {
-            base: value
-        })
-    } catch (error) {
-        ElMessage.error(error.message)
-    }
+    continueGame(genChoice, value)
 }
 </script>
 <style lang="less" scoped></style>