feat: add user about page

This commit is contained in:
YunYouJun
2023-07-30 20:13:20 +08:00
parent 44c9631e70
commit 2db9fee8af
20 changed files with 236 additions and 1191 deletions

View File

@@ -1,10 +1,19 @@
import type { Recipes } from '../types'
import type { RecipeItem, Recipes } from '../types'
/**
* 生成随机菜谱
* 生成随机菜谱,默认一道
* @param recipes
* @returns
*/
export function generateRandomRecipe(recipes: Recipes) {
return recipes[Math.floor(Math.random() * recipes.length)]
export function generateRandomRecipe(recipes: Recipes, total = 1) {
const randomRecipes: RecipeItem[] = []
for (let i = 0; i < total; i++) {
const randomIndex = Math.floor(Math.random() * recipes.length)
if (randomRecipes.includes(recipes[randomIndex])) {
i--
continue
}
randomRecipes.push(recipes[randomIndex])
}
return randomRecipes
}