From d95b2708c3d8a57f6d7e88c6928ac925c612038c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BA=95=E5=B1=82=E7=94=A8=E6=88=B7?= Date: Thu, 7 Jul 2022 21:42:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=20&=20=E5=A4=A9=E6=B0=94=20API=20=E6=9B=B4=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 19 ++++-- README_EN.md | 19 ++++-- font/Pacifico-Regular.ttf | Bin 12232 -> 12980 bytes index.html | 18 +++-- js/main.js | 135 +++++++++++++++++++++++++------------- js/music.js | 2 +- js/set.js | 129 ++++++++++++++++++------------------ 7 files changed, 193 insertions(+), 129 deletions(-) diff --git a/README.md b/README.md index 33937dd..0854ca1 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,6 @@ >主页的 Logo 字体已经过压缩,若用本站 Logo 以外的字母会变回默认字体,这里是 [完整字体](https://file.imsyy.top/font/Pacifico-Regular.ttf) ->天气 API 每日限量100次,需 [自行申请](https://www.tianqiapi.com/),或更换其他 API - ### Demo >由于 CDN 缓存原因,查看最新效果可能需要 `Ctrl` + `F5` 强制刷新浏览器缓存 @@ -28,7 +26,17 @@ - [x] 移动端适配 * [ ] 还没想好呢 -### 配置 + +### 天气 + +由于原天气 API 不稳定,已更换天气 API,现需要前往以下网站获取 key + +- 前往 [ROLL](https://www.mxnzp.com/doc/list) 获取 app_id 和 app_secret,用于获取城市信息 +- 前往 [和风天气](https://dev.qweather.com/) 获取 key,用于获取天气信息 + +也可自行更换其他方式 + + ### 音乐 @@ -137,7 +145,8 @@ make clean all * [MetingAPI By 武恩赐](https://api.wuenci.com/meting/api/) * [小歪 API](https://api.ixiaowai.cn/) -* [天气 API](https://www.tianqiapi.com/) +* [和风天气](https://dev.qweather.com/) +* [ROLL](https://www.mxnzp.com/doc/list) * [Hitokoto 一言](https://hitokoto.cn/)    diff --git a/README_EN.md b/README_EN.md index f5bae98..5d8cc53 100644 --- a/README_EN.md +++ b/README_EN.md @@ -9,8 +9,6 @@ Simple little homepage, had enough of the original one and made a new one >The logo font on the home page has been compressed, so if you use a font other than this logo, it will change back to the default font, Here is the [full font](https://file.imsyy.top/font/Pacifico-Regular.ttf) ->Weather API is limited to 100 times per day, must [Apply on your own](https://www.tianqiapi.com/), or change to another api - ### Demo >Due to CDN caching, you may need `Ctrl` + `F5` to force a browser cache refresh to see the latest results @@ -28,7 +26,17 @@ Simple little homepage, had enough of the original one and made a new one - [x] Mobile adaptation * [ ] Haven't thought about it yet -### Configuration +### Weather + +Because the original weather API is unstable, the weather API has been replaced. Now you need to go to the following website to obtain the key + +- to [ROLL] (https://www.mxnzp.com/doc/list) for app_id and app_secret, used to capture the city + +- to [and wind weather] (https://dev.qweather.com/) to obtain the key, is used to get the weather information + +It can also be replaced by other methods + + ### Music @@ -137,7 +145,8 @@ make clean all * [MetingAPI By wuenci](https://api.wuenci.com/meting/api/) * [小歪 API](https://api.ixiaowai.cn/) -* [天气 API](https://www.tianqiapi.com/) +* [和风天气](https://dev.qweather.com/) +* [ROLL](https://www.mxnzp.com/doc/list) * [Hitokoto 一言](https://hitokoto.cn/)    diff --git a/font/Pacifico-Regular.ttf b/font/Pacifico-Regular.ttf index eb60455b4a7d73bb18ad430680d3382b50f3956b..063d8ded860995bc4add8641902d6acf40bc3af1 100644 GIT binary patch delta 1200 zcmaKrT})eL7{~wb`<~O%L3=v-L0O?I{i3A|q`)~0S6b#k$S7Y%hQS336fmJs84^GP z#2FGUFiwn_nIF>&jhQnfl|8ZTy+C1&x$81FQGEMClLCT1qbr=TXg(BwSlwN@;`0Ph0u;`ri%w`9Yk0*61Q{JF{8RQ5I1{srmZ02aqo`dp6c zRv`8+J&UGhmM7yk&)R^}F9G-0)0y;yVYd7RX+Kk_(^N2ZaPqSN<$>w!!cxL7O;LW0 z^7Way@$@j*??2EB`l;}2HocT%SC!AmP-w_Io6cqi-+B5HP`3k!i@CXT3;ZWBK@Al2 zvD|znw^hAzo_hL?^6Ox97igE3;(ZtP`i$QFf_J-@ZTR>ue9|XaW;uAdfS+xm3U^S? zI-&6&5o5QvZ?WanLpXyB9!CxfSj4if(;KT$jXK)+}h z>Un)fzpB5fzplTkzoK8#U(WCFx0E&UD<>4!g54rZzW)Le+Jggn~kn!S5rR zRuKHYg2`Ft;f3<2mqS6fPl%Dhhaamwc_NkWNL?7~Ug-`6kNAZcj1P^}cP4rsZO^|{ zl$q9AE1Y&kvKJq#jcdM!Dwjt++tHP4iw-9fNw3ppwR(zbY7@spYM}gRY$&m~mcQ)S zWJJZQ-(|nBo2bFeuEH2+J*Rg}1SbH-CC=sv5SPR%VL_VaQ&SM)9ya?nY5jkF2W)B( z@dqM-;J<9tiG4Z;2-JTV5Cj6H{Y}nb@NZ?4lPy|2=&_YaOg5L4g zkyo-RYvPW19C2n84X;LnxtMDxdmEv$p3=Jzs=nh+ijl1r<}G*yLRyX=y;;B z$zm=x*EcA|l}F|N;b)$#bRV){}yZHYA delta 525 zcmXAlNoZ417=^$4UTkb@n{-HRz=i}`idL!=30PbxSS>iDx-b8ou~x|1hcyS>f+qXIp+@NKTE0FXC+wM&eX;-aImz@%_)CALyZv^YduWe?mB zjE(PZI-=aQ_7%gebzM;Ij^KHZI~R)hU3c(-*&$gNV2EM%%Y+AI#
-
+
2000 年 0 月 00 日 星期一
00:00:00 @@ -189,10 +189,9 @@
天气  加载失败  - °C~ - °C  + *°C  - + *
@@ -370,7 +369,7 @@
imsyy .top
-  v 3.2 +  v 3.3 @@ -438,9 +437,14 @@  音乐播放器支持音量控制 -  时光胶囊显示错误 +  修复天气 API + -  移动端动画及细节 +  时光胶囊显示错误 + + +  移动端动画及细节 +  图标更换为 Font Awesome diff --git a/js/main.js b/js/main.js index 84535c8..0782451 100644 --- a/js/main.js +++ b/js/main.js @@ -43,7 +43,7 @@ body.addEventListener('mousemove', (e) => { //移动端去除鼠标样式 switch (true) { case navigator.userAgent.indexOf('Mobile') > 0: - $('#g-pointer-2').css("display", "none"); + $('#g-pointer-2').css("display", "none"); } //加载完成后执行 @@ -146,7 +146,7 @@ $('#hitokoto').click(function () { .catch(console.error) } else { iziToast.show({ - timeout: 2000, + timeout: 1000, icon: "fa-solid fa-circle-exclamation", message: '你点太快了吧' }); @@ -154,19 +154,60 @@ $('#hitokoto').click(function () { }); //获取天气 -//每日限量 100 次 -//请前往 https://www.tianqiapi.com/ 申请(免费) -fetch(localStorage.getItem('weather_api')) - .then(response => response.json()) - .then(data => { - $('#wea_text').html(data.wea) - $('#city_text').html(data.city) - $('#tem_night').html(data.tem_night) - $('#tem_day').html(data.tem_day) - $('#win_text').html(data.win) - $('#win_speed').html(data.win_speed) - }) - .catch(console.error) +//请前往 https://www.mxnzp.com/doc/list 申请 app_id 和 app_secret +//请前往 https://dev.qweather.com/ 申请 key +const add_id = "wrknltonr0foslhs"; // app_id +const app_secret = "Nlh1c0F6d0ZDU2pDR0J3YVBVbkhudz09"; // app_secret +const key = "433f0c48615a48dfaf2f2b2444297e79" // key +function getWeather() { + fetch("https://www.mxnzp.com/api/ip/self?app_id=" + add_id + "&app_secret=" + app_secret) + .then(response => response.json()) + .then(data => { + let str = data.data.city + let city = str.replace(/市/g, '') + $('#city_text').html(city); + fetch("https://geoapi.qweather.com/v2/city/lookup?location=" + city + "&number=1&key=" + key) + .then(response => response.json()) + .then(location => { + let id = location.location[0].id + fetch("https://devapi.qweather.com/v7/weather/now?location=" + id + "&key=" + key) + .then(response => response.json()) + .then(weather => { + $('#wea_text').html(weather.now.text) + $('#tem_text').html(weather.now.temp) + $('#win_text').html(weather.now.windDir) + $('#win_speed').html(weather.now.windScale) + }) + }) + }) + .catch(console.error); +} + +getWeather(); + +$('#upWeather').click(function () { + if (times == 0) { + times = 1; + var index = setInterval(function () { + times--; + if (times == 0) { + clearInterval(index); + } + }, 60000); + getWeather(); + iziToast.show({ + timeout: 2000, + icon: "fa-solid fa-cloud-sun", + message: '实时天气已更新' + }); + } else { + iziToast.show({ + timeout: 1000, + icon: "fa-solid fa-circle-exclamation", + message: '请稍后再更新哦' + }); + } +}); //获取时间 var t = null; @@ -243,18 +284,41 @@ $("#twitter").mouseover(function () { $("#link-text").html("通过这里联系我"); }); +//自动变灰 +var myDate = new Date; +var mon = myDate.getMonth() + 1; +var date = myDate.getDate(); +var days = ['4.4', '5.12', '7.7', '9.9', '9.18', '12.13']; +for (var day of days) { + var d = day.split('.'); + if (mon == d[0] && date == d[1]) { + document.write( + '' + ) + $("#change").html("Silence in silence"); + $("#change1").html("今天是中国国家纪念日,全站已切换为黑白模式"); + window.addEventListener('load', function () { + iziToast.show({ + timeout: 14000, + icon: "fa-solid fa-clock", + message: '今天是中国国家纪念日' + }); + }, false); + } +} + //更多页面切换 var shoemore = false; $('#switchmore').on('click', function () { shoemore = !shoemore; if (shoemore && $(document).width() >= 990) { $('#container').attr('class', 'container mores'); - $("#change").html(localStorage.getItem('des_tip_change')); - $("#change1").html(localStorage.getItem('des_title_change')); + $("#change").html("Oops !"); + $("#change1").html("哎呀,这都被你发现了( 再点击一次可关闭 )"); } else { $('#container').attr('class', 'container'); - $("#change").html(localStorage.getItem('des_tip')); - $("#change1").html(localStorage.getItem('des_title')); + $("#change").html("Hello World !"); + $("#change1").html("一个建立于 21 世纪的小站,存活于互联网的边缘"); } }); @@ -302,8 +366,8 @@ window.addEventListener('load', function () { if (window.innerWidth <= 990) { //移动端隐藏更多页面 $('#container').attr('class', 'container'); - $("#change").html(localStorage.getItem('des_tip')); - $("#change1").html(localStorage.getItem('des_title')); + $("#change").html("Hello World !"); + $("#change1").html("一个建立于 21 世纪的小站,存活于互联网的边缘"); //移动端隐藏弹窗页面 $('#box').css("display", "none"); @@ -341,29 +405,6 @@ document.oncontextmenu = function () { return false; } -//自动变灰 -var myDate = new Date; -var mon = myDate.getMonth() + 1; -var date = myDate.getDate(); -var days = ['4.4', '5.12', '7.7', '9.9', '9.18', '12.13']; -for (var day of days) { - var d = day.split('.'); - if (mon == d[0] && date == d[1]) { - document.write( - '' - ) - $("#change").html("Silence in silence"); - $("#change1").html("今天是中国国家纪念日,全站已切换为黑白模式"); - window.addEventListener('load', function () { - iziToast.show({ - timeout: 14000, - icon: "fa-solid fa-candle-holder", - message: '今天是中国国家纪念日' - }); - }, false); - } -} - //控制台输出 console.clear(); var styleTitle1 = ` @@ -388,11 +429,11 @@ var title2 = ` |_____|_| |_|_____/ |_| |_| ` var content = ` -版 本 号:3.2 -更新日期:2022-06-28 +版 本 号:3.3 +更新日期:2022-07-06 主页: https://www.imsyy.top Github: https://github.com/imsyy/home ` console.log(`%c${title1} %c${title2} -%c${content}`, styleTitle1, styleTitle2, styleContent) +%c${content}`, styleTitle1, styleTitle2, styleContent) \ No newline at end of file diff --git a/js/music.js b/js/music.js index 7e37135..aff7a06 100644 --- a/js/music.js +++ b/js/music.js @@ -14,7 +14,7 @@ var type = "playlist"; //song: 单曲; playlist: 歌单; album: 唱片 var id = "7452421335"; //封面 ID / 单曲 ID / 歌单 ID $.ajax({ - url: "https://api.wuenci.com/meting/api/?server=" + server + "&type=" + type + "&id=" + id, //json文件位置,文件名 + url: "https://api.wuenci.com/meting/api/?server=" + server + "&type=" + type + "&id=" + id, type: "GET", dataType: "JSON", success: function (data) { diff --git a/js/set.js b/js/set.js index baab837..f16ae8e 100644 --- a/js/set.js +++ b/js/set.js @@ -5,70 +5,71 @@ GitHub:https://github.com/imsyy/home 版权所有,请勿删除 */ -$(function () { - var url = "../setting.json" - $.getJSON( - url, - function (data) { - /* 页头数据 */ - $('title').text(data.title); - $('#loading-title').html(data.title); - $("meta[name='description']").attr('content', data.description); - $("meta[name='keywords']").attr('content', data.keywords); - $("meta[name='author']").attr('content', data.author); - /* 基础信息 */ - $("#logo-img").attr("src", data.logo_img); - $('#logo-text-1').html(data.logo_text_1); - $('#logo-text-2').html("." + data.logo_text_2); - $('#logo-title-other').html(data.logo_text_1); - $('#logo-title-other-small').html("." + data.logo_text_2); - $('#logo-text-small').html(data.logo_text_1 + "." + data.logo_text_2); - $('#change').html(data.des_title[0]); - $('#change1').html(data.des_title[1]); - localStorage.setItem('des_tip', data.des_title[0]); - localStorage.setItem('des_tip_change', data.des_title_change[0]); - localStorage.setItem('des_title', data.des_title[1]); - localStorage.setItem('des_title_change', data.des_title_change[1]); - /* 社交链接 */ - $('#github').attr('href', "https://github.com/" + data.github); - $('#qq').attr('href', "https://wpa.qq.com/msgrd?v=3&uin=" + data.qq + "&site=qq&menu=yes"); - $('#email').attr('href', "mailto:" + data.email); - $('#telegram').attr('href', "https://t.me/" + data.telegram); - $('#twitter').attr('href', "https://twitter.com/" + data.twitter); - /* 天气 API */ - localStorage.setItem('weather_api', data.weather_api); - /* 快捷链接 */ - $('#link-url-1').attr('href', data.link_1[0]); - $('#link-icon-1').attr('class', data.link_1[1]); - $('#link-name-1').html(data.link_1[2]); - $('#link-url-2').attr('href', data.link_2[0]); - $('#link-icon-2').attr('class', data.link_2[1]); - $('#link-name-2').html(data.link_2[2]); - $('#link-url-3').attr('href', data.link_3[0]); - $('#link-icon-3').attr('class', data.link_3[1]); - $('#link-name-3').html(data.link_3[2]); - $('#link-url-4').attr('href', data.link_4[0]); - $('#link-icon-4').attr('class', data.link_4[1]); - $('#link-name-4').html(data.link_4[2]); - $('#link-url-5').attr('href', data.link_5[0]); - $('#link-icon-5').attr('class', data.link_5[1]); - $('#link-name-5').html(data.link_5[2]); - $('#link-url-6').attr('href', data.link_6[0]); - $('#link-icon-6').attr('class', data.link_6[1]); - $('#link-name-6').html(data.link_6[2]); - //壁纸 API - $('#wallpaper_text1').html(data.wallpaper_api[0][0]); - localStorage.setItem('wallpaper_api_1', data.wallpaper_api[0][1]); - $('#wallpaper_text2').html(data.wallpaper_api[1][0]); - localStorage.setItem('wallpaper_api_2', data.wallpaper_api[1][1]); - $('#wallpaper_text3').html(data.wallpaper_api[2][0]); - localStorage.setItem('wallpaper_api_3', data.wallpaper_api[2][1]); - //页脚版权 - $('#power-year').html(data.Copyright_year); - $('#power-text').html(data.Copyright_text); - } - ) -}); +/* 自定义配置 */ +// $(function () { +// var url = "../setting.json" +// $.getJSON( +// url, +// function (data) { +// /* 页头数据 */ +// $('title').text(data.title); +// $('#loading-title').html(data.title); +// $("meta[name='description']").attr('content', data.description); +// $("meta[name='keywords']").attr('content', data.keywords); +// $("meta[name='author']").attr('content', data.author); +// /* 基础信息 */ +// $("#logo-img").attr("src", data.logo_img); +// $('#logo-text-1').html(data.logo_text_1); +// $('#logo-text-2').html("." + data.logo_text_2); +// $('#logo-title-other').html(data.logo_text_1); +// $('#logo-title-other-small').html("." + data.logo_text_2); +// $('#logo-text-small').html(data.logo_text_1 + "." + data.logo_text_2); +// $('#change').html(data.des_title[0]); +// $('#change1').html(data.des_title[1]); +// localStorage.setItem('des_tip', data.des_title[0]); +// localStorage.setItem('des_tip_change', data.des_title_change[0]); +// localStorage.setItem('des_title', data.des_title[1]); +// localStorage.setItem('des_title_change', data.des_title_change[1]); +// /* 社交链接 */ +// $('#github').attr('href', "https://github.com/" + data.github); +// $('#qq').attr('href', "https://wpa.qq.com/msgrd?v=3&uin=" + data.qq + "&site=qq&menu=yes"); +// $('#email').attr('href', "mailto:" + data.email); +// $('#telegram').attr('href', "https://t.me/" + data.telegram); +// $('#twitter').attr('href', "https://twitter.com/" + data.twitter); +// /* 天气 API */ +// localStorage.setItem('weather_api', data.weather_api); +// /* 快捷链接 */ +// $('#link-url-1').attr('href', data.link_1[0]); +// $('#link-icon-1').attr('class', data.link_1[1]); +// $('#link-name-1').html(data.link_1[2]); +// $('#link-url-2').attr('href', data.link_2[0]); +// $('#link-icon-2').attr('class', data.link_2[1]); +// $('#link-name-2').html(data.link_2[2]); +// $('#link-url-3').attr('href', data.link_3[0]); +// $('#link-icon-3').attr('class', data.link_3[1]); +// $('#link-name-3').html(data.link_3[2]); +// $('#link-url-4').attr('href', data.link_4[0]); +// $('#link-icon-4').attr('class', data.link_4[1]); +// $('#link-name-4').html(data.link_4[2]); +// $('#link-url-5').attr('href', data.link_5[0]); +// $('#link-icon-5').attr('class', data.link_5[1]); +// $('#link-name-5').html(data.link_5[2]); +// $('#link-url-6').attr('href', data.link_6[0]); +// $('#link-icon-6').attr('class', data.link_6[1]); +// $('#link-name-6').html(data.link_6[2]); +// //壁纸 API +// $('#wallpaper_text1').html(data.wallpaper_api[0][0]); +// localStorage.setItem('wallpaper_api_1', data.wallpaper_api[0][1]); +// $('#wallpaper_text2').html(data.wallpaper_api[1][0]); +// localStorage.setItem('wallpaper_api_2', data.wallpaper_api[1][1]); +// $('#wallpaper_text3').html(data.wallpaper_api[2][0]); +// localStorage.setItem('wallpaper_api_3', data.wallpaper_api[2][1]); +// //页脚版权 +// $('#power-year').html(data.Copyright_year); +// $('#power-text').html(data.Copyright_text); +// } +// ) +// }); // 背景图片 Cookies function setBgImg(bg_img) {