mirror of
https://github.com/LiteyukiStudio/LiteyukiBot.git
synced 2025-08-02 18:29:51 +00:00
✨ 轻雪天气更新
This commit is contained in:
@ -9,3 +9,9 @@ const bgs = [
|
||||
]
|
||||
// 随机选择背景图片
|
||||
document.body.style.backgroundImage = `url(./img/${bgs[Math.floor(Math.random() * bgs.length)]})`;
|
||||
// body后插入info-box id=description
|
||||
let descriptionDiv = document.createElement("div");
|
||||
descriptionDiv.className = 'info-box'
|
||||
descriptionDiv.id = 'author-description'
|
||||
descriptionDiv.innerText = 'Designed by SnowyKami'
|
||||
document.body.appendChild(descriptionDiv);
|
||||
|
@ -290,6 +290,8 @@ function main() {
|
||||
document.getElementById('motto-text').innerText = mottoText
|
||||
document.getElementById('motto-from').innerText = mottoFrom
|
||||
|
||||
document.getElementById('author-description').innerText = localData['description'] + ' Powered by Liteyuki'
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,59 +0,0 @@
|
||||
/**
|
||||
* @typedef {Object} Location
|
||||
* @property {string} city - The city name.
|
||||
* @property {string} country - The country name.
|
||||
*
|
||||
* @typedef {Object} Weather
|
||||
* @property {number} temperature - The current temperature.
|
||||
* @property {string} description - The weather description.
|
||||
*
|
||||
* @typedef {Object} Data
|
||||
* @property {Location} location - The location data.
|
||||
* @property {Weather} weather - The weather data.
|
||||
*/
|
||||
|
||||
/** @type {Data} */
|
||||
|
||||
let data = JSON.parse(document.getElementById("data").innerText)
|
||||
|
||||
let weatherNow = data["weatherNow"]
|
||||
|
||||
let weatherDaily = data["weatherDaily"]
|
||||
let weatherHourly = data["weatherHourly"]
|
||||
let aqi = data["aqi"]
|
||||
|
||||
let locationData = data["location"]
|
||||
|
||||
// set info
|
||||
// document.getElementById("time").innerText = weatherNow["now"]["obsTime"]
|
||||
// document.getElementById("city").innerText = locationData["name"]
|
||||
// document.getElementById("adm").innerText = locationData["country"] + " " + locationData["adm1"] + " " + locationData["adm2"]
|
||||
// document.getElementById("temperature-now").innerText = weatherNow["now"]["temp"] + "°"
|
||||
// document.getElementById("temperature-range").innerText = weatherNow["now"]["feelsLike"] + "°"
|
||||
// document.getElementById("description").innerText = weatherNow["now"]["text"]
|
||||
// 处理aqi
|
||||
let aqiValue = 0
|
||||
aqi["aqi"].forEach(
|
||||
(item) => {
|
||||
if (item["defaultLocalAqi"]) {
|
||||
document.getElementById("aqi-data").innerText = "AQI " + item["valueDisplay"] + " " + item["category"]
|
||||
// 将(255,255,255)这种格式的颜色设置给css
|
||||
document.getElementById("aqi-dot").style.backgroundColor = "rgb(" + item["color"] + ")"
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
templates = {
|
||||
"time": weatherNow["now"]["obsTime"],
|
||||
"city": locationData["name"],
|
||||
"adm": locationData["country"] + " " + locationData["adm1"] + " " + locationData["adm2"],
|
||||
"temperature-now": weatherNow["now"]["temp"] + "°",
|
||||
"temperature-range": weatherDaily["daily"][0]["tempMin"] + "°/" + weatherDaily["daily"][0]["tempMax"] + "°",
|
||||
"description": weatherNow["now"]["text"]
|
||||
}
|
||||
|
||||
// 遍历每一个id,给其赋值
|
||||
|
||||
for (let id in templates) {
|
||||
document.getElementById(id).innerText = templates[id]
|
||||
}
|
Reference in New Issue
Block a user