From 8b37d72b03a604948851b96d4ecee58a1902c8d5 Mon Sep 17 00:00:00 2001 From: chenyinheng30 Date: Wed, 15 Nov 2023 18:02:46 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AE=BF=E9=97=AE?= =?UTF-8?q?=E8=80=85=E5=A4=A9=E6=B0=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layouts/index.html | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/layouts/index.html b/layouts/index.html index a88f43f8c..16376e4fd 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -4,6 +4,27 @@ {{- $posts := .Site.Params.home.posts -}}
+
+ + + {{- /* Profile */ -}} {{- if ne $profile.enable false -}} {{- partial "home/profile.html" . -}} From 71d9a6e9fc0971b5ed13aab4dd973d9623facbc1 Mon Sep 17 00:00:00 2001 From: chenyinheng30 Date: Thu, 16 Nov 2023 00:02:59 +0800 Subject: [PATCH 02/12] =?UTF-8?q?=E6=B5=8B=E8=AF=95=20ip-api.com?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layouts/index.html | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/layouts/index.html b/layouts/index.html index 16376e4fd..dbf346bf2 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -6,24 +6,12 @@
- + {{- /* Profile */ -}} {{- if ne $profile.enable false -}} From 72a9dca768bf3d998e720161e9eed22eed2a54f1 Mon Sep 17 00:00:00 2001 From: chenyinheng30 Date: Thu, 16 Nov 2023 00:46:44 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E7=9A=84=20 - {{- /* Profile */ -}} {{- if ne $profile.enable false -}} From 61b4171182f035da532cf39880aabf1316341cc4 Mon Sep 17 00:00:00 2001 From: chenyinheng30 Date: Thu, 16 Nov 2023 00:53:56 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=E4=BD=BF=E7=94=A8=20fetch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layouts/index.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/layouts/index.html b/layouts/index.html index 8b2683b0b..be93db5fd 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -10,10 +10,10 @@ var weatherElement = document.getElementById("weather"); weatherElement.innerHTML = `ip: ${ipData.query} ${ipData.city}`; } - const url = 'http://ip-api.com/json?fields=8208&lang=zh-CN&callback=handleIpApi'; - const script = document.createElement('script'); - script.src = url; - document.body.appendChild(script); + const url = 'http://ip-api.com/json?fields=8208&lang=zh-CN'; + fetch(url) + .then(response => response.json()) + .then(ipData => handleIpApi(ipData)); {{- /* Profile */ -}} From 568e4b7a277411eb2d5d234870f1b463fe8c631e Mon Sep 17 00:00:00 2001 From: chenyinheng30 Date: Thu, 16 Nov 2023 18:41:57 +0800 Subject: [PATCH 05/12] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=9B=B4=E6=94=B9?= =?UTF-8?q?=EF=BC=9A=E6=9F=A5=E7=9C=8B=E5=A4=B4=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layouts/index.html | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/layouts/index.html b/layouts/index.html index be93db5fd..63750f4d1 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -15,6 +15,15 @@ .then(response => response.json()) .then(ipData => handleIpApi(ipData)); + {{- /* Profile */ -}} {{- if ne $profile.enable false -}} From 99e8339e0779b46a17f15b07d1f27111554eda09 Mon Sep 17 00:00:00 2001 From: chenyinheng30 Date: Thu, 16 Nov 2023 19:00:56 +0800 Subject: [PATCH 06/12] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=9B=B4=E6=94=B9?= =?UTF-8?q?=EF=BC=9A=E6=9F=A5=E7=9C=8B=20window.location?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layouts/index.html | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/layouts/index.html b/layouts/index.html index 63750f4d1..ee7d2c7f6 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -16,13 +16,7 @@ .then(ipData => handleIpApi(ipData)); {{- /* Profile */ -}} From 283fe5a00df51b312965043b1b3b98974b110adb Mon Sep 17 00:00:00 2001 From: chenyinheng30 Date: Thu, 16 Nov 2023 20:46:42 +0800 Subject: [PATCH 07/12] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=88=91=E7=9A=84api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layouts/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/index.html b/layouts/index.html index dbf346bf2..3cc3e6f8a 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -11,7 +11,7 @@ weatherElement.innerHTML = `ip: ${ipData.query} ${ipData.city}`; } - + {{- /* Profile */ -}} {{- if ne $profile.enable false -}} From 1a2f7487cbbdf79c3e9f39d67aa65483bf8b7fa0 Mon Sep 17 00:00:00 2001 From: chenyinheng30 Date: Thu, 16 Nov 2023 21:12:21 +0800 Subject: [PATCH 08/12] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=94=99=E8=AF=AF?= =?UTF-8?q?=EF=BC=9A=E5=8E=BB=E9=99=A4=20ip-api.com?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layouts/index.html | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/layouts/index.html b/layouts/index.html index 95331a76f..cb324b4e3 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -10,12 +10,8 @@ var weatherElement = document.getElementById("weather"); weatherElement.innerHTML = `ip: ${ipData.query} ${ipData.city}`; } - const url = 'http://ip-api.com/json?fields=8208&lang=zh-CN'; - fetch(url) - .then(response => response.json()) - .then(ipData => handleIpApi(ipData)); - + {{- /* Profile */ -}} {{- if ne $profile.enable false -}} From ad4429651ef33cacd1e423f715116d61f5cb8991 Mon Sep 17 00:00:00 2001 From: chenyinheng30 Date: Thu, 16 Nov 2023 21:35:16 +0800 Subject: [PATCH 09/12] =?UTF-8?q?=E6=9C=80=E6=96=B0=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E8=B7=A8=E5=9F=9F=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layouts/index.html | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/layouts/index.html b/layouts/index.html index cb324b4e3..7cd5d87cb 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -6,12 +6,21 @@
- + {{- /* Profile */ -}} {{- if ne $profile.enable false -}} From e8915e315193390f06f208ecebb7d47cc55f41aa Mon Sep 17 00:00:00 2001 From: chenyinheng30 Date: Thu, 16 Nov 2023 22:05:38 +0800 Subject: [PATCH 10/12] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9F=8E=E5=B8=82?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layouts/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/index.html b/layouts/index.html index 7cd5d87cb..8d8c010f8 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -16,7 +16,7 @@ .then(response => response.json()) .then(weatherData => { var weatherElement = document.getElementById("weather"); - weatherElement.innerHTML = `实时气温:${weatherData.current.temperature_2m}°C`; + weatherElement.innerHTML = `实时气温:${weatherData.current.temperature_2m}°C ${localData.city}`; }) } From 637e939cedf5c81066589e5ea0640a2376cdd384 Mon Sep 17 00:00:00 2001 From: chenyinheng30 Date: Fri, 17 Nov 2023 12:53:00 +0800 Subject: [PATCH 11/12] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=EF=BC=9A=20=E5=9F=8E?= =?UTF-8?q?=E5=B8=82=E3=80=81=E8=BA=AB=E4=BB=BD=E3=80=81=E5=9B=BD=E5=AE=B6?= =?UTF-8?q?emoji?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layouts/index.html | 60 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/layouts/index.html b/layouts/index.html index 8d8c010f8..3f40daace 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -6,18 +6,60 @@
From fc31cfc3da281c1d17467b7fce7f745e213d597f Mon Sep 17 00:00:00 2001 From: chenyinheng30 Date: Fri, 17 Nov 2023 13:32:16 +0800 Subject: [PATCH 12/12] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layouts/index.html | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/layouts/index.html b/layouts/index.html index 3f40daace..61c66d3f2 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -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;