in initializer-page/src/components/common/explore/Explore.js [34:118]
throw Error(`Could not read the ZIP project.`)
})
setSelected(result.selected)
setTree(result.tree)
} catch (e) {
dispatch({ type: 'EXPLORE_UPDATE', payload: { open: false } })
toast.error(e.message)
}
}
if (explore && blob) {
load()
}
}, [explore, blob, dispatch])
const onCopy = () => {
setButton('Copied!')
setTimeout(() => {
setButton('Copy!')
}, 3000)
}
const download = file => {
const blobFile = new Blob([file.content], {
type: 'text/plain;charset=utf-8',
})
FileSaver.saveAs(blobFile, file.filename)
}
const downloadZip = () => {
FileSaver.saveAs(blob, projectName)
}
return (
<div>
<Modal
open={open}
onClose={() => {
setSelected(null)
onClose()
}}
showCloseIcon={false}
classNames={{ modal: 'modal-explorer', overlay: 'overlay' }}
>
{tree && selected ? (
<div className='colset-explorer'>
<div className='left'>
<div className='head'>
<strong>{projectName}</strong>
</div>
<div className='explorer-content'>
<Tree
selected={selected}
onClickItem={item => {
setSelected(item)
// onSelected(item)
}}
tree={tree}
/>
</div>
<div className='foot'>
<a
href='/#'
onClick={e => {
e.preventDefault()
downloadZip()
}}
className='action'
>
下载源码包
</a>
</div>
</div>
<div className='right'>
{selected && (
<>
<div className='head'>
<strong>
<IconFile />
{get(selected, 'filename')}
</strong>
<div className='actions'>
<span className='divider'>|</span>
<a
href='/#'
onClick={e => {