mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00
🎈 pref: 内容评估器优化
This commit is contained in:
parent
1c409cb369
commit
dfb893b31d
@ -4,38 +4,23 @@
|
|||||||
* @param link 链接
|
* @param link 链接
|
||||||
*/
|
*/
|
||||||
export function contentEstimator(link) {
|
export function contentEstimator(link) {
|
||||||
const wxReg = /(?:https?:\/\/)?mp\.weixin\.qq\.com\/[A-Za-z\d._?%&+\-=\/#]*/;
|
const patterns = [
|
||||||
const arxivReg = /(?:https?:\/\/)?arxiv.org\/[a-zA-Z\d._?%&+\-=\/#]*/;
|
{ reg: /(?:https?:\/\/)?mp\.weixin\.qq\.com\/[A-Za-z\d._?%&+\-=\/#]*/, name: '微信文章' },
|
||||||
const chinaDailyReg = /(?:https?:\/\/)?(www\.)chinadaily.com.cn\/a\/[a-zA-Z0-9\d._?%&+\-=\/#]*/;
|
{ reg: /(?:https?:\/\/)?arxiv.org\/[a-zA-Z\d._?%&+\-=\/#]*/, name: 'ArXiv论文' },
|
||||||
const sspaiReg = /(?:https?:\/\/)?sspai.com\/[a-zA-Z\d._?%&+\-=\/#]*/;
|
{ reg: /(?:https?:\/\/)?sspai.com\/[a-zA-Z\d._?%&+\-=\/#]*/, name: '少数派' },
|
||||||
const biliReadReg = /(?:https?:\/\/)?www\.bilibili\.com\/read\/[A-Za-z\d._?%&+\-=\/#]*/;
|
{ reg: /(?:https?:\/\/)?www\.bilibili\.com\/read\/[A-Za-z\d._?%&+\-=\/#]*/, name: '哔哩哔哩专栏' },
|
||||||
if (wxReg.test(link)) {
|
{ reg: /(?:https?:\/\/)?(www\.)chinadaily.com.cn\/a\/[a-zA-Z0-9\d._?%&+\-=\/#]*/, name: 'ChinaDaily' }
|
||||||
return {
|
];
|
||||||
name: '微信文章',
|
|
||||||
summaryLink: wxReg.exec(link)?.[0]
|
for (const pattern of patterns) {
|
||||||
};
|
if (pattern.reg.test(link)) {
|
||||||
} else if (arxivReg.test(link)) {
|
return {
|
||||||
return {
|
name: pattern.name,
|
||||||
name: 'ArXiv论文',
|
summaryLink: pattern.reg.exec(link)?.[0]
|
||||||
summaryLink: arxivReg.exec(link)?.[0]
|
};
|
||||||
};
|
|
||||||
} else if (sspaiReg.test(link)) {
|
|
||||||
return {
|
|
||||||
name: '少数派',
|
|
||||||
summaryLink: sspaiReg.exec(link)?.[0]
|
|
||||||
}
|
}
|
||||||
} else if (biliReadReg.test(link)) {
|
|
||||||
return {
|
|
||||||
name: '哔哩哔哩专栏',
|
|
||||||
summaryLink: biliReadReg.exec(link)?.[0]
|
|
||||||
}
|
|
||||||
} else if (chinaDailyReg.test(link)) {
|
|
||||||
return {
|
|
||||||
name: 'ChinaDaily',
|
|
||||||
summaryLink: chinaDailyReg.exec(link)?.[0]
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
logger.error("[R插件][总结模块] 内容评估出错...");
|
|
||||||
throw Error("内容评估出错...");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.error("[R插件][总结模块] 内容评估出错...");
|
||||||
|
throw Error("内容评估出错...");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user