diff --git a/apps/restart.ts b/apps/restart.ts index cbbe12b..04395e7 100644 --- a/apps/restart.ts +++ b/apps/restart.ts @@ -97,8 +97,7 @@ export class Restart extends Plugin { await redis.set(this.key, data, { EX: 120 }) if (await isPortTaken(restart_port || 27881)) { try { - let result = await fetch(`http://localhost:${restart_port || 27881}/restart`) - result = await result.text() + const result = await fetch(`http://localhost:${restart_port || 27881}/restart`).then(res=>res.text()) if (result !== `OK`) { redis.del(this.key) this.e.reply(`操作失败!`) diff --git a/hello.tsx b/hello.tsx deleted file mode 100644 index 84a9308..0000000 --- a/hello.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import React from 'react' -import Nav from './component/Nav.tsx' -import NavItem from './component/NavItem.tsx' -import List from './component/List.tsx' -import ListItem, { MovieType } from './component/ListItem.tsx' -export type DataType = { - name: string -} -export type PropsType = { - data: DataType - movies:MovieType[] -} -export default function App({ data, movies }: PropsType) { - return ( -
- - - {movies.map((movie) => ( - - ))} - -
- ) -} \ No newline at end of file diff --git a/image.tsx b/image.tsx new file mode 100644 index 0000000..3917710 --- /dev/null +++ b/image.tsx @@ -0,0 +1,41 @@ +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(, { + // html/hello/uid.html + join_dir: 'hello', + html_name: `${uid}.html`, + }) + return this.Pup.render(Address) + } +} +// 初始化 图片生成对象 +export const imgae = new Image() \ No newline at end of file diff --git a/resources/example.png b/resources/example.png new file mode 100644 index 0000000..4cda1a5 Binary files /dev/null and b/resources/example.png differ diff --git a/routes.tsx b/routes.tsx index 554b399..2d961e9 100644 --- a/routes.tsx +++ b/routes.tsx @@ -1,22 +1,13 @@ import React from "react" import { type RouterType } from "yunzai/image/types" -import Hello from "./hello.tsx" - +import Hello from "./views/hello.tsx" +import Music from "./views/music.tsx" +import { createRequire } from 'yunzai/utils' +const require = createRequire(import.meta.url) const movies = [ { id: 0, - image: 'https://t14.baidu.com/it/u=2426410956,1575157783&fm=58&app=83&size=w931&q=75&n=0&f=JPEG&fmt=auto&maxorilen2heic=2000000', - title: 'Prognosis Negative', - starRating: '2.66', - rating: 'PG-13', - year: '2021', - genre: 'Comedy', - runtime: '1h 46m', - cast: 'Simon Pegg, Zach Galifianakis ' - }, - { - id: 0, - image: 'https://t14.baidu.com/it/u=2426410956,1575157783&fm=58&app=83&size=w931&q=75&n=0&f=JPEG&fmt=auto&maxorilen2heic=2000000', + image: require('./resources/example.png'), title: 'Prognosis Negative', starRating: '2.66', rating: 'PG-13', @@ -26,17 +17,14 @@ const movies = [ cast: 'Simon Pegg, Zach Galifianakis ' } ] - const Config: RouterType = [ { url: "/", element: }, { - url: "/new", - element:
- hello Word ! -
+ url: "/music", + element: } ] export default Config \ No newline at end of file diff --git a/views/hello.tsx b/views/hello.tsx new file mode 100644 index 0000000..d676975 --- /dev/null +++ b/views/hello.tsx @@ -0,0 +1,33 @@ +import React from 'react' +import Nav from '../component/Nav.tsx' +import NavItem from '../component/NavItem.tsx' +import List from '../component/List.tsx' +import ListItem, { MovieType } from '../component/ListItem.tsx' +export type DataType = { + name: string +} +export type PropsType = { + data: DataType + movies:MovieType[] +} +import { createRequire } from 'yunzai/utils' +const require = createRequire(import.meta.url) +export default function App({ data, movies }: PropsType) { + const url = require('../resources/example.png') + return ( +
+ + + + {movies.map((movie) => ( + + ))} + +
+ ) +} \ No newline at end of file diff --git a/views/music.tsx b/views/music.tsx new file mode 100644 index 0000000..20f16fc --- /dev/null +++ b/views/music.tsx @@ -0,0 +1,82 @@ +import React from "react"; +import { createRequire } from 'yunzai/utils' +const require = createRequire(import.meta.url) +export default function App() { + const url = require('../resources/example.png') + return <> +
+
+ +
+

+ Ep. 128 +

+

+ Scaling CSS at Heroku with Utility Classes +

+

+ Full Stack Radio +

+
+
+
+
+
+
+
+
+
+
+
+
+
24:16
+
75:50
+
+
+
+
+
+ + + +
+ +
+ + + +
+
+ +} \ No newline at end of file