fix: work around icon import for demo playground

This commit is contained in:
Justineo 2021-09-16 18:49:13 +08:00
parent cafc41321d
commit 8099c9efcf
No known key found for this signature in database
GPG Key ID: B73F0979CF18A0EA
2 changed files with 11 additions and 4 deletions

View File

@ -36,7 +36,9 @@
ui="icon"
@click="localExpanded = !localExpanded"
>
<veui-icon :name="localExpanded ? 'one-demo-code-off' : 'one-demo-code'"/>
<veui-icon
:name="localExpanded ? 'one-demo-code-off' : 'one-demo-code'"
/>
</veui-button>
</section>
<section
@ -96,11 +98,16 @@ export default {
},
methods: {
play () {
createCodeSandbox(this.$refs.source.textContent.replace(/from 'veui'/g, 'from \'veui/dist/veui.esm\''))
createCodeSandbox(preprocess(this.$refs.source.textContent))
}
}
}
function preprocess (code) {
return code.replace(/from 'veui'/g, `from 'veui/dist/veui.esm'`)
.replace(/(?:import 'veui-theme-dls-icons[^']+'\n)+/g, `import 'veui-theme-dls-icons/dist/icons.esm'\n`)
}
Icon.register({
'one-demo-code': {
width: 24,

View File

@ -28,8 +28,8 @@ export function createCodeSandbox (sfc) {
const meta = `{
"dependencies": {
"veui": "2.1.1",
"veui-theme-dls": "2.1.1",
"veui": "2.1.2",
"veui-theme-dls": "2.1.2",
"vue": "2.6.14"
}
}