fix(route): fix swjtu/scai/bks route (#18832)

* fix(route): fix swjtu/scai/bks route)

* fix(route): fix swjtu/scai/bks route)

* fix(route): fix swjtu/scai/bks route)

* fix(route): fix swjtu/scai/bks route)

* fix(route): fix swjtu/scai/bks route)

* fix(route): fix swjtu/scai/bks route)

* fix(route): fix swjtu/scai/bks route)
This commit is contained in:
SuperJeason
2025-04-12 22:11:44 +08:00
committed by GitHub
parent a8b2d68228
commit edf603fbbe
+19 -4
View File
@@ -54,21 +54,36 @@ const partition = {
const getItem = (item, cache) => {
const title = item.find('a').text();
const link = `${rootURL}${item.find('a').attr('href').slice(2)}`;
// console.log(link);
return cache.tryGet(link, async () => {
const res = await ofetch(link);
const $ = load(res);
let pubDate: Date;
let dateText = $('div.news-info span:nth-of-type(2)').text();
// 转教务通知时的时间获取方法
if (!dateText) {
dateText = $('div.news-top-bar span:nth-of-type(1)').text();
}
// 'date' may be undefined. and 'parseDate' will return current time.
const date = dateText.match(/\d{4}(-|\/|.)\d{1,2}\1\d{1,2}/)?.[0];
const pubDate = parseDate(date);
// 转其他院的通知,获取不到具体时间,先从列表页获取具体信息
if (dateText) {
const dateMatch = dateText.match(/\d{4}(-|\/|.)\d{1,2}\1\d{1,2}/);
if (!dateMatch || !dateMatch[0]) {
return null;
}
pubDate = parseDate(dateMatch[0]);
} else {
const dateItem = item.find('.calendar'); // 注意 .calendar 是 class
const day = dateItem.find('.day').text().trim(); // "31" (文本需 trim 去空格)
const ymd = dateItem.find('.date').text().trim(); // "2025/03"
const [year, month] = ymd.split('/'); // ["2025", "03"]
const dateText = `${year}-${month}-${day.padStart(2, '0')}`;
pubDate = new Date(dateText);
}
const description = $('div.content-main').html();
// 确实无法获取时间就以当前时间为准
pubDate ||= new Date('2025-04-12'); // 使用当前时间作为默认值
return {
title,
pubDate,