Merge pull request #6629 from hellodword/add-microsoft-store

feat: add microsoft store updates
This commit is contained in:
NeverBehave 2021-01-09 23:57:17 -05:00 committed by GitHub
commit 3c2e479f63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 0 deletions

View File

@ -164,6 +164,12 @@ The owner of the official image fills in the library, for example: https://rsshu
<RouteEn author="hoilc" example="/edge/addon/gangkeiaobmjcjokiofpkfpcobpbmnln" path="/edge/addon/:crxid" :paramsDesc="['Addon id, can be found in addon url']"/>
## Microsoft Store
### Updates
<Route author="hellodword" example="/microsoft-store/updates/9WZDNCRFHVN5/CN" path="/microsoft-store/updates/:productid/:market?" :paramsDesc="['`Share` - `Copy Link` in the Store', '`CN` as default']" />
## Minecraft
Refer to [#minecraft](/en/game.html#minecraft)

View File

@ -212,6 +212,12 @@ pageClass: routes
<Route author="hoilc" example="/edge/addon/gangkeiaobmjcjokiofpkfpcobpbmnln" path="/edge/addon/:crxid" :paramsDesc="['扩展 id, 可在扩展页 URL 中找到']" />
## Microsoft Store
### Updates
<Route author="hellodword" example="/microsoft-store/updates/9WZDNCRFHVN5/CN" path="/microsoft-store/updates/:productid/:market?" :paramsDesc="['在 Store 中点击 `分享` - `复制链接` 即可获得', '默认为 `CN`']" />
## Minecraft
见 [#minecraft](/game.html#minecraft)

View File

@ -2853,6 +2853,9 @@ router.get('/xposed/module/:mod', require('./routes/xposed/module'));
// Microsoft Edge
router.get('/edge/addon/:crxid', require('./routes/edge/addon'));
// Microsoft Store
router.get('/microsoft-store/updates/:productid/:market?', require('./routes/microsoft-store/updates'));
// 上海立信会计金融学院
router.get('/slu/tzgg/:id', require('./routes/universities/slu/tzgg'));
router.get('/slu/jwc/:id', require('./routes/universities/slu/jwc'));

View File

@ -0,0 +1,32 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
const { market = 'CN', productid } = ctx.params;
const { data } = await got({
method: 'get',
url: `https://displaycatalog.mp.microsoft.com/v7.0/products/${productid}/?fieldsTemplate=&market=${market}&languages=en`,
headers: {
'Content-Type': 'application/json',
'MS-CV': `${Array(16)
.join()
.split(',')
.map(function () {
return 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'.charAt(Math.floor(Math.random() * 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'.length));
})
.join('')}.1`,
},
});
ctx.state.data = {
title: `${data.Product.LocalizedProperties[0].ProductTitle} - Microsoft Store Updates`,
link: `https://www.microsoft.com/store/productId/${productid}`,
item: [
{
title: data.Product.DisplaySkuAvailabilities[0].Sku.Properties.Packages[0].PackageFullName,
pubDate: new Date(data.Product.DisplaySkuAvailabilities[0].Sku.LastModifiedDate),
link: `https://www.microsoft.com/store/productId/${productid}`,
},
],
};
};