Miao-Yunzai/image.tsx

31 lines
934 B
TypeScript
Raw Permalink 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 13:49:19 +08:00
import * as hello from './views/hello.tsx'
2024-06-18 10:49:28 +08:00
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
*/
2024-06-18 13:49:19 +08:00
async createHello(uid: number, Props: Parameters<typeof hello.default>[0]) {
const Hello = (await dynamic<typeof hello>('./views/hello.tsx')).default
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()