| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- <template>
- <div class="env-panel" v-if="expanded">
- <div class="env-header">
- <div class="env-header-title">环境控制</div>
- <button class="env-toggle-btn" @click="expanded = false">收起 ▲</button>
- </div>
- <div class="env-row">
- <div class="weather-select-title">时间</div>
- <el-slider
- class="env-slider"
- v-model="sliderValue"
- :min="0"
- :max="1439"
- :step="1"
- :show-tooltip="false"
- size="small"
- @input="handleInput"
- @change="handleChange"
- />
- <div class="env-time-value">{{ timeText }}</div>
- </div>
- <div class="env-row">
- <div class="weather-select-title">天气</div>
- <div class="weather-select-buttons">
- <button
- v-for="w in weatherList"
- :key="w.type"
- :class="['weather-btn', { active: currentWeather === w.type }]"
- @click="selectWeather(w.type)"
- >{{ w.label }}</button>
- </div>
- </div>
- <div class="env-row">
- <div class="weather-select-title">季节</div>
- <div class="weather-select-buttons">
- <button
- v-for="s in seasonList"
- :key="s.type"
- :class="['weather-btn', { active: currentSeason === s.type }]"
- @click="selectSeason(s.type)"
- >{{ s.label }}</button>
- </div>
- </div>
- </div>
- <button v-else class="env-collapsed-btn" @click="expanded = true">环境 ▼</button>
- </template>
- <script>
- import weatherSelect from "./weather-select.js";
- export default {
- name: "Sm3dWeatherSelect",
- setup() {
- let {
- expanded,
- sliderValue,
- timeText,
- handleInput,
- handleChange,
- weatherList,
- seasonList,
- currentWeather,
- currentSeason,
- selectWeather,
- selectSeason
- } = weatherSelect();
- return {
- expanded,
- sliderValue,
- timeText,
- handleInput,
- handleChange,
- weatherList,
- seasonList,
- currentWeather,
- currentSeason,
- selectWeather,
- selectSeason
- };
- }
- };
- </script>
- <style scoped>
- .env-panel {
- position: absolute;
- top: 12px;
- right: 12px;
- z-index: 1000;
- display: flex;
- flex-direction: column;
- gap: 6px;
- padding: 8px 12px;
- background: rgba(20, 40, 70, 0.85);
- border: 1px solid rgba(255, 255, 255, 0.15);
- border-radius: 6px;
- box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
- backdrop-filter: blur(4px);
- }
- .env-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 2px;
- }
- .env-header-title {
- color: #fff;
- font-size: 13px;
- font-weight: bold;
- }
- .env-toggle-btn {
- padding: 2px 10px;
- font-size: 12px;
- color: #cfe0ff;
- background: rgba(255, 255, 255, 0.1);
- border: 1px solid rgba(255, 255, 255, 0.2);
- border-radius: 4px;
- cursor: pointer;
- transition: all 0.2s;
- }
- .env-toggle-btn:hover {
- background: rgba(255, 255, 255, 0.2);
- color: #fff;
- }
- .env-collapsed-btn {
- position: absolute;
- top: 12px;
- right: 12px;
- z-index: 1000;
- padding: 6px 14px;
- font-size: 13px;
- color: #cfe0ff;
- background: rgba(20, 40, 70, 0.85);
- border: 1px solid rgba(255, 255, 255, 0.2);
- border-radius: 6px;
- cursor: pointer;
- transition: all 0.2s;
- box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
- backdrop-filter: blur(4px);
- }
- .env-collapsed-btn:hover {
- background: rgba(40, 70, 110, 0.9);
- color: #fff;
- }
- .env-row {
- display: flex;
- align-items: center;
- }
- .weather-select-title {
- color: #fff;
- font-size: 13px;
- font-weight: bold;
- margin-right: 10px;
- white-space: nowrap;
- }
- .env-slider {
- width: 160px;
- margin: 0 6px;
- }
- .env-time-value {
- color: #ffd04b;
- font-size: 14px;
- font-weight: bold;
- font-family: "Consolas", monospace;
- min-width: 44px;
- text-align: center;
- white-space: nowrap;
- }
- .weather-select-buttons {
- display: flex;
- gap: 4px;
- }
- .weather-btn {
- padding: 3px 12px;
- font-size: 13px;
- color: #cfe0ff;
- background: rgba(255, 255, 255, 0.1);
- border: 1px solid rgba(255, 255, 255, 0.2);
- border-radius: 4px;
- cursor: pointer;
- transition: all 0.2s;
- white-space: nowrap;
- }
- .weather-btn:hover {
- background: rgba(255, 255, 255, 0.2);
- color: #fff;
- }
- .weather-btn.active {
- background: #409eff;
- border-color: #409eff;
- color: #fff;
- font-weight: bold;
- }
- </style>
|