Miao-Yunzai/image.tsx

33 lines
1.1 KiB
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 { createDynamic } from 'yunzai/utils'
import { PropsType } from './views/hello.tsx'
const require = createDynamic(import.meta.url)
export class Image extends Picture {
2024-06-16 00:21:18 +08:00
constructor() {
2024-06-17 11:01:50 +08:00
super()
2024-06-16 00:21:18 +08:00
// start
this.Pup.start()
}
/**
* html html文件
* @param uid
* @param Props
* @returns
*/
2024-06-17 11:01:50 +08:00
async createHello(uid: number, Props: PropsType) {
// 此作用域可被重复执行,此处将变成动态组件 - 这是危险的!
const Hello = (await require('./views/hello.tsx')).default;
2024-06-16 00:21:18 +08:00
// 生成 html 地址 或 html字符串
2024-06-17 11:01:50 +08:00
const Address = this.Com.create(<Hello {...Props} />, {
2024-06-16 00:21:18 +08:00
// html/hello/uid.html
join_dir: 'hello',
html_name: `${uid}.html`,
})
2024-06-17 11:01:50 +08:00
return this.Pup.render(Address, {
2024-06-16 18:11:37 +08:00
tab: ''
})
2024-06-16 00:21:18 +08:00
}
}
// 初始化 图片生成对象
export const imgae = new Image()