feat: 同步更新

This commit is contained in:
ningmengchongshui 2024-06-18 13:49:19 +08:00
parent a26d500ab3
commit 1ed74602d5
2 changed files with 15 additions and 5 deletions

View File

@ -1,9 +1,8 @@
import React from 'react'
import { Picture } from 'yunzai/utils'
import { type PropsType } from './views/hello.tsx'
import * as hello from './views/hello.tsx'
import { createDynamicComponent } from 'yunzai/utils'
const dynamic = createDynamicComponent(import.meta.url)
export class Image extends Picture {
constructor() {
super()
@ -16,9 +15,8 @@ export class Image extends Picture {
* @param Props
* @returns
*/
async createHello(uid: number, Props: PropsType) {
// 非生产环境将触发动态组件效果
const { default: Hello } = (await dynamic<'default', PropsType>('./views/hello.tsx'))
async createHello(uid: number, Props: Parameters<typeof hello.default>[0]) {
const Hello = (await dynamic<typeof hello>('./views/hello.tsx')).default
// 生成 html 地址 或 html字符串
const Address = this.Com.create(<Hello {...Props} />, {
// html/hello/uid.html

View File

@ -17,6 +17,18 @@ export type PropsType = {
const require = createRequire(import.meta.url)
const url: string = require('../resources/example.png')
export function Post({ url }: { url: string }) {
return (
<section className="flex flex-col">
<div className="divide-y divide-slate-100 m-8 shadow-2xl">
<img className="h-40 w-40" src={url}></img>
</div>
</section>
)
}
/**
*
* @param param0