Skip to content

Commit

Permalink
fix: key with /
Browse files Browse the repository at this point in the history
close #26
  • Loading branch information
imcuttle committed Jan 25, 2022
1 parent c916158 commit 6396401
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
26 changes: 26 additions & 0 deletions packages/editor/example/mometa-material.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,31 @@ module.exports = require('../../app/mometa-material.config').concat([
{
name: 'HHHPAC',
key: 'component'
},
{
name: 'Local Mat',
key: 'local-mat',
assetGroups: [
{
name: '通用',
key: 'gen',
assets: [
{
name: '按钮',
key: 'Button',
cover: 'https://gw.alipayobjects.com/zos/alicdn/fNUKzY1sk/Button.svg',
data: {
code: '<Button type="default">按钮</Button>',
dependencies: {
Button: {
source: '@/materials/button',
mode: 'default'
}
}
}
}
]
}
]
}
])
9 changes: 9 additions & 0 deletions packages/editor/example/src/materials/button/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react'
import './style.css'

console.log('materials Button')

export default function Button() {
console.log('materials Button render1')
return <div className={'no'}>123</div>
}
3 changes: 3 additions & 0 deletions packages/editor/example/src/materials/button/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.no {
color: red !important;
}
1 change: 1 addition & 0 deletions packages/editor/example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"jsx": "react-jsx",
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"],
"@mometa/fs-handler": ["../../fs-handler/src"],
"@mometa/fs-handler/*": ["../../fs-handler/src/*"],
"@mometa/editor": ["../src"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ module.exports = async function writeRuntimePreviewRender({ materialsConfig, con
const keys = parents.map((x, i) => x.key || x.name || path[i])
const root = nps.join(paths.runtimePreviewRender, filenamify(configFilename, { replacement: '~' }))
await fsExtra.ensureDir(root)
const filename = nps.join(root, `preview-render-${keys.join('_')}_${sha1(asset).slice(0, 8)}.js`)
const filename = nps.join(
root,
filenamify(`preview-render-${keys.join('_')}_${sha1(asset).slice(0, 8)}.js`, { replacement: '~' })
)

if (fs.existsSync(filename) && fs.statSync(filename).isFile()) {
const content = await fs.promises.readFile(filename, 'utf8')
Expand Down

0 comments on commit 6396401

Please sign in to comment.