Skip to content

Commit

Permalink
fix: material config compact data and url
Browse files Browse the repository at this point in the history
  • Loading branch information
chilingling committed Feb 7, 2025
1 parent 5e6d8dd commit 7c7bc09
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
4 changes: 3 additions & 1 deletion designer-demo/engine.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import material from '@opentiny/tiny-engine-materials'

export default {
id: 'engine.config',
theme: import.meta.env.VITE_THEME || 'light',
material: ['/mock/bundle.json'],
material: [material],
scripts: [],
styles: []
}
1 change: 1 addition & 0 deletions designer-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"dependencies": {
"@opentiny/tiny-engine": "workspace:^",
"@opentiny/tiny-engine-materials": "workspace:*",
"@opentiny/tiny-engine-theme-dark": "workspace:*",
"@opentiny/tiny-engine-theme-light": "workspace:*",
"@opentiny/tiny-engine-utils": "workspace:*",
Expand Down
6 changes: 2 additions & 4 deletions packages/materials/buildMaterials.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,8 @@ const generateComponents = async (entry) => {

const getFrameworkWithData = (data) => {
return {
data: {
framework: 'Vue',
materials: data
}
framework: 'Vue',
materials: data
}
}

Expand Down
14 changes: 13 additions & 1 deletion packages/plugins/materials/src/composable/useMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,19 @@ const setMaterial = (name, data) => {
*/
export const getMaterialsRes = async () => {
const bundleUrls = getMergeMeta('engine.config')?.material || []
const materials = await Promise.allSettled(bundleUrls.map((url) => getMetaApi(META_SERVICE.Http).get(url)))
const materials = await Promise.allSettled(
bundleUrls.map((bundleItem) => {
// bundle 是一个 url
if (typeof bundleItem === 'string') {
return getMetaApi(META_SERVICE.Http).get(bundleItem)
}
// 直接传入 bundle
if (bundleItem?.materials) {
return bundleItem
}
})
)

return materials
}

Expand Down

0 comments on commit 7c7bc09

Please sign in to comment.