dsite/frontend/src/utils/constants.js
Ching b4fa5d9519 feat(recipe detail): 编辑详情时编辑框展示当前详情内容
编辑详情时编辑框展示当前详情内容

Signed-off-by: Ching <loooching@gmail.com>
2021-10-02 17:28:06 +08:00

39 lines
720 B
JavaScript

const type_map = {
vegetable: '青菜',
meat: '肉',
soup: '汤',
};
const rate_map = {
1: '🍚',
2: '🍚 🍚',
3: '🍚 🍚 🍚',
4: '🍚 🍚 🍚 🍚',
5: '🍚 🍚 🍚 🍚 🍚',
};
const difficulty_map = {
1: '⭐',
2: '⭐ ⭐',
3: '⭐ ⭐ ⭐',
4: '⭐ ⭐ ⭐ ⭐',
5: '⭐ ⭐ ⭐ ⭐ ⭐',
};
function formatRecipeType(recipe_type) {
return type_map[recipe_type];
}
function formatRate(rate) {
return rate_map[rate];
}
function formatDifficulty(difficulty) {
return difficulty_map[difficulty];
}
module.exports = {
RECIPE_TYPE_VEGETABLE: 'vegetable',
RECIPE_TYPE_META: 'meat',
RECIPE_TYPE_SOUP: 'soup',
formatRecipeType,
formatDifficulty,
formatRate,
}