feat: 同步新版

This commit is contained in:
ningmengchongshui 2024-06-18 10:49:28 +08:00
parent 5e0c0dc756
commit 2fd18f564b
2 changed files with 11 additions and 11 deletions

View File

@ -1,8 +1,9 @@
import React from 'react' import React from 'react'
import { Picture } from 'yunzai/utils' import { Picture } from 'yunzai/utils'
import { PropsType } from './views/hello.tsx' import { type PropsType } from './views/hello.tsx'
import { createDynamic } from 'yunzai/utils' import { createDynamicComponent } from 'yunzai/utils'
const require = createDynamic(import.meta.url) const dynamic = createDynamicComponent(import.meta.url)
export class Image extends Picture { export class Image extends Picture {
constructor() { constructor() {
super() super()
@ -16,10 +17,8 @@ export class Image extends Picture {
* @returns * @returns
*/ */
async createHello(uid: number, Props: PropsType) { async createHello(uid: number, Props: PropsType) {
// 非生产环境将触发 动态组件效果 // 非生产环境将触发动态组件效果
const Hello = ( const { default: Hello } = (await dynamic<'default', PropsType>('./views/hello.tsx'))
await require('./views/hello.tsx', process.env.NODE_ENV != 'production')
).default
// 生成 html 地址 或 html字符串 // 生成 html 地址 或 html字符串
const Address = this.Com.create(<Hello {...Props} />, { const Address = this.Com.create(<Hello {...Props} />, {
// html/hello/uid.html // html/hello/uid.html
@ -29,5 +28,6 @@ export class Image extends Picture {
return this.Pup.render(Address) return this.Pup.render(Address)
} }
} }
// 初始化 图片生成对象 // 初始化 图片生成对象
export const imgae = new Image() export const imgae = new Image()

View File

@ -1,9 +1,9 @@
import React from 'react' import React from 'react'
import { movies } from './data' import { movies } from './data'
import { createDynamic } from 'yunzai/utils' import { createDynamic } from 'yunzai/utils'
const require = createDynamic(import.meta.url) const dynamic = createDynamic(import.meta.url)
const Hello = (await require('./views/hello.tsx')).default const Hello = (await dynamic('./views/hello.tsx')).default
const Music = (await require('./views/music.tsx')).default const Music = (await dynamic('./views/music.tsx')).default
const Config = [ const Config = [
{ {
url: '/hello', url: '/hello',