diff --git a/README.md b/README.md index d632255..7646c60 100644 --- a/README.md +++ b/README.md @@ -38,25 +38,7 @@ 部署网易云 API,详情参见 [Binaryify/NeteaseCloudMusicApi](https://github.com/Binaryify/NeteaseCloudMusicApi) -3. 更改api地址 - - 打开`./source/js/main.js`,将第二行apiAd的值修改为api地址。**一定不要忘了地址最后的`/`** - - ```javascript - //api地址 - let apiAd = "";//一定不要忘了地址最后的'/' - ``` - - 如: - - ```javascript - //api地址 - let apiAd = "http://127.0.0.1:3000/";//一定不要忘了地址最后的'/' - ``` - - 如果你是在本地部署的api,则api地址为`"http://localhost:3000/"` - -4. 部署网页 +3. 部署网页 - Windows @@ -108,6 +90,12 @@ 请使用Apache服务或Nginx服务部署。 +4. 在网页中输入api地址,一定不要忘了地址最后的/ + + 如: `http://127.0.0.1:3000/` + + 如果你是在本地部署的api,则api地址为`"http://localhost:3000/"` + ## 贡献者 @[Timlzh](https://github.com/timlzh/) @@ -115,6 +103,7 @@ ## 鸣谢 [qier222/YesPlayMusic](https://github.com/qier222/YesPlayMusic) + [Binaryify/NeteaseCloudMusicApi](https://github.com/Binaryify/NeteaseCloudMusicApi) diff --git a/source/js/main.js b/source/js/main.js index 933e21c..1a1cdc2 100644 --- a/source/js/main.js +++ b/source/js/main.js @@ -1,7 +1,5 @@ -//api地址 -let apiAd = "http://csgo.itstim.xyz:3000/";//一定不要忘了地址最后的'/' - //变量声明 +let apiAd = localStorage.apiAd; let loginMethod = 1; let loginStatus = 0; let loginCookie = localStorage.cookie; @@ -65,7 +63,17 @@ shuffledPlayingIndexs = localStorage.shuffledPlayingIndexs ? JSON.parse(localSto $(".me").hide(); $(".list").hide(); $(".playing_div").hide(); -if(apiAd == "") alert("请正确填入api地址!"); +if(!apiAd){ + localStorage.apiAd = apiAd = prompt("请输入api地址 \n 一定不要忘了地址最后的/","http://localhost:3000/"); + location.reload(); +}else{ + let api_adr = apiAd + "search/hot"; + let data; + if (!(data = ajaxGet(api_adr))) { + localStorage.apiAd = apiAd = ""; + location.reload(); + } +} transInputIcon(".search_input", ".search_btn"); transInputIcon("#account_input", ".fa-envelope"); transInputIcon("#account_input", ".fa-mobile-alt");