feat: 器械分类网格化 + 分类页标题防乱码 + 按器械/部位多维度筛选
- 首页『热门器械』由横滑 chips 改为与『按部位浏览』一致的网格 - 分类页 navbar 标题改由本地分类枚举回写,避免外部传入标题乱码 - 分类页新增二级维度多选筛选:器械维度交叉按部位,其余维度交叉按器械 - 后端 exercises.service 支持 equipment/bodyPart 逗号分隔多值 OR 过滤(向后兼容)
This commit is contained in:
@@ -46,8 +46,15 @@ export class ExercisesService implements OnModuleInit {
|
||||
findAll(query: QueryExercisesDto) {
|
||||
let list = this.exercises;
|
||||
|
||||
if (query.bodyPart) list = list.filter((e) => e.bodyPart === query.bodyPart);
|
||||
if (query.equipment) list = list.filter((e) => e.equipment === query.equipment);
|
||||
// 支持逗号分隔多值(OR 关系),向后兼容单值
|
||||
if (query.bodyPart) {
|
||||
const arr = String(query.bodyPart).split(',').map((s) => s.trim()).filter(Boolean);
|
||||
if (arr.length) list = list.filter((e) => arr.includes(e.bodyPart));
|
||||
}
|
||||
if (query.equipment) {
|
||||
const arr = String(query.equipment).split(',').map((s) => s.trim()).filter(Boolean);
|
||||
if (arr.length) list = list.filter((e) => arr.includes(e.equipment));
|
||||
}
|
||||
if (query.type) list = list.filter((e) => e.type === query.type);
|
||||
if (query.target) list = list.filter((e) => e.target === query.target);
|
||||
if (query.muscleGroup)
|
||||
|
||||
Reference in New Issue
Block a user