weather-select.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <div class="env-panel" v-if="expanded">
  3. <div class="env-header">
  4. <div class="env-header-title">环境控制</div>
  5. <button class="env-toggle-btn" @click="expanded = false">收起 ▲</button>
  6. </div>
  7. <div class="env-row">
  8. <div class="weather-select-title">时间</div>
  9. <el-slider
  10. class="env-slider"
  11. v-model="sliderValue"
  12. :min="0"
  13. :max="1439"
  14. :step="1"
  15. :show-tooltip="false"
  16. size="small"
  17. @input="handleInput"
  18. @change="handleChange"
  19. />
  20. <div class="env-time-value">{{ timeText }}</div>
  21. </div>
  22. <div class="env-row">
  23. <div class="weather-select-title">天气</div>
  24. <div class="weather-select-buttons">
  25. <button
  26. v-for="w in weatherList"
  27. :key="w.type"
  28. :class="['weather-btn', { active: currentWeather === w.type }]"
  29. @click="selectWeather(w.type)"
  30. >{{ w.label }}</button>
  31. </div>
  32. </div>
  33. <div class="env-row">
  34. <div class="weather-select-title">季节</div>
  35. <div class="weather-select-buttons">
  36. <button
  37. v-for="s in seasonList"
  38. :key="s.type"
  39. :class="['weather-btn', { active: currentSeason === s.type }]"
  40. @click="selectSeason(s.type)"
  41. >{{ s.label }}</button>
  42. </div>
  43. </div>
  44. </div>
  45. <button v-else class="env-collapsed-btn" @click="expanded = true">环境 ▼</button>
  46. </template>
  47. <script>
  48. import weatherSelect from "./weather-select.js";
  49. export default {
  50. name: "Sm3dWeatherSelect",
  51. setup() {
  52. let {
  53. expanded,
  54. sliderValue,
  55. timeText,
  56. handleInput,
  57. handleChange,
  58. weatherList,
  59. seasonList,
  60. currentWeather,
  61. currentSeason,
  62. selectWeather,
  63. selectSeason
  64. } = weatherSelect();
  65. return {
  66. expanded,
  67. sliderValue,
  68. timeText,
  69. handleInput,
  70. handleChange,
  71. weatherList,
  72. seasonList,
  73. currentWeather,
  74. currentSeason,
  75. selectWeather,
  76. selectSeason
  77. };
  78. }
  79. };
  80. </script>
  81. <style scoped>
  82. .env-panel {
  83. position: absolute;
  84. top: 12px;
  85. right: 12px;
  86. z-index: 1000;
  87. display: flex;
  88. flex-direction: column;
  89. gap: 6px;
  90. padding: 8px 12px;
  91. background: rgba(20, 40, 70, 0.85);
  92. border: 1px solid rgba(255, 255, 255, 0.15);
  93. border-radius: 6px;
  94. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  95. backdrop-filter: blur(4px);
  96. }
  97. .env-header {
  98. display: flex;
  99. align-items: center;
  100. justify-content: space-between;
  101. margin-bottom: 2px;
  102. }
  103. .env-header-title {
  104. color: #fff;
  105. font-size: 13px;
  106. font-weight: bold;
  107. }
  108. .env-toggle-btn {
  109. padding: 2px 10px;
  110. font-size: 12px;
  111. color: #cfe0ff;
  112. background: rgba(255, 255, 255, 0.1);
  113. border: 1px solid rgba(255, 255, 255, 0.2);
  114. border-radius: 4px;
  115. cursor: pointer;
  116. transition: all 0.2s;
  117. }
  118. .env-toggle-btn:hover {
  119. background: rgba(255, 255, 255, 0.2);
  120. color: #fff;
  121. }
  122. .env-collapsed-btn {
  123. position: absolute;
  124. top: 12px;
  125. right: 12px;
  126. z-index: 1000;
  127. padding: 6px 14px;
  128. font-size: 13px;
  129. color: #cfe0ff;
  130. background: rgba(20, 40, 70, 0.85);
  131. border: 1px solid rgba(255, 255, 255, 0.2);
  132. border-radius: 6px;
  133. cursor: pointer;
  134. transition: all 0.2s;
  135. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  136. backdrop-filter: blur(4px);
  137. }
  138. .env-collapsed-btn:hover {
  139. background: rgba(40, 70, 110, 0.9);
  140. color: #fff;
  141. }
  142. .env-row {
  143. display: flex;
  144. align-items: center;
  145. }
  146. .weather-select-title {
  147. color: #fff;
  148. font-size: 13px;
  149. font-weight: bold;
  150. margin-right: 10px;
  151. white-space: nowrap;
  152. }
  153. .env-slider {
  154. width: 160px;
  155. margin: 0 6px;
  156. }
  157. .env-time-value {
  158. color: #ffd04b;
  159. font-size: 14px;
  160. font-weight: bold;
  161. font-family: "Consolas", monospace;
  162. min-width: 44px;
  163. text-align: center;
  164. white-space: nowrap;
  165. }
  166. .weather-select-buttons {
  167. display: flex;
  168. gap: 4px;
  169. }
  170. .weather-btn {
  171. padding: 3px 12px;
  172. font-size: 13px;
  173. color: #cfe0ff;
  174. background: rgba(255, 255, 255, 0.1);
  175. border: 1px solid rgba(255, 255, 255, 0.2);
  176. border-radius: 4px;
  177. cursor: pointer;
  178. transition: all 0.2s;
  179. white-space: nowrap;
  180. }
  181. .weather-btn:hover {
  182. background: rgba(255, 255, 255, 0.2);
  183. color: #fff;
  184. }
  185. .weather-btn.active {
  186. background: #409eff;
  187. border-color: #409eff;
  188. color: #fff;
  189. font-weight: bold;
  190. }
  191. </style>