feat: v1.2.0
Some checks failed
continuous-integration/drone Build is failing

This commit is contained in:
mol
2023-12-13 18:54:37 +08:00
parent d03ffb0cfc
commit 901f127b8a
20 changed files with 824 additions and 63 deletions

18
plugins/cook/api/index.js Normal file
View File

@ -0,0 +1,18 @@
import getDb from '../db/index.js';
export async function getRandomRecipe(limit = 5) {
const data = await getDb();
const len = data.length;
const list = [];
const indexList = new Set();
while (indexList.size === limit) {
const index = Math.floor(Math.random() * len);
if (!indexList.has(index)) {
indexList.set(index);
list.push(data[index]);
}
}
return list;
}