This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import pkg from 'node-csv';
|
||||
import logger from '#root/utils/logger.js';
|
||||
import { emojiMap } from './food.js'
|
||||
import path from 'path';
|
||||
const __dirname = path.dirname(new URL(import.meta.url).pathname);
|
||||
|
||||
@ -17,11 +18,19 @@ function parser() {
|
||||
}
|
||||
logger('食谱加载成功');
|
||||
const keys = data.shift()
|
||||
keys[0] = keys[0].slice(1)
|
||||
recipeData = data.map(d => {
|
||||
const res = {}
|
||||
keys.forEach((key, index) => {
|
||||
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
|
||||
@ -42,5 +51,5 @@ export default async function getDb() {
|
||||
}
|
||||
|
||||
// getDb().then((res) => {
|
||||
// console.log(recipeData)
|
||||
// // console.log(recipeData)
|
||||
// })
|
||||
|
Reference in New Issue
Block a user