fix(home): 首页排版细节优化
- 宜忌弹窗字体 44→32rpx、收紧间距,20+ 条可完整显示 - 历史上的今天内页年份加粗、文字稍小,修正层级 - 节日速查外页3条/内页10条,佛历开启时并入排序 - 统一「更多」箭头为 >>
This commit is contained in:
@@ -1228,8 +1228,9 @@ function daysBetween(fromY, fromM, fromD, toY, toM, toD) {
|
||||
|
||||
/** 获取即将到来的 N 个节日(含基准日之后的)
|
||||
* baseYear/baseMonth/baseDay 可选,默认今天
|
||||
* includeBuddhist 为 true 时,把佛教节日也并入一起按倒计时排序
|
||||
*/
|
||||
function getUpcomingFestivals(count = 6, baseYear, baseMonth, baseDay) {
|
||||
function getUpcomingFestivals(count = 6, baseYear, baseMonth, baseDay, includeBuddhist = false) {
|
||||
const now = new Date();
|
||||
const y = baseYear || now.getFullYear();
|
||||
const m = baseMonth || (now.getMonth() + 1);
|
||||
@@ -1245,6 +1246,7 @@ function getUpcomingFestivals(count = 6, baseYear, baseMonth, baseDay) {
|
||||
if (diff >= 0) {
|
||||
list.push({
|
||||
name: fest.name,
|
||||
type: fest.type,
|
||||
solarDate: `${solar.year}-${String(solar.month).padStart(2, '0')}-${String(solar.day).padStart(2, '0')}`,
|
||||
solarYear: solar.year,
|
||||
solarMonth: solar.month,
|
||||
@@ -1256,6 +1258,30 @@ function getUpcomingFestivals(count = 6, baseYear, baseMonth, baseDay) {
|
||||
}
|
||||
}
|
||||
|
||||
// 佛历节日(开启后并入,统一按倒计时排序)
|
||||
if (includeBuddhist) {
|
||||
for (const [key, name] of Object.entries(BUDDHIST_FESTIVALS)) {
|
||||
const [lm, ld] = key.split('-').map(Number);
|
||||
for (const tryYear of [y, y + 1]) {
|
||||
const solar = lunarFestivalToSolar(tryYear, lm, ld);
|
||||
if (!solar) continue;
|
||||
const diff = daysBetween(y, m, d, solar.year, solar.month, solar.day);
|
||||
if (diff >= 0) {
|
||||
list.push({
|
||||
name,
|
||||
type: 'buddhist',
|
||||
solarDate: `${solar.year}-${String(solar.month).padStart(2, '0')}-${String(solar.day).padStart(2, '0')}`,
|
||||
solarYear: solar.year,
|
||||
solarMonth: solar.month,
|
||||
solarDay: solar.day,
|
||||
daysLeft: diff
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
list.sort((a, b) => a.daysLeft - b.daysLeft);
|
||||
return list.slice(0, count);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user