feat: 丰富例子
This commit is contained in:
parent
c052a84f27
commit
9fcf22ccbe
|
@ -11,6 +11,9 @@ import { makeForwardMsg } from 'yunzai/core'
|
||||||
|
|
||||||
const textArr = {}
|
const textArr = {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* tudo
|
||||||
|
*/
|
||||||
export class add extends Plugin {
|
export class add extends Plugin {
|
||||||
path = './data/textJson/'
|
path = './data/textJson/'
|
||||||
facePath = './data/face/'
|
facePath = './data/face/'
|
||||||
|
|
|
@ -22,6 +22,11 @@ export class invite extends Plugin {
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async accept() {
|
async accept() {
|
||||||
|
if(/group/.test(this.event)){
|
||||||
|
this.e.isGroup = true
|
||||||
|
}
|
||||||
|
if(!this.e.isGroup) return
|
||||||
|
//
|
||||||
if (!cfg.masterQQ || !cfg.masterQQ.includes(String(this.e.user_id))) {
|
if (!cfg.masterQQ || !cfg.masterQQ.includes(String(this.e.user_id))) {
|
||||||
logger.mark(`[邀请加群]:${this.e.group_name}:${this.e.group_id}`)
|
logger.mark(`[邀请加群]:${this.e.group_name}:${this.e.group_id}`)
|
||||||
return
|
return
|
|
@ -4,15 +4,15 @@
|
||||||
* *****
|
* *****
|
||||||
*/
|
*/
|
||||||
export * from './add.js'
|
export * from './add.js'
|
||||||
export * from './disFriPoke.js'
|
export * from './event/disFriPoke.js'
|
||||||
export * from './disPri.js'
|
export * from './event/disPri.js'
|
||||||
export * from './friend.js'
|
export * from './event/friend.js'
|
||||||
export * from './invite.js'
|
export * from './event/invite.js'
|
||||||
export * from './quit.js'
|
export * from './event/quit.js'
|
||||||
export * from './restart.js'
|
export * from './restart.js'
|
||||||
export * from './sendLog.js'
|
export * from './sendLog.js'
|
||||||
export * from './status.js'
|
export * from './status.js'
|
||||||
export * from './update.js'
|
export * from './update.js'
|
||||||
export * from './example2.js'
|
export * from './example2.js'
|
||||||
export * from './newcomer.js'
|
export * from './event/newcomer.js'
|
||||||
export * from './outNotice.js'
|
export * from './event/outNotice.js'
|
|
@ -5,6 +5,10 @@ import fs from 'fs'
|
||||||
import YAML from 'yaml'
|
import YAML from 'yaml'
|
||||||
import { exec } from 'child_process'
|
import { exec } from 'child_process'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* tudo
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param port
|
* @param port
|
||||||
|
@ -51,9 +55,9 @@ export class Restart extends Plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
let restart = await redis.get(this.key)
|
const data = await redis.get(this.key)
|
||||||
if (restart) {
|
if (data) {
|
||||||
restart = JSON.parse(restart)
|
const restart = JSON.parse(data)
|
||||||
const uin = restart?.uin || Bot.uin
|
const uin = restart?.uin || Bot.uin
|
||||||
let time = restart.time || new Date().getTime()
|
let time = restart.time || new Date().getTime()
|
||||||
time = (new Date().getTime() - time) / 1000
|
time = (new Date().getTime() - time) / 1000
|
||||||
|
|
|
@ -4,6 +4,10 @@ import fs from "node:fs"
|
||||||
import lodash from "lodash"
|
import lodash from "lodash"
|
||||||
import moment from "moment"
|
import moment from "moment"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* tudo
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2,6 +2,11 @@
|
||||||
import { ConfigController as cfg } from 'yunzai/config'
|
import { ConfigController as cfg } from 'yunzai/config'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import { Plugin } from 'yunzai/core'
|
import { Plugin } from 'yunzai/core'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* tudo
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
104
apps/update.ts
104
apps/update.ts
|
@ -7,38 +7,52 @@ import { sleep } from 'yunzai/utils'
|
||||||
import { exec, execSync } from 'child_process'
|
import { exec, execSync } from 'child_process'
|
||||||
import { BOT_NAME } from 'yunzai/config'
|
import { BOT_NAME } from 'yunzai/config'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* tudo
|
||||||
|
*/
|
||||||
|
|
||||||
let uping = false
|
let uping = false
|
||||||
|
|
||||||
|
const Cache = new Map()
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
export class update extends Plugin {
|
export class update extends Plugin {
|
||||||
typeName = BOT_NAME
|
typeName = BOT_NAME
|
||||||
messages = []
|
messages = []
|
||||||
|
isUp = null
|
||||||
|
isNowUp = null
|
||||||
|
oldCommitId = null
|
||||||
constructor() {
|
constructor() {
|
||||||
/**
|
|
||||||
name: '更新',
|
|
||||||
dsc: '#更新 #强制更新',
|
|
||||||
*/
|
|
||||||
super()
|
super()
|
||||||
this.priority = 4000
|
this.priority = 4000
|
||||||
this.rule = [
|
this.rule = [
|
||||||
{
|
{
|
||||||
reg: '^#更新日志',
|
reg: /^#更新日志/,
|
||||||
fnc: this.updateLog.name
|
fnc: this.updateLog.name
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
reg: '^#(强制)?更新',
|
reg: /^#(强制)?更新/,
|
||||||
fnc: this.update.name
|
fnc: this.update.name
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
reg: '^#(静默)?全部(强制)?更新$',
|
reg: /^#(静默)?全部(强制)?更新$/,
|
||||||
fnc: this.updateAll.name,
|
fnc: this.updateAll.name,
|
||||||
permission: 'master'
|
permission: 'master'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
async update() {
|
async update() {
|
||||||
if (!this.e.isMaster) return false
|
if (!this.e.isMaster) return false
|
||||||
if (uping) return this.reply('已有命令更新中..请勿重复操作')
|
if (uping) {
|
||||||
|
this.reply('已有命令更新中..请勿重复操作')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (/详细|详情|面板|面版/.test(this.e.msg)) return false
|
if (/详细|详情|面板|面版/.test(this.e.msg)) return false
|
||||||
|
|
||||||
|
@ -63,55 +77,60 @@ export class update extends Plugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param Plugin
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
getPlugin(Plugin = '') {
|
getPlugin(Plugin = '') {
|
||||||
if (!Plugin) {
|
if (!Plugin) {
|
||||||
Plugin = this.e.msg.replace(/#(强制)?更新(日志)?/, '')
|
Plugin = this.e.msg.replace(/#(强制)?更新(日志)?/, '')
|
||||||
if (!Plugin) return ''
|
if (!Plugin) return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fs.existsSync(`Plugins/${Plugin}/.git`)) return false
|
if (!fs.existsSync(`Plugins/${Plugin}/.git`)) return false
|
||||||
|
|
||||||
this.typeName = Plugin
|
this.typeName = Plugin
|
||||||
return Plugin
|
return Plugin
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param cmd
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
async execSync(cmd) {
|
async execSync(cmd) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve) => {
|
||||||
exec(cmd, { windowsHide: true }, (error, stdout, stderr) => {
|
exec(cmd, { windowsHide: true }, (error, stdout, stderr) => {
|
||||||
resolve({ error, stdout, stderr })
|
resolve({ error, stdout, stderr })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param Plugin
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
async runUpdate(Plugin = '') {
|
async runUpdate(Plugin = '') {
|
||||||
this.isNowUp = false
|
this.isNowUp = false
|
||||||
|
|
||||||
let cm = 'git pull --no-rebase'
|
let cm = 'git pull --no-rebase'
|
||||||
|
|
||||||
let type = '更新'
|
let type = '更新'
|
||||||
if (this.e.msg.includes('强制')) {
|
if (this.e.msg.includes('强制')) {
|
||||||
type = '强制更新'
|
type = '强制更新'
|
||||||
cm = `git reset --hard && git pull --rebase --allow-unrelated-histories`
|
cm = `git reset --hard && git pull --rebase --allow-unrelated-histories`
|
||||||
}
|
}
|
||||||
if (Plugin) cm = `cd "Plugins/${Plugin}" && ${cm}`
|
if (Plugin) cm = `cd "Plugins/${Plugin}" && ${cm}`
|
||||||
|
|
||||||
this.oldCommitId = await this.getcommitId(Plugin)
|
this.oldCommitId = await this.getcommitId(Plugin)
|
||||||
|
|
||||||
logger.mark(`${this.e.logFnc} 开始${type}:${this.typeName}`)
|
logger.mark(`${this.e.logFnc} 开始${type}:${this.typeName}`)
|
||||||
|
|
||||||
await this.reply(`开始${type} ${this.typeName}`)
|
await this.reply(`开始${type} ${this.typeName}`)
|
||||||
uping = true
|
uping = true
|
||||||
const ret = await this.execSync(cm)
|
const ret = await this.execSync(cm)
|
||||||
uping = false
|
uping = false
|
||||||
|
|
||||||
if (ret.error) {
|
if (ret.error) {
|
||||||
logger.mark(`${this.e.logFnc} 更新失败:${this.typeName}`)
|
logger.mark(`${this.e.logFnc} 更新失败:${this.typeName}`)
|
||||||
this.gitErr(ret.error, ret.stdout)
|
this.gitErr(ret.error, ret.stdout)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const time = await this.getTime(Plugin)
|
const time = await this.getTime(Plugin)
|
||||||
|
|
||||||
if (/Already up|已经是最新/g.test(ret.stdout)) {
|
if (/Already up|已经是最新/g.test(ret.stdout)) {
|
||||||
await this.reply(`${this.typeName} 已是最新\n最后更新时间:${time}`)
|
await this.reply(`${this.typeName} 已是最新\n最后更新时间:${time}`)
|
||||||
} else {
|
} else {
|
||||||
|
@ -119,23 +138,30 @@ export class update extends Plugin {
|
||||||
this.isUp = true
|
this.isUp = true
|
||||||
await this.reply(await this.getLog(Plugin))
|
await this.reply(await this.getLog(Plugin))
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.mark(`${this.e.logFnc} 最后更新时间:${time}`)
|
logger.mark(`${this.e.logFnc} 最后更新时间:${time}`)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param Plugin
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
async getcommitId(Plugin = '') {
|
async getcommitId(Plugin = '') {
|
||||||
let cm = 'git rev-parse --short HEAD'
|
let cm = 'git rev-parse --short HEAD'
|
||||||
if (Plugin) cm = `cd "Plugins/${Plugin}" && ${cm}`
|
if (Plugin) cm = `cd "Plugins/${Plugin}" && ${cm}`
|
||||||
|
|
||||||
const commitId = await execSync(cm, { encoding: 'utf-8' })
|
const commitId = await execSync(cm, { encoding: 'utf-8' })
|
||||||
return lodash.trim(commitId)
|
return lodash.trim(commitId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param Plugin
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
async getTime(Plugin = '') {
|
async getTime(Plugin = '') {
|
||||||
let cm = 'git log -1 --pretty=%cd --date=format:"%F %T"'
|
let cm = 'git log -1 --pretty=%cd --date=format:"%F %T"'
|
||||||
if (Plugin) cm = `cd "Plugins/${Plugin}" && ${cm}`
|
if (Plugin) cm = `cd "Plugins/${Plugin}" && ${cm}`
|
||||||
|
|
||||||
let time = ''
|
let time = ''
|
||||||
try {
|
try {
|
||||||
time = await execSync(cm, { encoding: 'utf-8' })
|
time = await execSync(cm, { encoding: 'utf-8' })
|
||||||
|
@ -144,41 +170,42 @@ export class update extends Plugin {
|
||||||
logger.error(error.toString())
|
logger.error(error.toString())
|
||||||
time = '获取时间失败'
|
time = '获取时间失败'
|
||||||
}
|
}
|
||||||
|
|
||||||
return time
|
return time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param err
|
||||||
|
* @param stdout
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
async gitErr(err, stdout) {
|
async gitErr(err, stdout) {
|
||||||
const msg = '更新失败!'
|
const msg = '更新失败!'
|
||||||
const errMsg = err.toString()
|
const errMsg = err.toString()
|
||||||
stdout = stdout.toString()
|
stdout = stdout.toString()
|
||||||
|
|
||||||
if (errMsg.includes('Timed out')) {
|
if (errMsg.includes('Timed out')) {
|
||||||
const remote = errMsg.match(/'(.+?)'/g)[0].replace(/'/g, '')
|
const remote = errMsg.match(/'(.+?)'/g)[0].replace(/'/g, '')
|
||||||
return this.reply(`${msg}\n连接超时:${remote}`)
|
return this.reply(`${msg}\n连接超时:${remote}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (/Failed to connect|unable to access/g.test(errMsg)) {
|
if (/Failed to connect|unable to access/g.test(errMsg)) {
|
||||||
const remote = errMsg.match(/'(.+?)'/g)[0].replace(/'/g, '')
|
const remote = errMsg.match(/'(.+?)'/g)[0].replace(/'/g, '')
|
||||||
return this.reply(`${msg}\n连接失败:${remote}`)
|
return this.reply(`${msg}\n连接失败:${remote}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errMsg.includes('be overwritten by merge')) {
|
if (errMsg.includes('be overwritten by merge')) {
|
||||||
return this.reply(`${msg}\n存在冲突:\n${errMsg}\n请解决冲突后再更新,或者执行#强制更新,放弃本地修改`)
|
return this.reply(`${msg}\n存在冲突:\n${errMsg}\n请解决冲突后再更新,或者执行#强制更新,放弃本地修改`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stdout.includes('CONFLICT')) {
|
if (stdout.includes('CONFLICT')) {
|
||||||
return this.reply(`${msg}\n存在冲突:\n${errMsg}${stdout}\n请解决冲突后再更新,或者执行#强制更新,放弃本地修改`)
|
return this.reply(`${msg}\n存在冲突:\n${errMsg}${stdout}\n请解决冲突后再更新,或者执行#强制更新,放弃本地修改`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.reply([errMsg, stdout])
|
return this.reply([errMsg, stdout])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
async updateAll() {
|
async updateAll() {
|
||||||
const dirs = fs.readdirSync('./Plugins/')
|
const dirs = fs.readdirSync('./Plugins/')
|
||||||
|
|
||||||
const originalReply = this.reply
|
const originalReply = this.reply
|
||||||
|
|
||||||
const testReg = /^#静默全部(强制)?更新$/.test(this.e.msg)
|
const testReg = /^#静默全部(强制)?更新$/.test(this.e.msg)
|
||||||
if (testReg) {
|
if (testReg) {
|
||||||
await this.reply(`开始执行静默全部更新,请稍等...`)
|
await this.reply(`开始执行静默全部更新,请稍等...`)
|
||||||
|
@ -208,10 +235,18 @@ export class update extends Plugin {
|
||||||
this.reply = originalReply
|
this.reply = originalReply
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
restart() {
|
restart() {
|
||||||
new Restart(this.e).restart()
|
new Restart(this.e).restart()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param Plugin
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
async getLog(Plugin = '') {
|
async getLog(Plugin = '') {
|
||||||
let cm = 'git log -100 --pretty="%h||[%cd] %s" --date=format:"%F %T"'
|
let cm = 'git log -100 --pretty="%h||[%cd] %s" --date=format:"%F %T"'
|
||||||
if (Plugin) cm = `cd "Plugins/${Plugin}" && ${cm}`
|
if (Plugin) cm = `cd "Plugins/${Plugin}" && ${cm}`
|
||||||
|
@ -254,9 +289,14 @@ export class update extends Plugin {
|
||||||
return makeForwardMsg(this.e, [log, end], `${Plugin || 'Miao-Yunzai'} 更新日志,共${line}条`)
|
return makeForwardMsg(this.e, [log, end], `${Plugin || 'Miao-Yunzai'} 更新日志,共${line}条`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
async updateLog() {
|
async updateLog() {
|
||||||
const Plugin = this.getPlugin()
|
const Plugin = this.getPlugin()
|
||||||
if (Plugin === false) return false
|
if (Plugin === false) return false
|
||||||
return this.reply(await this.getLog(Plugin))
|
this.reply(await this.getLog(Plugin))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
export default function List({ children }) {
|
||||||
|
return (
|
||||||
|
<ul className="divide-y divide-slate-100">
|
||||||
|
{children}
|
||||||
|
</ul>
|
||||||
|
)
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
export interface MovieType {
|
||||||
|
id: number, //
|
||||||
|
image:string, //
|
||||||
|
title:string, // Prognosis Negative
|
||||||
|
starRating: string, // 2.66
|
||||||
|
rating:string, // PG-13
|
||||||
|
year:string, // 2021
|
||||||
|
genre:string, // Comedy
|
||||||
|
runtime:string, // 1h 46m
|
||||||
|
cast:string // Simon Pegg, Zach Galifianakis
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function ListItem({ movie }: {movie:MovieType}) {
|
||||||
|
return (
|
||||||
|
<article className="flex items-start space-x-6 p-6">
|
||||||
|
<img src={movie.image} alt="" width="60" height="88" className="flex-none rounded-md bg-slate-100" />
|
||||||
|
<div className="min-w-0 relative flex-auto">
|
||||||
|
<h2 className="font-semibold text-slate-900 truncate pr-20">{movie.title}</h2>
|
||||||
|
<dl className="mt-2 flex flex-wrap text-sm leading-6 font-medium">
|
||||||
|
<div className="absolute top-0 right-0 flex items-center space-x-1">
|
||||||
|
<dt className="text-sky-500">
|
||||||
|
<span className="sr-only">Star rating</span>
|
||||||
|
<svg width="16" height="20" fill="currentColor">
|
||||||
|
<path d="M7.05 3.691c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.372 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.539 1.118l-2.8-2.034a1 1 0 00-1.176 0l-2.8 2.034c-.783.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.363-1.118L.98 9.483c-.784-.57-.381-1.81.587-1.81H5.03a1 1 0 00.95-.69L7.05 3.69z" />
|
||||||
|
</svg>
|
||||||
|
</dt>
|
||||||
|
<dd>{movie.starRating}</dd>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<dt className="sr-only">Rating</dt>
|
||||||
|
<dd className="px-1.5 ring-1 ring-slate-200 rounded">{movie.rating}</dd>
|
||||||
|
</div>
|
||||||
|
<div className="ml-2">
|
||||||
|
<dt className="sr-only">Year</dt>
|
||||||
|
<dd>{movie.year}</dd>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<dt className="sr-only">Genre</dt>
|
||||||
|
<dd className="flex items-center">
|
||||||
|
<svg width="2" height="2" fill="currentColor" className="mx-2 text-slate-300" aria-hidden="true">
|
||||||
|
<circle cx="1" cy="1" r="1" />
|
||||||
|
</svg>
|
||||||
|
{movie.genre}
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<dt className="sr-only">Runtime</dt>
|
||||||
|
<dd className="flex items-center">
|
||||||
|
<svg width="2" height="2" fill="currentColor" className="mx-2 text-slate-300" aria-hidden="true">
|
||||||
|
<circle cx="1" cy="1" r="1" />
|
||||||
|
</svg>
|
||||||
|
{movie.runtime}
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<div className="flex-none w-full mt-2 font-normal">
|
||||||
|
<dt className="sr-only">Cast</dt>
|
||||||
|
<dd className="text-slate-400">{movie.cast}</dd>
|
||||||
|
</div>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
import React from "react";
|
||||||
|
export default function Nav({ children }) {
|
||||||
|
return (
|
||||||
|
<nav className="py-4 px-6 text-sm font-medium">
|
||||||
|
<ul className="flex space-x-3">
|
||||||
|
{children}
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
)
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
import React from "react";
|
||||||
|
export default function NavItem({ href, children }) {
|
||||||
|
return (
|
||||||
|
<li>
|
||||||
|
<a
|
||||||
|
href={href}
|
||||||
|
className={`block px-3 py-2 rounded-md bg-sky-500 text-white`}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
)
|
||||||
|
}
|
10
deploy.sh
10
deploy.sh
|
@ -1,10 +0,0 @@
|
||||||
#!/usr/bin/env sh
|
|
||||||
|
|
||||||
# 确保脚本抛出遇到的错误
|
|
||||||
set -e
|
|
||||||
|
|
||||||
git init
|
|
||||||
git add -A
|
|
||||||
git commit -m 'update: 修改'
|
|
||||||
|
|
||||||
git push -f git@github.com:yoimiya-kokomi/Miao-Yunzai.git master:system
|
|
18
hello.tsx
18
hello.tsx
|
@ -1,12 +1,26 @@
|
||||||
import React from 'react'
|
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 = {
|
export type DataType = {
|
||||||
name: string
|
name: string
|
||||||
}
|
}
|
||||||
export type PropsType = {
|
export type PropsType = {
|
||||||
data: DataType
|
data: DataType
|
||||||
|
movies:MovieType[]
|
||||||
}
|
}
|
||||||
export default function App({ data }: PropsType) {
|
export default function App({ data, movies }: PropsType) {
|
||||||
return (
|
return (
|
||||||
<div className="text-red-500 p-2 text-xl m-80">Hello, {data.name}!</div>
|
<div className="divide-y divide-slate-100 m-8 shadow-2xl">
|
||||||
|
<Nav>
|
||||||
|
<NavItem href="./new" >New {data.name}</NavItem>
|
||||||
|
</Nav>
|
||||||
|
<List>
|
||||||
|
{movies.map((movie) => (
|
||||||
|
<ListItem key={movie.id} movie={movie} />
|
||||||
|
))}
|
||||||
|
</List>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
38
routes.tsx
38
routes.tsx
|
@ -1,10 +1,42 @@
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import { type RouterType } from "yunzai/image/types"
|
import { type RouterType } from "yunzai/image/types"
|
||||||
import Hello from "./hello.tsx"
|
import Hello from "./hello.tsx"
|
||||||
|
|
||||||
|
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',
|
||||||
|
title: 'Prognosis Negative',
|
||||||
|
starRating: '2.66',
|
||||||
|
rating: 'PG-13',
|
||||||
|
year: '2021',
|
||||||
|
genre: 'Comedy',
|
||||||
|
runtime: '1h 46m',
|
||||||
|
cast: 'Simon Pegg, Zach Galifianakis '
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
const Config: RouterType = [
|
const Config: RouterType = [
|
||||||
{
|
{
|
||||||
url: "/",
|
url: "/",
|
||||||
element: <Hello data={{ name: "word" }} />
|
element: <Hello data={{ name: "word" }} movies={movies} />
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: "/new",
|
||||||
|
element: <div>
|
||||||
|
hello Word !
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
export default Config
|
export default Config
|
Loading…
Reference in New Issue