feat: 新增营养记录页面及相关组件
- 在应用中新增营养记录页面,展示用户的饮食记录 - 引入营养记录卡片组件,优化记录展示效果 - 更新路由常量,添加营养记录相关路径 - 修改布局文件,整合营养记录功能 - 优化数据加载逻辑,支持分页和日期过滤
This commit is contained in:
@@ -29,10 +29,14 @@ export function getMonthTitleZh(date: Dayjs = dayjs()): string {
|
||||
export type MonthDay = {
|
||||
/** 中文星期:日/一/二/三/四/五/六 */
|
||||
weekdayZh: string;
|
||||
/** 简化的星期,用于显示 */
|
||||
dayAbbr: string;
|
||||
/** 月内第几日(1-31) */
|
||||
dayOfMonth: number;
|
||||
/** 对应的 dayjs 对象 */
|
||||
date: Dayjs;
|
||||
/** 是否是今天 */
|
||||
isToday: boolean;
|
||||
};
|
||||
|
||||
/** 获取某月的所有日期(中文星期+日号) */
|
||||
@@ -41,12 +45,18 @@ export function getMonthDaysZh(date: Dayjs = dayjs()): MonthDay[] {
|
||||
const monthIndex = date.month();
|
||||
const daysInMonth = date.daysInMonth();
|
||||
const zhWeek = ['日', '一', '二', '三', '四', '五', '六'];
|
||||
const today = dayjs();
|
||||
|
||||
return Array.from({ length: daysInMonth }, (_, i) => {
|
||||
const d = dayjs(new Date(year, monthIndex, i + 1));
|
||||
const isToday = d.isSame(today, 'day');
|
||||
|
||||
return {
|
||||
weekdayZh: zhWeek[d.day()],
|
||||
dayAbbr: zhWeek[d.day()],
|
||||
dayOfMonth: i + 1,
|
||||
date: d,
|
||||
isToday,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user