2022-06-08 20:10:25 +08:00
|
|
|
import 'iframe-resizer/js/iframeResizer.contentWindow'
|
|
|
|
import './style.scss'
|
|
|
|
|
2021-08-25 17:52:20 +08:00
|
|
|
import React from 'react'
|
2022-04-11 16:16:04 +08:00
|
|
|
import { createRoot } from 'react-dom/client'
|
2022-06-08 20:10:25 +08:00
|
|
|
|
2023-07-01 03:03:49 +08:00
|
|
|
import { debug, splitName } from './helper.js'
|
2021-08-25 17:52:20 +08:00
|
|
|
|
|
|
|
export default function init(name: string, source: any) {
|
|
|
|
// @ts-ignore
|
|
|
|
window.source = source
|
|
|
|
document.title = name
|
|
|
|
|
|
|
|
const [demoCategory, demoName] = splitName(name)
|
|
|
|
|
|
|
|
import(`../src/${demoCategory}/${demoName}/React/index.jsx`)
|
|
|
|
.then(module => {
|
2022-04-11 16:16:04 +08:00
|
|
|
const root = document.getElementById('app')
|
|
|
|
|
|
|
|
if (root) {
|
|
|
|
createRoot(root).render(React.createElement(module.default))
|
|
|
|
}
|
2021-08-25 17:52:20 +08:00
|
|
|
debug()
|
|
|
|
})
|
|
|
|
}
|