Miao-Yunzai/image.tsx

33 lines
980 B
TypeScript
Raw Normal View History

2024-06-16 00:21:18 +08:00
import React from 'react'
2024-06-17 11:01:50 +08:00
import { Picture } from 'yunzai/utils'
2024-06-18 10:49:28 +08:00
import { type PropsType } from './views/hello.tsx'
import { createDynamicComponent } from 'yunzai/utils'
const dynamic = createDynamicComponent(import.meta.url)
2024-06-17 11:01:50 +08:00
export class Image extends Picture {
2024-06-17 22:52:15 +08:00
constructor() {
super()
// start
this.Pup.start()
}
/**
* html html文件
* @param uid
* @param Props
* @returns
*/
async createHello(uid: number, Props: PropsType) {
2024-06-18 10:49:28 +08:00
// 非生产环境将触发动态组件效果
const { default: Hello } = (await dynamic<'default', PropsType>('./views/hello.tsx'))
2024-06-17 22:52:15 +08:00
// 生成 html 地址 或 html字符串
const Address = this.Com.create(<Hello {...Props} />, {
// html/hello/uid.html
join_dir: 'hello',
html_name: `${uid}.html`
})
return this.Pup.render(Address)
}
2024-06-16 00:21:18 +08:00
}
2024-06-18 10:49:28 +08:00
2024-06-16 00:21:18 +08:00
// 初始化 图片生成对象
2024-06-18 10:49:28 +08:00
export const imgae = new Image()