Miao-Yunzai/image.tsx

34 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'
import { PropsType } from './views/hello.tsx'
2024-06-17 22:52:15 +08:00
import { createDynamic } from 'yunzai/utils'
2024-06-17 11:01:50 +08:00
const require = createDynamic(import.meta.url)
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) {
// 非生产环境将触发 动态组件效果
const Hello = (
await require('./views/hello.tsx', process.env.NODE_ENV != 'production')
).default
// 生成 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-17 22:52:15 +08:00
export const imgae = new Image()