From a6941358ee382297f8f8a1a70f893c1edc794218 Mon Sep 17 00:00:00 2001 From: jieliu52 Date: Fri, 28 Feb 2025 14:23:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=89=A9=E6=96=99?= =?UTF-8?q?=E5=90=88=E6=88=90=E8=84=9A=E6=9C=AC=EF=BC=8C=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E7=BB=84=E4=BB=B6=E5=A4=9A=E4=B8=AAsnippets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/buildMaterials.mjs | 44 +++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/scripts/buildMaterials.mjs b/scripts/buildMaterials.mjs index 4f8a05b73b..0bc43ca64d 100644 --- a/scripts/buildMaterials.mjs +++ b/scripts/buildMaterials.mjs @@ -93,7 +93,24 @@ const generateComponents = () => { materials: { components: [], blocks: [], - snippets: [] + snippets: [], + packages: [ + { + name: 'TinyVue组件库', + package: '@opentiny/vue', + version: '3.20.0', + destructuring: true, + script: 'https://unpkg.com/@opentiny/vue-runtime@~3.20/dist3/tiny-vue-pc.mjs', + css: 'https://unpkg.com/@opentiny/vue-theme@~3.20/index.css' + }, + { + name: 'element-plus组件库', + package: 'element-plus', + version: '2.4.2', + script: 'https://unpkg.com/element-plus@2.4.2/dist/index.full.mjs', + css: 'https://unpkg.com/element-plus@2.4.2/dist/index.css' + } + ] } } } @@ -131,20 +148,23 @@ const generateComponents = () => { if (!valid) return - const { snippets: componentSnippets, category, ...componentInfo } = material + const { snippets: componentSnippets = [], category, ...componentInfo } = material components.push(componentInfo) - const snippet = snippets.find((item) => item.group === category) - - if (snippet) { - componentSnippets && snippet.children.push(componentSnippets[0]) - } else if (category && componentInfo) { - snippets.push({ - group: category, - children: componentSnippets || [] - }) - } + componentSnippets.forEach((c) => { + const componentCategory = c.category || category || '其他' + const snippet = snippets.find((item) => item.group === componentCategory) + + if (snippet) { + snippet.children.push(c) + } else { + snippets.push({ + group: componentCategory, + children: [c] + }) + } + }) const { component, npm = {} } = componentInfo