- backend: NestJS service with exercise/plan data - miniprogram: WeChat mini program client - exclude node_modules, dist, runtime data-store, local env
28 lines
651 B
JavaScript
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 };
|