Miao-Yunzai/image.tsx

41 lines
1.1 KiB
TypeScript
Raw Normal View History

2024-06-16 00:21:18 +08:00
import React from 'react'
import { Component, Puppeteer } from 'yunzai/utils'
import Hello, { PropsType } from './views/hello.tsx'
// 初始化 组件渲染对象
const Com = new Component()
export class Image {
Pup: typeof Puppeteer.prototype = null
/**
* Puppeteer
*/
constructor() {
// init
this.Pup = new Puppeteer()
// start
this.Pup.start()
this.Pup.setLaunch({
defaultViewport: {
width: 1280,
height: 800
}
})
}
/**
* html html文件
* @param uid
* @param Props
* @returns
*/
createHello(uid: number, Props: PropsType) {
// 生成 html 地址 或 html字符串
const Address = Com.create(<Hello {...Props} />, {
// html/hello/uid.html
join_dir: 'hello',
html_name: `${uid}.html`,
})
return this.Pup.render(Address)
}
}
// 初始化 图片生成对象
export const imgae = new Image()