HostSettings.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <view class="game-settings">
  3. <nut-divider
  4. content-position="center"
  5. :style="{ color: '#3C92FB', borderColor: '#3C92FB', padding: '0 16px', margin: '12px 0 12px 0' }"
  6. >
  7. 游戏设置
  8. </nut-divider>
  9. <!-- 1. 主题选择 -->
  10. <view class="setting-item">
  11. <view class="setting-label">主题选择</view>
  12. <nut-cell
  13. :desc="selectedTheme?.text || '请选择游戏主题'"
  14. @click="onShowThemeSelector"
  15. >
  16. <template #link>
  17. <IconFont name="right" size="16"></IconFont>
  18. </template>
  19. </nut-cell>
  20. </view>
  21. <!-- 2. 难度选择 -->
  22. <view class="setting-item">
  23. <view class="setting-label">游戏难度</view>
  24. <nut-cell
  25. :desc="difficultyText"
  26. @click="onShowDifficultySelector"
  27. >
  28. <template #link>
  29. <IconFont name="right" size="16"></IconFont>
  30. </template>
  31. </nut-cell>
  32. </view>
  33. <!-- 3. 题目选择 (只有当主题和难度都选择后才显示) -->
  34. <view class="setting-item" v-if="selectedThemeId && selectedDifficulty">
  35. <view class="setting-label">题目选择</view>
  36. <nut-cell
  37. :desc="selectedPuzzle?.text || '请选择游戏题目'"
  38. @click="selectedThemeId ? onShowPuzzleSelector() : null"
  39. >
  40. <template #link>
  41. <IconFont name="right" size="16"></IconFont>
  42. </template>
  43. </nut-cell>
  44. </view>
  45. </view>
  46. </template>
  47. <script lang="ts">
  48. import { defineComponent, PropType } from 'vue'
  49. import { IconFont } from '@nutui/icons-vue-taro'
  50. import { TurtleSoupDifficulty } from '@/types/games/turtlesoup'
  51. import { CascaderOption } from '@/types/cascader'
  52. export default defineComponent({
  53. name: 'GameSettings',
  54. components: {
  55. IconFont
  56. },
  57. props: {
  58. selectedTheme: {
  59. type: Object as PropType<CascaderOption | null>,
  60. default: null
  61. },
  62. selectedPuzzle: {
  63. type: Object as PropType<CascaderOption | null>,
  64. default: null
  65. },
  66. selectedThemeId: {
  67. type: String,
  68. default: ''
  69. },
  70. selectedDifficulty: {
  71. type: String,
  72. default: TurtleSoupDifficulty.MEDIUM
  73. },
  74. difficultyText: {
  75. type: String,
  76. default: '中等'
  77. }
  78. },
  79. setup(props, { emit }) {
  80. const onShowThemeSelector = () => {
  81. emit('show-theme-selector')
  82. }
  83. const onShowDifficultySelector = () => {
  84. emit('show-difficulty-selector')
  85. }
  86. const onShowPuzzleSelector = () => {
  87. emit('show-puzzle-selector')
  88. }
  89. return {
  90. onShowThemeSelector,
  91. onShowDifficultySelector,
  92. onShowPuzzleSelector
  93. }
  94. }
  95. })
  96. </script>
  97. <style lang="scss">
  98. .game-settings {
  99. background-color: $background-color-light;
  100. border-radius: $border-radius-small;
  101. padding: $spacing-base;
  102. margin-bottom: $spacing-base;
  103. box-shadow: $shadow-light;
  104. .setting-item {
  105. margin-bottom: $spacing-base;
  106. .setting-label {
  107. font-size: $font-size-small;
  108. color: $text-color-secondary;
  109. margin-bottom: $spacing-mini;
  110. font-weight: $font-weight-medium;
  111. }
  112. }
  113. }
  114. </style>