Files
fitness-coach/miniprogram/utils/format.js
wm b3b58e66fb feat: init fitness-coach (backend + miniprogram)
- backend: NestJS service with exercise/plan data
- miniprogram: WeChat mini program client
- exclude node_modules, dist, runtime data-store, local env
2026-07-22 00:35:40 +08:00

28 lines
651 B
JavaScript

// 通用格式化辅助函数
function truncate(str, n) {
if (!str) return '';
return str.length > n ? str.slice(0, n) + '…' : str;
}
// 训练类型 -> 主题色(用于标签 / 角标)
function typeColor(type) {
const map = {
strength: '#D9B36C', // 力量 -> 金
cardio: '#58C9B9', // 有氧 -> 青
flexibility: '#9B8CFF' // 拉伸 -> 紫
};
return map[type] || '#D9B36C';
}
// 训练类型 -> 中文名
function typeLabel(type) {
const map = {
strength: '力量',
cardio: '有氧',
flexibility: '拉伸'
};
return map[type] || '动作';
}
module.exports = { truncate, typeColor, typeLabel };