feat: add user about page
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user