Update Weather.vue

This commit is contained in:
hwxlikemi 2025-01-26 20:50:24 +08:00 committed by GitHub
parent 172fb4230d
commit 9593cbb24f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,5 +1,6 @@
<template>
<div class="weather" v-if="weatherData.adCode.city && weatherData.weather.weather"
<div class="weather" v-if="weatherData.adCode.city && weatherData.weather.weather">
<span>{{ weatherData.adCode.city }}&nbsp;</span>
<span>{{ weatherData.weather.weather }}&nbsp;</span>
<span>{{ weatherData.weather.temperature }}</span>
<span class="sm-hidden">
@ -19,10 +20,8 @@
<script setup>
import { getAdcode, getWeather, getOtherWeather } from "@/api";
import { Error } from "@icon-park/vue-next";
// Key
const mainKey = import.meta.env.VITE_WEATHER_KEY;
//
const weatherData = reactive({
adCode: {
@ -36,7 +35,6 @@ const weatherData = reactive({
windpower: null, //
},
});
//
const getTemperature = (min, max) => {
try {
@ -48,7 +46,6 @@ const getTemperature = (min, max) => {
return "NaN";
}
};
//
const getWeatherData = async () => {
try {
@ -93,7 +90,6 @@ const getWeatherData = async () => {
onError("天气信息获取失败");
}
};
//
const onError = (message) => {
ElMessage({
@ -105,7 +101,6 @@ const onError = (message) => {
});
console.error(message);
};
onMounted(() => {
//
getWeatherData();