Finish store
This commit is contained in:
@@ -16,22 +16,32 @@ const View = () => {
|
||||
const [compiledCode, setCompiledCode] = useState('')
|
||||
|
||||
const render = (toolVo: ToolVo) => {
|
||||
try {
|
||||
const baseDist = base64ToStr(toolVo.base.dist.data!)
|
||||
const files = base64ToFiles(toolVo.source.data!)
|
||||
const importMap = JSON.parse(files[IMPORT_MAP_FILE_NAME].value) as IImportMap
|
||||
if (username === '!') {
|
||||
try {
|
||||
const baseDist = base64ToStr(toolVo.base.dist.data!)
|
||||
const files = base64ToFiles(toolVo.source.data!)
|
||||
const importMap = JSON.parse(files[IMPORT_MAP_FILE_NAME].value) as IImportMap
|
||||
|
||||
void compiler
|
||||
.compile(files, importMap, toolVo.entryPoint)
|
||||
.then((result) => {
|
||||
const output = result.outputFiles[0].text
|
||||
setCompiledCode(`${output}\n${baseDist}`)
|
||||
})
|
||||
.catch((reason) => {
|
||||
void message.error(`编译失败:${reason}`)
|
||||
})
|
||||
} catch (e) {
|
||||
void message.error('载入工具失败')
|
||||
void compiler
|
||||
.compile(files, importMap, toolVo.entryPoint)
|
||||
.then((result) => {
|
||||
const output = result.outputFiles[0].text
|
||||
setCompiledCode(`${output}\n${baseDist}`)
|
||||
})
|
||||
.catch((reason) => {
|
||||
void message.error(`编译失败:${reason}`)
|
||||
})
|
||||
} catch (e) {
|
||||
void message.error('载入工具失败')
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
const baseDist = base64ToStr(toolVo.base.dist.data!)
|
||||
const dist = base64ToStr(toolVo.dist.data!)
|
||||
setCompiledCode(`${dist}\n${baseDist}`)
|
||||
} catch (e) {
|
||||
void message.error('载入工具失败')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user