Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 32 additions & 12 deletions scripts/buildMaterials.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
]
Comment on lines +97 to +113
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里在 #1200 兼容了。(splitMaterials 的时候分离出来了 packages.json, buildMaterials 的时候读取 packages.json )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

收到

}
}
}
Expand Down Expand Up @@ -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

Expand Down