This commit is contained in:
93
plugins/cook/db/food.js
Normal file
93
plugins/cook/db/food.js
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
export const emojiMap = new Map([
|
||||||
|
[
|
||||||
|
'土豆', '🥔'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'胡萝卜', '🥕'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'花菜', '🥦'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'白萝卜', '🥣'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'西葫芦', '🥒'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'番茄', '🍅'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'西红柿', '🍅'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'芹菜', '🥬'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'黄瓜', '🥒'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'洋葱', '🧅'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'莴笋', '🎍'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'菌菇', '🍄'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'茄子', '🍆'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'豆腐', '🍲'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'包菜', '🥗'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'白菜', '🥬'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'午餐肉', '🥓'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'香肠', '🌭'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'腊肠', '🌭'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'鸡肉', '🐤'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'猪肉', '🐷'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'鸡蛋', '🥚'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'虾', '🦐'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'牛肉', '🐮'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'骨头', '🦴'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'鱼(Todo)', '🐟'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'面食', '🍝'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'面包', '🍞'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'米', '🍚'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'方便面', '🍜'
|
||||||
|
]
|
||||||
|
]
|
||||||
|
)
|
@ -1,5 +1,6 @@
|
|||||||
import pkg from 'node-csv';
|
import pkg from 'node-csv';
|
||||||
import logger from '#root/utils/logger.js';
|
import logger from '#root/utils/logger.js';
|
||||||
|
import { emojiMap } from './food.js'
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
const __dirname = path.dirname(new URL(import.meta.url).pathname);
|
const __dirname = path.dirname(new URL(import.meta.url).pathname);
|
||||||
|
|
||||||
@ -17,11 +18,19 @@ function parser() {
|
|||||||
}
|
}
|
||||||
logger('食谱加载成功');
|
logger('食谱加载成功');
|
||||||
const keys = data.shift()
|
const keys = data.shift()
|
||||||
|
keys[0] = keys[0].slice(1)
|
||||||
recipeData = data.map(d => {
|
recipeData = data.map(d => {
|
||||||
const res = {}
|
const res = {}
|
||||||
keys.forEach((key, index) => {
|
keys.forEach((key, index) => {
|
||||||
if (key) {
|
if (key) {
|
||||||
res[key] = d[index]
|
let text = d[index]
|
||||||
|
if (key === 'stuff') {
|
||||||
|
text = text.split('、').map(t => {
|
||||||
|
return `${emojiMap.has(t) ? emojiMap.get(t) + ' ' : ''}${t}`
|
||||||
|
}).join('、')
|
||||||
|
}
|
||||||
|
|
||||||
|
res[key] = text
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return res
|
return res
|
||||||
@ -42,5 +51,5 @@ export default async function getDb() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// getDb().then((res) => {
|
// getDb().then((res) => {
|
||||||
// console.log(recipeData)
|
// // console.log(recipeData)
|
||||||
// })
|
// })
|
||||||
|
@ -3,7 +3,7 @@ export function genRecipeMessage(recipeList, header, footer) {
|
|||||||
|
|
||||||
for (let recipe of recipeList) {
|
for (let recipe of recipeList) {
|
||||||
textList.push(
|
textList.push(
|
||||||
`吃${recipe['name']}\n准备材料:${recipe.stuff}\n使用厨具:${recipe.tools}\nhttps://www.bilibili.com/video/${recipe.bv}`,
|
`${recipe.name}\n材料:${recipe.stuff}\n厨具:${recipe.tools}\nhttps://www.bilibili.com/video/${recipe.bv}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,5 +15,5 @@ export function genRecipeMessage(recipeList, header, footer) {
|
|||||||
textList.push(footer);
|
textList.push(footer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return textList.join('\n----------\n');
|
return textList.join('\n \n');
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user