feat(route): add bphc 北京共有产权住房租赁平台 (#10955)
* bphc * radar ok * change maintainer * fix null checking err * rss link should be rootUrl * fix: sort routes
This commit is contained in:
parent
25ede3fb80
commit
b523c4dc31
|
|
@ -44,6 +44,18 @@ pageClass: routes
|
|||
|
||||
<Route author="Fatpandac" example="/ssm/news" path="/ssm/news"/>
|
||||
|
||||
## 北京市保障房中心有限公司
|
||||
|
||||
### 北京市共有产权住房租赁服务平台
|
||||
|
||||
<Route author="bigfei" example="/gov/beijing/bphc/announcement" path="/gov/beijing/bphc/:caty" :paramsDesc="['类别']">
|
||||
|
||||
| 通知公告 | 项目介绍 |
|
||||
| :----------: | :-----: |
|
||||
| announcement | project |
|
||||
|
||||
</Route>
|
||||
|
||||
## 北京市教育委员会
|
||||
|
||||
### 通知公告
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
const mapping = {
|
||||
'/project': {
|
||||
title: '项目介绍',
|
||||
list: '/front/index/project/page',
|
||||
detail: '/front/index/project',
|
||||
link: '/#/communityDetail?id=',
|
||||
},
|
||||
'/announcement': {
|
||||
title: '通知公告',
|
||||
list: '/front/announcement/page',
|
||||
detail: '/front/announcement/',
|
||||
link: '/#/announcementList/detail?id=',
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'http://gycp.bphc.com.cn:21000';
|
||||
const defaultPath = 'announcement';
|
||||
|
||||
const pathname = ctx.path.replace(/(^\/beijing\/bphc|\/$)/g, '');
|
||||
const key = pathname === '' ? defaultPath : pathname.endsWith('/') ? pathname.slice(0, -1) : pathname;
|
||||
const obj = mapping[key];
|
||||
const currentUrl = `${rootUrl}${obj.list}`;
|
||||
|
||||
const listResp = await got(currentUrl).json();
|
||||
const list = listResp.data?.records ?? [];
|
||||
const items = await Promise.all(
|
||||
list.map((item) => {
|
||||
const detail = `${rootUrl}${obj.detail}/${item.id}`;
|
||||
return ctx.cache.tryGet(detail, async () => {
|
||||
const detailResponse = await got(detail).json();
|
||||
const description = (detailResponse.data?.content || detailResponse.data?.introduction) ?? '';
|
||||
const single = {
|
||||
title: item.title || item.fullName,
|
||||
author: description.match(/来源:(.*?)</)?.[1].trim() ?? item.operator,
|
||||
link: `${rootUrl}${obj.link}${item.id}`,
|
||||
description,
|
||||
pubDate: timezone(parseDate(item.createTime), +8),
|
||||
};
|
||||
return single;
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: obj.title,
|
||||
link: rootUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -37,6 +37,7 @@ module.exports = {
|
|||
'/stats/:path+': ['bigfei'],
|
||||
// province
|
||||
'/anhui/kjt/:path?': ['nczitzk'],
|
||||
'/beijing/bphc/:channel': ['bigfei'],
|
||||
'/beijing/jw/tzgg': ['nczitzk'],
|
||||
'/beijing/kw/:channel': ['Fatpandac'],
|
||||
'/guangdong/tqyb/tfxtq': ['Fatpandac'],
|
||||
|
|
|
|||
|
|
@ -297,6 +297,17 @@ module.exports = {
|
|||
},
|
||||
],
|
||||
},
|
||||
'bphc.com.cn': {
|
||||
_name: '北京保障房中心有限公司',
|
||||
gycpt: [
|
||||
{
|
||||
title: '北京市共有产权住房租赁服务平台',
|
||||
docs: 'https://docs.rsshub.app/government.html#bei-jing-shi-bao-zhang-fang-zhong-xin-you-xian-gong-si',
|
||||
source: ['/*'],
|
||||
target: (params, url) => `/gov/bphc/${new URL(url).href.match(/gycpt\.bphc\.com\.cn\/(.*)/)[1]}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
'ccdi.gov.cn': {
|
||||
_name: '中央纪委国家监委',
|
||||
www: [
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ module.exports = function (router) {
|
|||
router.get(/stats(\/[\w/-]+)?/, require('./stats'));
|
||||
// province
|
||||
router.get(/anhui\/kjt\/([\w\d/-]+)?/, require('./anhui/kjt'));
|
||||
router.get(/beijing\/bphc(\/[\w/-]+)?/, require('./beijing/bphc'));
|
||||
router.get('/beijing/jw/tzgg', require('./beijing/jw/tzgg'));
|
||||
router.get('/beijing/kw/:channel', require('./beijing/kw/index'));
|
||||
router.get('/guangdong/tqyb/tfxtq', require('./guangdong/tqyb/tfxtq'));
|
||||
|
|
|
|||
Loading…
Reference in New Issue