元旦节皮肤
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
============================================================ */
|
||||
import { useMemo } from "react";
|
||||
|
||||
export type FestivalId = "christmas" | "halloween";
|
||||
export type FestivalId = "christmas" | "halloween" | "newyear";
|
||||
|
||||
/** Inclusive [month, day] windows. Christmas: Dec 20 – Dec 26; Halloween: Oct 26 – Nov 1. */
|
||||
const FESTIVAL_WINDOWS: Record<
|
||||
@@ -15,6 +15,8 @@ const FESTIVAL_WINDOWS: Record<
|
||||
> = {
|
||||
christmas: { from: [12, 20], to: [12, 26] },
|
||||
halloween: { from: [10, 26], to: [11, 1] },
|
||||
// 元旦接续圣诞节,跨年窗口包含首尾日期。
|
||||
newyear: { from: [12, 27], to: [1, 3] },
|
||||
};
|
||||
|
||||
function inWindow(
|
||||
@@ -55,8 +57,14 @@ export function useFestival(): FestivalId | null {
|
||||
return useMemo(() => getFestival(), []);
|
||||
}
|
||||
|
||||
/** 跨年夜展示即将到来的年份,其余月份预览展示当年。 */
|
||||
export function getNewYearDisplayYear(now: Date = new Date()): number {
|
||||
return now.getFullYear() + (now.getMonth() === 11 ? 1 : 0);
|
||||
}
|
||||
|
||||
/** 首页 VU 区的节日问候语,键与 FestivalId 对应。 */
|
||||
export const FESTIVAL_GREETINGS: Record<FestivalId, string> = {
|
||||
christmas: "Merry Christmas",
|
||||
halloween: "Happy Halloween",
|
||||
newyear: "Happy New Year",
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user