💡 起因翻CSDN的时候看到这篇:Kindle可用的天气时钟,大概就是把吃灰的Kindle拿来当天气时钟用。
说实话博主家里也有几个吃灰设备...
读了下源码,做得还挺完整的——农历、天气、一言都有。不过看着看着就手痒了:这API Key直接写前端里不太行啊,而且每次换个城市还得改HTML…
不如干脆自己动手改一版吧。
🔍 原项目长啥样简单过一下原项目:
时间日期 农历转换 天气数据 一言名句 天气图标
用的是和风天气API + lunar.js做农历,整体架构就是纯前端。
问题出在哪翻了翻代码,列几个比较明显的:
问题
怎么回事
严不严重
Key裸奔
API Key明文写在JS里
挺危险
城市写死
想换城市得改HTML
有点麻烦
部署麻烦
没有现成的部署方案
还好
第一个问题最要命——Key放前端,随便谁F12一下就能拿走。虽然和风免费版有调用限制,但还是不太好。
🛠️ 怎么改的思路其实很简单:把敏感操作挪到服务端。
graph LR
A[浏览器] -->|请求天气| B[Vercel函数]
B -- ...
Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.
Quick StartCreate a new post1$ hexo new "My New Post"
More info: Writing
Run server1$ hexo server
More info: Server
Generate static files1$ hexo generate
More info: Generating
Deploy to remote sites1$ hexo deploy
More info: Deployment















