-
Notifications
You must be signed in to change notification settings - Fork 376
fix: Block Preview Error #1343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Block Preview Error #1343
Conversation
WalkthroughThis update introduces defensive programming improvements to two functions in separate modules. In the canvas rendering module, the Changes
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
import { defineComponent, computed, defineAsyncComponent } from 'vue' | ||
import { Repl, ReplStore } from '@vue/repl' | ||
import { getMergeMeta } from '@opentiny/tiny-engine-meta-register' | ||
import vueJsx from '@vue/babel-plugin-jsx' | ||
import { transformSync } from '@babel/core' | ||
import { getMetaApi } from '@opentiny/tiny-engine-meta-register' | ||
import { getImportMap as getInitImportMap } from './importMap' | ||
import srcFiles from './srcFiles' | ||
import generateMetaFiles, { processAppJsCode } from './generate' | ||
import { getSearchParams, fetchMetaData, fetchImportMap, fetchAppSchema, fetchBlockSchema } from './http' | ||
import { PanelType, PreviewTips } from '../constant' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
冲突可能解决的有点问题:
在 #1261 中,我这边合入了 preview 的新特性,将处理预览出码相关的放置到了:
tiny-engine/packages/design-core/src/preview/src/preview/usePreviewData.ts
Lines 329 to 383 in b87d90c
const updatePreview = async (params: { currentPage: IPage; ancestors: IPage[] }) => { | |
const { appData, metaData, importMapData } = await getBasicData(basicFiles) | |
previewState.currentPage = params.currentPage | |
previewState.ancestors = params.ancestors | |
// importMap 发生变化才更新 importMap | |
if (JSON.stringify(previewState.importMap) !== JSON.stringify(importMapData)) { | |
store.setImportMap(importMapData) | |
previewState.importMap = importMapData | |
} | |
const blockSet = new Set() | |
let blocks = [] | |
const { getAllNestedBlocksSchema, generatePageCode } = getMetaApi('engine.service.generateCode') | |
if (params.ancestors?.length) { | |
const promises = params.ancestors.map((item) => | |
getAllNestedBlocksSchema(item.page_content, fetchBlockSchema, blockSet) | |
) | |
blocks = (await Promise.all(promises)).flat() | |
} | |
const currentPageBlocks = await getAllNestedBlocksSchema( | |
params.currentPage?.page_content || {}, | |
fetchBlockSchema, | |
blockSet | |
) | |
blocks = blocks.concat(currentPageBlocks) | |
const pageCode = [ | |
...getPageAncestryFiles(appData, params), | |
...(blocks || []).map((blockSchema) => { | |
return { | |
panelName: `${blockSchema.fileName}.vue`, | |
panelValue: generatePageCode(blockSchema, appData?.componentsMap || [], { blockRelativePath: './' }) || '', | |
panelType: 'vue' | |
} | |
}) | |
] | |
const newFiles = store.getFiles() | |
const searchParams = new URLSearchParams(location.search) | |
const appJsCode = processAppJsCode(newFiles['app.js'], JSON.parse(searchParams.get('styles') || '[]')) | |
newFiles['app.js'] = appJsCode | |
pageCode.map(fixScriptLang).forEach((item) => assignFiles(item, newFiles)) | |
const metaFiles = generateMetaFiles(metaData) | |
Object.assign(newFiles, metaFiles) | |
setFiles(newFiles) | |
} |
可以验证下有没有解决预览侧的问题
(可能重新拉个分支更快,你变更的代码不会很多)
English | 简体中文
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Background and solution
What is the current behavior?
Issue Number: #1342
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit