From 77c9450311bf74e2af6db4c3a232da9cc132ea71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?FH=E4=BA=91=E5=BD=A9?= Date: Wed, 22 May 2019 14:26:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E4=BA=86=E5=BF=85?= =?UTF-8?q?=E5=BA=94=E5=A3=81=E7=BA=B8=20(#2194)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/picture.md | 6 ++++++ lib/router.js | 3 +++ lib/routes/bing/index.js | 25 +++++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 lib/routes/bing/index.js diff --git a/docs/picture.md b/docs/picture.md index 34c6da015a..f21e31ca78 100644 --- a/docs/picture.md +++ b/docs/picture.md @@ -151,3 +151,9 @@ pageClass: routes ### 主题 + +## Bing 壁纸 + +### 每日壁纸 + + diff --git a/lib/router.js b/lib/router.js index 9ca43f9513..23da5298b1 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1316,6 +1316,9 @@ router.get('/enclavebooks/category/:id?', require('./routes/enclavebooks/categor router.get('/dsndsht23/:subforumid', require('./routes/dsndsht23/index')); router.get('/dsndsht23', require('./routes/dsndsht23/index')); +// Bing壁纸 +router.get('/bing', require('./routes/bing/index')); + // MaxNews - DotA 2 router.get('/maxnews/dota2', require('./routes/maxnews/dota2')); diff --git a/lib/routes/bing/index.js b/lib/routes/bing/index.js new file mode 100644 index 0000000000..9940137cb6 --- /dev/null +++ b/lib/routes/bing/index.js @@ -0,0 +1,25 @@ +const axios = require('@/utils/axios'); + +module.exports = async (ctx) => { + const response = await axios({ + method: 'get', + baseURL: 'https://cn.bing.com', + url: '/HPImageArchive.aspx', + params: { + format: 'js', + idx: 0, + n: 7, + mkt: 'zh-CN', + }, + }); + const data = response.data; + ctx.state.data = { + title: 'Bing每日壁纸', + link: `https://cn.bing.com/`, + item: data.images.map((item) => ({ + title: item.copyright, + description: ``, + link: item.copyrightlink, + })), + }; +};