refactor: 合并多语言支持的显示名称字段,优化奖池手动爆发功能的返回数据结构,增强管理端权限控制
This commit is contained in:
@@ -23,6 +23,35 @@ function formatParts(date: Date, timeZone?: string): string {
|
||||
return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
|
||||
}
|
||||
|
||||
const WEEKDAY_KEYS = [
|
||||
"sunday",
|
||||
"monday",
|
||||
"tuesday",
|
||||
"wednesday",
|
||||
"thursday",
|
||||
"friday",
|
||||
"saturday",
|
||||
] as const;
|
||||
|
||||
export type AdminWeekdayKey = (typeof WEEKDAY_KEYS)[number];
|
||||
|
||||
export function adminWeekdayKeyForDate(date: Date = new Date()): AdminWeekdayKey {
|
||||
return WEEKDAY_KEYS[date.getDay()] ?? "sunday";
|
||||
}
|
||||
|
||||
/**
|
||||
* 仪表盘顶栏日期:数字日期 + i18n 星期(避免 Intl 在 ne 等语言下回退到系统中文)。
|
||||
*/
|
||||
export function formatAdminCalendarToday(locale: AdminApiLocale, weekdayLabel: string): string {
|
||||
const d = new Date();
|
||||
const y = d.getFullYear();
|
||||
const m = String(d.getMonth() + 1).padStart(2, "0");
|
||||
const day = String(d.getDate()).padStart(2, "0");
|
||||
const datePart = locale === "en" ? `${m}/${day}/${y}` : `${y}-${m}-${day}`;
|
||||
|
||||
return `${datePart} ${weekdayLabel}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将接口返回的 ISO 时间串格式化为浏览器本地时区下的 `YYYY-MM-DD HH:mm:ss`。
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user