feat: 优化md渲染组件性能表现
This commit is contained in:
1 parent
c1be93739d
commit
d20dc84d9d
4 files changed
+44
-31
No files matched your search
@@ -0,0 +1,28 @@
|
||||
const codemirrorMiddleware: middlewareType = {
|
||||
filter(tagName: string) {
|
||||
return tagName === 'code'
|
||||
},
|
||||
async render({
|
||||
item,
|
||||
tagAttrs,
|
||||
}) {
|
||||
const codeMirror = await cachedPromise('component:codeMirror', async () => {
|
||||
const codeMirror = (await import('~/components/codeMirror.vue')).default
|
||||
return codeMirror
|
||||
})
|
||||
const codeType = tagAttrs?.class?.slice(1, -1)?.split('-')?.[1] ?? ''
|
||||
// @ts-ignore
|
||||
const inline = (item.children[0].children.trim() as string).includes('\n') ? false : true
|
||||
return h(
|
||||
codeMirror,
|
||||
{
|
||||
// @ts-ignore
|
||||
data: item.children[0].children.trim(),
|
||||
type: codeType,
|
||||
inline,
|
||||
},
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
export default codemirrorMiddleware
|
||||
Reference in new issue
Block a user