Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge #382

Closed
wants to merge 13 commits into from
Prev Previous commit
添加默认值
  • Loading branch information
chenyinheng30 committed Nov 17, 2023
commit fc31cfc3da281c1d17467b7fce7f745e213d597f
12 changes: 8 additions & 4 deletions layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,17 @@
const streetData = await streetResponse.json();
// 提取所需的数据
temperature_2m = weatherData.current.temperature_2m;
city = streetData.address.city;
state = streetData.address.state;
country_code = streetData.address.country_code;
city = streetData.address.city || "";
state = streetData.address.state || "";
country_code = streetData.address.country_code || undefined;
} catch (error) {
console.error("Error fetching data:", error);
}
const country_flag = countryCodeEmoji(country_code);
if (country_code == undefined){
var country_flag = '🏳️';
}else{
var country_flag = countryCodeEmoji(country_code);
}
var visible = `实时气温:${temperature_2m}°C ${city}/${state} ${country_flag}`;
const weatherElement = document.getElementById("weather");
weatherElement.innerHTML = visible;
Expand Down
Loading