diff --git a/docs/other.md b/docs/other.md index d5f6e8559..eda29a377 100644 --- a/docs/other.md +++ b/docs/other.md @@ -9,6 +9,31 @@ pageClass: routes ### 新闻 + +## Amazfit Watch Faces + +手表型号可在网站中选择后到地址栏查看 + +| Amazfit Bip | Amazfit Cor | Amazfit GTR | Amazfit GTS | Amazfit Stratos | Amazfit T-Rex | Amazfit Verge | Amazfit Verge Lite | Honor Band 5 | Honor Watch Magic | Huawei Watch GT | Xiaomi Mi Band 4 | +| ----------- | ----------- | ----------- | ----------- | --------------- | ------------- | ------------- | ------------------ | ------------ | ----------------- | --------------- | ---------------- | +| bip | cor | gtr | gts | pace | t-rex | verge | verge-lite | honor-band-5 | honor-watch-magic | huawei-watch-gt | mi-band-4 | + +### 新品上架 + + + +### 最近更新 + + + +### 排行榜 + + + +### 搜索结果 + + + ## Apple ### 更换和维修扩展计划 diff --git a/lib/router.js b/lib/router.js index 0ca7e7f69..b8cf14f71 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2871,6 +2871,12 @@ router.get('/changku', require('./routes/changku/index')); // 上海市生态环境局 router.get('/gov/shanghai/sthj', require('./routes/gov/shanghai/sthj')); +// Amazfit Watch Faces +router.get('/amazfitwatchfaces/fresh/:model/:type?/:lang?', require('./routes/amazfitwatchfaces/fresh')); +router.get('/amazfitwatchfaces/updated/:model/:type?/:lang?', require('./routes/amazfitwatchfaces/updated')); +router.get('/amazfitwatchfaces/top/:model/:type?/:time?/:sortBy?/:lang?', require('./routes/amazfitwatchfaces/top')); +router.get('/amazfitwatchfaces/search/:model/:keyword?/:sortBy?', require('./routes/amazfitwatchfaces/search')); + // 猫耳FM router.get('/missevan/drama/:id', require('./routes/missevan/drama')); diff --git a/lib/routes/amazfitwatchfaces/fresh.js b/lib/routes/amazfitwatchfaces/fresh.js new file mode 100644 index 000000000..826673434 --- /dev/null +++ b/lib/routes/amazfitwatchfaces/fresh.js @@ -0,0 +1,7 @@ +const utils = require('./utils'); + +module.exports = async (ctx) => { + const currentUrl = `${ctx.params.model}/fresh?${ctx.params.lang ? 'lang=' + ctx.params.lang : ''}${ctx.params.type ? '&compatible=' + ctx.params.type : ''}`; + + ctx.state.data = await utils(ctx, currentUrl); +}; diff --git a/lib/routes/amazfitwatchfaces/search.js b/lib/routes/amazfitwatchfaces/search.js new file mode 100644 index 000000000..a37ad328c --- /dev/null +++ b/lib/routes/amazfitwatchfaces/search.js @@ -0,0 +1,7 @@ +const utils = require('./utils'); + +module.exports = async (ctx) => { + const currentUrl = `search/${ctx.params.model}/tags/${ctx.params.keyword ? ctx.params.keyword : ''}${ctx.params.sortBy ? '?sortby=' + ctx.params.sortBy : ''}`; + + ctx.state.data = await utils(ctx, currentUrl); +}; diff --git a/lib/routes/amazfitwatchfaces/top.js b/lib/routes/amazfitwatchfaces/top.js new file mode 100644 index 000000000..f149d3856 --- /dev/null +++ b/lib/routes/amazfitwatchfaces/top.js @@ -0,0 +1,9 @@ +const utils = require('./utils'); + +module.exports = async (ctx) => { + const currentUrl = `${ctx.params.model}/top?${ctx.params.lang ? 'lang=' + ctx.params.lang : ''}${ctx.params.type ? '&compatible=' + ctx.params.type : ''}${ctx.params.sortBy ? '&sortby=' + ctx.params.sortBy : ''}${ + ctx.params.time ? '&topof=' + ctx.params.time : '' + }`; + + ctx.state.data = await utils(ctx, currentUrl); +}; diff --git a/lib/routes/amazfitwatchfaces/updated.js b/lib/routes/amazfitwatchfaces/updated.js new file mode 100644 index 000000000..c9b10df8b --- /dev/null +++ b/lib/routes/amazfitwatchfaces/updated.js @@ -0,0 +1,7 @@ +const utils = require('./utils'); + +module.exports = async (ctx) => { + const currentUrl = `${ctx.params.model}/updated?${ctx.params.lang ? 'lang=' + ctx.params.lang : ''}${ctx.params.type ? '&compatible=' + ctx.params.type : ''}`; + + ctx.state.data = await utils(ctx, currentUrl); +}; diff --git a/lib/routes/amazfitwatchfaces/utils.js b/lib/routes/amazfitwatchfaces/utils.js new file mode 100644 index 000000000..008e95e76 --- /dev/null +++ b/lib/routes/amazfitwatchfaces/utils.js @@ -0,0 +1,44 @@ +const url = require('url'); +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx, currentUrl) => { + const rootUrl = `https://amazfitwatchfaces.com/`; + const response = await got({ + method: 'get', + url: `${rootUrl}${currentUrl}`, + }); + const $ = cheerio.load(response.data); + const list = $('#wf-row div.col-md-3') + .slice(0, 10) + .map((_, item) => { + item = $(item); + return { + link: url.resolve(rootUrl, $(item).find('a.wf-act').attr('href')), + }; + }) + .get(); + + const items = await Promise.all( + list.map( + async (item) => + await ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ method: 'get', url: item.link }); + const content = cheerio.load(detailResponse.data); + const date = content('i.fa-calendar').parent().find('span').text(); + const ymd = date.split(' ')[0]; + + item.title = `[${content('code').text()}] ${content('title').text().split(' - ')[0]}`; + item.description = `
${content('div.unicodebidi').text()}`; + item.pubDate = new Date(`${ymd.split('.')[2]}-${ymd.split('.')[1]}-${ymd.split('.')[0]} ${date.split(' ')[1]}`).toUTCString(); + return item; + }) + ) + ); + + return { + title: `${$('title').text().split('|')[0]} | Amazfit Watch Faces`, + link: currentUrl, + item: items, + }; +};