fix(route): 中国政府网没有正确拼接相对地址路径 && 替换滚动新闻地址 (#12622)
* Update index.js * fix(route): 中国政府网没有正确拼接相对地址路径 && 替换滚动新闻地址
This commit is contained in:
parent
051a3efcbb
commit
65c2909640
|
|
@ -4,24 +4,26 @@ const logger = require('@/utils/logger');
|
|||
|
||||
module.exports = async (ctx) => {
|
||||
const uid = ctx.params.uid;
|
||||
const originDomain = 'https://www.gov.cn';
|
||||
let url = '';
|
||||
let title = '';
|
||||
let list = '';
|
||||
switch (uid) {
|
||||
case 'bm':
|
||||
url = `http://www.gov.cn/lianbo/bumen/index.htm`;
|
||||
url = `${originDomain}/lianbo/bumen/index.htm`;
|
||||
title = '中国政府网 - 部门政务';
|
||||
break;
|
||||
case 'yw':
|
||||
url = `http://www.gov.cn/yaowen/index.htm`;
|
||||
url = `${originDomain}/yaowen/index.htm`;
|
||||
title = '中国政府网 - 新闻要闻';
|
||||
break;
|
||||
case 'gd':
|
||||
url = `http://www.gov.cn/xinwen/gundong.htm`;
|
||||
// 因 /xinwen/gundong.htm 被重定向到 /yaowen/index.htm, 所以这里直接用要闻的代替了
|
||||
url = `${originDomain}/yaowen/index.htm`;
|
||||
title = '中国政府网 - 滚动新闻';
|
||||
break;
|
||||
case 'gwy':
|
||||
url = 'http://www.gov.cn/pushinfo/v150203/';
|
||||
url = `${originDomain}/pushinfo/v150203/`;
|
||||
title = '中国政府网 - 国务院信息';
|
||||
break;
|
||||
case 'zhengce':
|
||||
|
|
@ -75,9 +77,9 @@ module.exports = async (ctx) => {
|
|||
} else {
|
||||
href = item.find('a').attr('href');
|
||||
if (href.startsWith('.')) {
|
||||
href = href.slice(1);
|
||||
href = new URL(href, url).pathname;
|
||||
}
|
||||
contentUrl = href.startsWith('/') ? `http://www.gov.cn${href}` : href;
|
||||
contentUrl = href.startsWith('/') ? `${originDomain}${href}` : href;
|
||||
if (!contentUrl.includes('content')) {
|
||||
description = item.find('a').text(); // 忽略获取吹风会的全文
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue