From 9d2619589b845ba8e041ded5edef958c38e081c1 Mon Sep 17 00:00:00 2001
From: Envision <9063072+elapsingdreams@user.noreply.gitee.com>
Date: Thu, 15 Aug 2024 21:37:25 +0800
Subject: [PATCH] =?UTF-8?q?:twisted=5Frightwards=5Farrows:=E5=90=88?=
=?UTF-8?q?=E5=B9=B6=E4=B8=BB=E4=BB=93=E5=BA=93=E5=AF=B9=E5=A4=A9=E6=B0=94?=
=?UTF-8?q?=E6=8F=92=E4=BB=B6=E7=9A=84=E6=9B=B4=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
unused_plugin/liteyuki_weather/qw_api.py | 33 ++++++----
unused_resource/liteyuki_weather/lang/en.lang | 11 +++-
unused_resource/liteyuki_weather/lang/ja.lang | 11 +++-
.../liteyuki_weather/lang/zh-CN.lang | 11 +++-
.../templates/css/weather_now.css | 54 +++++++--------
.../templates/js/weather_now.js | 62 ++++++++++-------
.../templates/weather_now.html | 66 +------------------
7 files changed, 120 insertions(+), 128 deletions(-)
diff --git a/unused_plugin/liteyuki_weather/qw_api.py b/unused_plugin/liteyuki_weather/qw_api.py
index ab47fad..6fd0c07 100644
--- a/unused_plugin/liteyuki_weather/qw_api.py
+++ b/unused_plugin/liteyuki_weather/qw_api.py
@@ -43,18 +43,27 @@ def get_local_data(ulang_code: str) -> dict:
"""
ulang = Language(ulang_code)
return {
- "monday" : ulang.get("weather.monday"),
- "tuesday" : ulang.get("weather.tuesday"),
- "wednesday": ulang.get("weather.wednesday"),
- "thursday" : ulang.get("weather.thursday"),
- "friday" : ulang.get("weather.friday"),
- "saturday" : ulang.get("weather.saturday"),
- "sunday" : ulang.get("weather.sunday"),
- "today" : ulang.get("weather.today"),
- "tomorrow" : ulang.get("weather.tomorrow"),
- "day" : ulang.get("weather.day"),
- "night" : ulang.get("weather.night"),
- "no_aqi" : ulang.get("weather.no_aqi"),
+ "monday" : ulang.get("weather.monday"),
+ "tuesday" : ulang.get("weather.tuesday"),
+ "wednesday" : ulang.get("weather.wednesday"),
+ "thursday" : ulang.get("weather.thursday"),
+ "friday" : ulang.get("weather.friday"),
+ "saturday" : ulang.get("weather.saturday"),
+ "sunday" : ulang.get("weather.sunday"),
+ "today" : ulang.get("weather.today"),
+ "tomorrow" : ulang.get("weather.tomorrow"),
+ "day" : ulang.get("weather.day"),
+ "night" : ulang.get("weather.night"),
+ "no_aqi" : ulang.get("weather.no_aqi"),
+ "now-windVelocity" : ulang.get("weather.now-windVelocity"),
+ "now-humidity" : ulang.get("weather.now-humidity"),
+ "now-feelsLike" : ulang.get("weather.now-feelsLike"),
+ "now-precip" : ulang.get("weather.now-precip"),
+ "now-pressure" : ulang.get("weather.now-pressure"),
+ "now-vis" : ulang.get("weather.now-vis"),
+ "now-cloud" : ulang.get("weather.now-cloud"),
+ "astronomy-sunrise" : ulang.get("weather.astronomy-sunrise"),
+ "astronomy-sunset" : ulang.get("weather.astronomy-sunset"),
}
diff --git a/unused_resource/liteyuki_weather/lang/en.lang b/unused_resource/liteyuki_weather/lang/en.lang
index 9822bda..9e4031d 100644
--- a/unused_resource/liteyuki_weather/lang/en.lang
+++ b/unused_resource/liteyuki_weather/lang/en.lang
@@ -9,4 +9,13 @@ weather.day=Day
weather.night=Night
weather.today=Today
weather.tomorrow=Tomorrow
-weather.no_aqi=No AQI data
\ No newline at end of file
+weather.no_aqi=No AQI data
+weather.now-windVelocity=WS
+weather.now-humidity=RH
+weather.now-feelsLike=FL
+weather.now-precip=PPT
+weather.now-pressure=MSLP
+weather.now-vis=VIS
+weather.now-cloud=CC
+weather.astronomy-sunrise=SR
+weather.astronomy-sunset=SS
\ No newline at end of file
diff --git a/unused_resource/liteyuki_weather/lang/ja.lang b/unused_resource/liteyuki_weather/lang/ja.lang
index 58bcd04..5e91feb 100644
--- a/unused_resource/liteyuki_weather/lang/ja.lang
+++ b/unused_resource/liteyuki_weather/lang/ja.lang
@@ -9,4 +9,13 @@ weather.day=昼
weather.night=夜
weather.today=今日
weather.tomorrow=明日
-weather.no_aqi=空気質データなし
\ No newline at end of file
+weather.no_aqi=空気質データなし
+weather.now-windVelocity=風速
+weather.now-humidity=湿度
+weather.now-feelsLike=体感温度
+weather.now-precip=降水量
+weather.now-pressure=気圧
+weather.now-vis=能視距離
+weather.now-cloud=雲量
+weather.astronomy-sunrise=日出
+weather.astronomy-sunset=日没
\ No newline at end of file
diff --git a/unused_resource/liteyuki_weather/lang/zh-CN.lang b/unused_resource/liteyuki_weather/lang/zh-CN.lang
index a4f44d5..5ce680d 100644
--- a/unused_resource/liteyuki_weather/lang/zh-CN.lang
+++ b/unused_resource/liteyuki_weather/lang/zh-CN.lang
@@ -9,4 +9,13 @@ weather.day=白天
weather.night=夜晚
weather.today=今天
weather.tomorrow=明天
-weather.no_aqi=暂无AQI数据
\ No newline at end of file
+weather.no_aqi=暂无AQI数据
+weather.now-windVelocity=风矢
+weather.now-humidity=湿度
+weather.now-feelsLike=体感
+weather.now-precip=降水
+weather.now-pressure=气压
+weather.now-vis=能见
+weather.now-cloud=云量
+weather.astronomy-sunrise=日出
+weather.astronomy-sunset=日落
\ No newline at end of file
diff --git a/unused_resource/liteyuki_weather/templates/css/weather_now.css b/unused_resource/liteyuki_weather/templates/css/weather_now.css
index b1fe3db..c6d44e5 100644
--- a/unused_resource/liteyuki_weather/templates/css/weather_now.css
+++ b/unused_resource/liteyuki_weather/templates/css/weather_now.css
@@ -187,37 +187,37 @@
.ad-box {
margin-bottom: 20px;
-
- img {
- border-radius: 60px;
- }
}
-.sub-info {
+#ad {
+ border-radius: 60px;
+}
+
+#sub-info {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 10px;
color: var(--main-text-color);
- font-size: 40px;
+ font-size: 36px;
align-items: center;
}
-.sub-info>div {
+.sub-item {
display: flex;
align-items: center;
gap: 5px;
overflow: hidden;
padding-left: 20px;
+}
- /*要问就问html调svg为什么那么不友好*/
- img {
- transform: translateY(-80px);
- /*自定义颜色*/
- filter: drop-shadow(var(--main-text-color) 0 80px);
- /*自定义透明度*/
- opacity: 1;
- padding-right: 10px;
- }
+/*要问就问为什么html调svg那么不友好*/
+.sub-svg {
+ transform: translateY(-80px);
+ /*此处用作自定义颜色*/
+ filter: drop-shadow(var(--main-text-color) 0 80px);
+ /*此处用作自定义透明度*/
+ opacity: 1;
+ padding-right: 10px;
}
.attribution-box {
@@ -225,16 +225,16 @@
position: relative;
display: flex;
justify-content: center;
+}
- #attribution-info {
- backdrop-filter: blur(10px);
- padding: 0 5px 0;
- background-color: rgba(0, 0, 0, 0.5);
- font-size: 25px;
- justify-content: space-between;
- display: inline-flex;
- word-wrap: break-word;
- color: var(--sub-text-color);
- text-align: center;
- }
+#attribution-info {
+ backdrop-filter: blur(10px);
+ padding: 0 5px 0;
+ background-color: rgba(0, 0, 0, 0.5);
+ font-size: 25px;
+ justify-content: space-between;
+ display: inline-flex;
+ word-wrap: break-word;
+ color: var(--sub-text-color);
+ text-align: center;
}
\ No newline at end of file
diff --git a/unused_resource/liteyuki_weather/templates/js/weather_now.js b/unused_resource/liteyuki_weather/templates/js/weather_now.js
index 974693d..b39552f 100644
--- a/unused_resource/liteyuki_weather/templates/js/weather_now.js
+++ b/unused_resource/liteyuki_weather/templates/js/weather_now.js
@@ -54,7 +54,7 @@ if ("aqi" in aqi) {
}
-templates = {
+let templates = {
"time": weatherNow["now"]["obsTime"],
"city": locationData["name"],
"adm": locationData["country"] + " " + locationData["adm1"] + " " + locationData["adm2"],
@@ -69,31 +69,48 @@ for (let id in templates) {
}
-subtemplates = {
+let subtemplates = {
"now-windDirect": weatherNow["now"]["windDir"] + " " + weatherNow["now"]["wind360"] + "°",
- "now-windVelocity": "风矢 " + weatherNow["now"]["windScale"] + "级 " + weatherNow["now"]["windSpeed"] + "km/h",
- "now-humidity": "湿度 " + weatherNow["now"]["humidity"] + "%",
- "now-feelsLike": "体感 " + weatherNow["now"]["feelsLike"] + "°C",
- "now-precip": "降水 " + weatherNow["now"]["precip"] + "mm",
- "now-pressure": "气压 " + weatherNow["now"]["pressure"] + "hPa",
- "vis": "能见 " + weatherNow["now"]["vis"] + "km",
- "cloud ": "云量 " + (weatherNow["now"]["cloud"] == "" ? "无数据" : (weatherNow["now"]["cloud"] + "%")),
- "astronomy-sunrise": "日出 " + get_time_hour(weatherAstronomy["sunrise"]),
- "astronomy-sunset": "日落 " + get_time_hour(weatherAstronomy["sunset"])
+ "now-windVelocity": localData["now-windVelocity"] + " " + weatherNow["now"]["windScale"] + "级 " + weatherNow["now"]["windSpeed"] + "km/h",
+ "now-humidity": localData["now-humidity"] + " " + weatherNow["now"]["humidity"] + "%",
+ "now-feelsLike": localData["now-feelsLike"] + " " + weatherNow["now"]["feelsLike"] + "°C",
+ "now-precip": localData["now-precip"] + " " + weatherNow["now"]["precip"] + "mm",
+ "now-pressure": localData["now-pressure"] + " " + weatherNow["now"]["pressure"] + "hPa",
+ "now-vis": localData["now-vis"] + " " + weatherNow["now"]["vis"] + "km",
+ "now-cloud": localData["now-cloud"] + " " + (weatherNow["now"]["cloud"] == "" ? "无数据" : (weatherNow["now"]["cloud"] + "%")),
+ "astronomy-sunrise": localData["astronomy-sunrise"] + " " + get_time_hour(weatherAstronomy["sunrise"]),
+ "astronomy-sunset": localData["astronomy-sunset"] + " " + get_time_hour(weatherAstronomy["sunset"])
}
-let subItemDivTemplate = document.importNode(document.getElementById("sub-info-template").content, true);
+let subiconMap = {
+ "now-windDirect": "windDirect",
+ "now-windVelocity": "windVelocity",
+ "now-humidity": "humidity",
+ "now-feelsLike": "feelsLike",
+ "now-precip": "precip",
+ "now-pressure": "pressure",
+ "now-vis": "vis",
+ "now-cloud": "cloud",
+ "astronomy-sunrise": "sunrise",
+ "astronomy-sunset": "sunset"
+};
-let subItemDiv = subItemDivTemplate.querySelector(".sub-info");
+let subtemplate = document.getElementById('sub-info-template').content;
+let subcontainer = document.getElementById('sub-info');
-for (let id in subtemplates) {
- let element = subItemDiv.querySelector(`#${id}`);
- if (element) {
- element.innerText = subtemplates[id];
- }
-}
+Object.keys(subtemplates).forEach(id => {
+ let subItemDiv = document.importNode(subtemplate, true).querySelector('.sub-item');
+
+ subItemDiv.querySelector(`div`).innerText = subtemplates[id];
+
+ let iconName = subiconMap[id];
+
+ subItemDiv.querySelector(`img`).src = `./img/svg/${iconName}.svg`;
+ subItemDiv.querySelector(`img`).alt = `SVG ${id}`;
+
+ subcontainer.appendChild(subItemDiv);
+});
-document.getElementById('sub-info').appendChild(subItemDiv);
let maxHourlyItem = 8
let percentWidth = 1 / (maxHourlyItem * 1.5) * 100
@@ -161,7 +178,6 @@ function get_time_hour(fxTime) {
return fxTime.split("T")[1].split("+")[0]
}
-let attrinfo = document.getElementById('attribution-info');
-if (!is_dev & !attr) attrinfo.parentElement.style.display = "none"
-attrinfo.innerText = is_dev ? "Weather Service Drived by QWeather" : (attr ? attr : "Weather Service Drived by QWeather")
+let attrinfo = document.getElementById('attribution-info');
+attrinfo.innerText = is_dev ? "Weather Service Drived by QWeather" : (attr ? attr : "Weather Service Drived by QWeather");
diff --git a/unused_resource/liteyuki_weather/templates/weather_now.html b/unused_resource/liteyuki_weather/templates/weather_now.html
index 23876f8..e0b360a 100644
--- a/unused_resource/liteyuki_weather/templates/weather_now.html
+++ b/unused_resource/liteyuki_weather/templates/weather_now.html
@@ -7,7 +7,6 @@
-
@@ -38,68 +37,9 @@
-
-
-
-
- 西北风 315°
-
-
-
-
- 风矢 2级 10km/h
-
-
-
-
-
- 湿度 45%
-
-
-
-
-
- 体感 32°C
-
-
-
-
-
- 降水 0.0mm
-
-
-
-
-
-
-
- 气压 979hPa
-
-
-
-
-
- 能见 5km
-
-
-
-
-
- 云量 50%
-
-
-
-
-
- 日出 06:37
-
-
-
-
-
- 日落 19:01
-
-
+
+
+
示例信息