| | |
| | | <div class="screen-widget-text"> |
| | | {{ weather.now.text }} {{ weather.now.temperature + "℃" }} |
| | | </div> |
| | | <div |
| | | <!-- <div |
| | | class="screen-widget-time screen-widget-text" |
| | | style="margin-left: 20px" |
| | | > |
| | | {{ $dayjs().format("YYYY/MM/DD HH:mm") }} |
| | | </div> --> |
| | | <div |
| | | class="screen-widget-time screen-widget-text" |
| | | style="margin-left: 20px" |
| | | > |
| | | {{ currentTime }} |
| | | </div> |
| | | </div> |
| | | <div class="screen-widget-home"> |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, onMounted, computed, defineEmits } from "vue"; |
| | | import { ref, onMounted, computed, defineEmits,onBeforeUnmount } from "vue"; |
| | | import { useRouter } from "vue-router"; |
| | | import dayjs from 'dayjs' |
| | | |
| | | const currentTime = ref(dayjs().format("YYYY/MM/DD HH:mm:ss")); |
| | | |
| | | const updateTime = () => { |
| | | currentTime.value = dayjs().format("YYYY/MM/DD HH:mm:ss"); |
| | | }; |
| | | |
| | | let timer; |
| | | |
| | | onMounted(() => { |
| | | timer = setInterval(updateTime, 1000); |
| | | }); |
| | | |
| | | onBeforeUnmount(() => { |
| | | clearInterval(timer); // 避免内存泄漏 |
| | | }); |
| | | |
| | | const router = useRouter(); |
| | | const bgVisible = ref(true); |
| | | const defaultCity = ref(cityData.name); |
| | |
| | | .then((response) => response.json()) |
| | | .then((data) => { |
| | | weather.value = data.results[0]; |
| | | // console.log(weather.value) |
| | | }); |
| | | }; |
| | | function initScene() { |
| | |
| | | viewer.scene.camera.flyTo(view); |
| | | } |
| | | onMounted(() => { |
| | | // getWeatherData() |
| | | getWeatherData() |
| | | }); |
| | | </script> |
| | | <style lang="less" scoped> |