Skip to content

Commit b81baf5

Browse files
authored
Fix the error reporting issue of the block on the parent page. (#1289)
* Fix the error reporting issue of the block on the parent page.
1 parent 894eaca commit b81baf5

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

  • packages/design-core/src/preview/src/preview

packages/design-core/src/preview/src/preview/Preview.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,24 @@ export default {
132132
return familyPages
133133
}
134134
135+
const genAllBlocks = async (ancestors) => {
136+
// blockSet 是为了防止重复出码同样的区块,同名区块只出码一遍
137+
const blockSet = new Set()
138+
const promises = ancestors.map((item) => getAllNestedBlocksSchema(item.page_content, fetchBlockSchema, blockSet))
139+
const blocks = (await Promise.all(promises)).flat()
140+
return blocks
141+
}
142+
135143
const promiseList = [
136144
fetchAppSchema(queryParams?.app),
137145
fetchMetaData(queryParams),
146+
genAllBlocks(queryParams.ancestors),
138147
setFiles(srcFiles, 'src/Main.vue'),
139148
getImportMap()
140149
]
141-
Promise.all(promiseList).then(async ([appData, metaData, _void, importMapData]) => {
150+
Promise.all(promiseList).then(async ([appData, metaData, blocks, _void, importMapData]) => {
142151
store.setImportMap(importMapData)
143152
144-
const blocks = await getAllNestedBlocksSchema(queryParams.pageInfo?.schema, fetchBlockSchema)
145-
146153
// TODO: 需要验证级联生成 block schema
147154
// TODO: 物料内置 block 需要如何处理?
148155
const pageCode = [

0 commit comments

Comments
 (0)