From 23d56963e480b9cea9a6934f2f9b133db15fe848 Mon Sep 17 00:00:00 2001 From: mol Date: Thu, 14 Dec 2023 13:39:26 +0800 Subject: [PATCH] test --- plugins/cook/db/index.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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) +})