diff --git a/plugins/cook/db/index.js b/plugins/cook/db/index.js index 156f1d0..d0d7ef1 100644 --- a/plugins/cook/db/index.js +++ b/plugins/cook/db/index.js @@ -16,7 +16,17 @@ function parser() { return j(); } logger('食谱加载成功'); - recipeData = data; + const keys = data.shift() + console.log(keys) + recipeData = data.map(d => { + const res = {} + keys.forEach((key, index) => { + if (key) { + res[key] = d[index] + } + }) + return res + }); loaded = true; r(recipeData); }); @@ -31,3 +41,7 @@ export default async function getDb() { return recipeData; } } + +getDb().then((res) => { + console.log(recipeData) +})