From 8cb3214a421c3dc22318c378e677af17c08e4bad Mon Sep 17 00:00:00 2001 From: DIYgod Date: Sat, 25 Nov 2023 22:51:32 +0800 Subject: [PATCH] feat: add uniqlo new arrival route (#13885) --- lib/routes/uniqlo/stylingbook.js | 24 ------------- lib/v2/uniqlo/maintainer.js | 3 ++ lib/v2/uniqlo/new.js | 62 ++++++++++++++++++++++++++++++++ lib/v2/uniqlo/radar.js | 12 +++++++ lib/v2/uniqlo/router.js | 3 ++ website/docs/routes/other.mdx | 4 +-- website/docs/routes/shopping.mdx | 6 ++++ 7 files changed, 88 insertions(+), 26 deletions(-) delete mode 100644 lib/routes/uniqlo/stylingbook.js create mode 100644 lib/v2/uniqlo/maintainer.js create mode 100644 lib/v2/uniqlo/new.js create mode 100644 lib/v2/uniqlo/radar.js create mode 100644 lib/v2/uniqlo/router.js diff --git a/lib/routes/uniqlo/stylingbook.js b/lib/routes/uniqlo/stylingbook.js deleted file mode 100644 index 72e0e1ea4..000000000 --- a/lib/routes/uniqlo/stylingbook.js +++ /dev/null @@ -1,24 +0,0 @@ -const got = require('@/utils/got'); - -module.exports = async (ctx) => { - const category = ctx.params.category ? ctx.params.category : 'women'; - const url = `https://style.uniqlo.com/api/v2/styleSearch.json?dptId=${category}&lang=en&limit=50&locale=my&offset=0`; - - const response = await got({ - method: 'get', - url, - }); - - const data = response.data.result.styles; - - ctx.state.data = { - title: `Uniqlo styling book`, - link: `https://www.uniqlo.com/my/stylingbook/pc/${category}`, - description: `Uniqlo styling book`, - item: data.map((item) => ({ - title: item.styleId, - description: ``, - link: `https://www.uniqlo.com/my/stylingbook/pc/style/` + item.styleId, - })), - }; -}; diff --git a/lib/v2/uniqlo/maintainer.js b/lib/v2/uniqlo/maintainer.js new file mode 100644 index 000000000..040fa2a12 --- /dev/null +++ b/lib/v2/uniqlo/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/new/:country/:category': ['DIYgod'], +}; diff --git a/lib/v2/uniqlo/new.js b/lib/v2/uniqlo/new.js new file mode 100644 index 000000000..acd8e46b1 --- /dev/null +++ b/lib/v2/uniqlo/new.js @@ -0,0 +1,62 @@ +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const { country, category } = ctx.params; + + const map = { + sg: { + url: 'https://www.uniqlo.com/sg/api/commerce/v3/en/products', + withFlag: true, + path: { + women: 5855, + men: 5856, + kids: 5857, + baby: 5858, + }, + }, + us: { + url: 'https://www.uniqlo.com/us/api/commerce/v5/en/products', + withFlag: false, + path: { + women: 22210, + men: 22211, + kids: 22212, + baby: 22213, + }, + }, + jp: { + url: 'https://www.uniqlo.com/jp/api/commerce/v5/ja/products', + withFlag: false, + path: { + women: 1071, + men: 1072, + kids: 1073, + baby: 1074, + }, + lang: 'ja', + }, + }; + const { data } = await got(map[country].url, { + searchParams: { + path: map[country].path[category], + flagCodes: map[country].withFlag ? 'salesStart newSKU,salesStart newSKU,salesStart newSKU' : undefined, + sort: 1, + limit: 24, + offset: 0, + }, + }); + + const items = data.result.items.map((item) => ({ + title: item.name, + link: `https://www.uniqlo.com/${country}/${map[country].lang || 'en'}/products/${item.productId}`, + description: `${item.longDescription || item.name}

Price: ${(item.prices.base || item.prices.promo).currency.symbol}${(item.prices.base || item.prices.promo).value}

${ + item.images.main.length ? item.images.main.map((image) => ``).join('') : '' + }${item.images.sub.map((image) => ``).join('')}`, + })); + + ctx.state.data = { + title: `Uniqlo ${category} new arrivals in ${country}`, + link: `https://www.uniqlo.com/${country}/${map[country].lang || 'en'}/feature/new/${category}`, + item: items, + }; +}; diff --git a/lib/v2/uniqlo/radar.js b/lib/v2/uniqlo/radar.js new file mode 100644 index 000000000..646f59518 --- /dev/null +++ b/lib/v2/uniqlo/radar.js @@ -0,0 +1,12 @@ +module.exports = { + 'uniqlo.com': { + _name: 'Uniqlo', + www: [ + { + title: 'New Arrivals', + docs: 'https://docs.rsshub.app/routes/shopping#uniqlo', + source: ['/sg', '/us', '/jp'], + }, + ], + }, +}; diff --git a/lib/v2/uniqlo/router.js b/lib/v2/uniqlo/router.js new file mode 100644 index 000000000..515f65a8c --- /dev/null +++ b/lib/v2/uniqlo/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/new/:country/:category', require('./new')); +}; diff --git a/website/docs/routes/other.mdx b/website/docs/routes/other.mdx index aaaa5f9c7..90b0e3019 100644 --- a/website/docs/routes/other.mdx +++ b/website/docs/routes/other.mdx @@ -835,9 +835,9 @@ Refer to [the list of supported currencies](https://wise.com/tools/exchange-rate -## 成都住建蓉 e 办 {#cheng-du-zhu-jian-rong-e-ban} +## 成都住建蓉 e 办 {#cheng-dou-zhu-jian-rong-e-ban} -### 商品住房购房登记 {#cheng-du-zhu-jian-rong-e-ban-shang-pin-zhu-fang-gou-fang-deng-ji} +### 商品住房购房登记 {#cheng-dou-zhu-jian-rong-e-ban-shang-pin-zhu-fang-gou-fang-deng-ji} diff --git a/website/docs/routes/shopping.mdx b/website/docs/routes/shopping.mdx index 4e5e9cc7d..9866d24e2 100644 --- a/website/docs/routes/shopping.mdx +++ b/website/docs/routes/shopping.mdx @@ -307,6 +307,12 @@ Language +## Uniqlo {#uniqlo} + +### New Arrivals {#uniqlo-new-arrivals} + + + ## Westore {#westore} ### 新品 {#westore-xin-pin}