diff --git a/apps/add.ts b/apps/add.ts index d38909b..43f09f6 100644 --- a/apps/add.ts +++ b/apps/add.ts @@ -11,6 +11,9 @@ import { makeForwardMsg } from 'yunzai/core' const textArr = {} +/** + * tudo + */ export class add extends Plugin { path = './data/textJson/' facePath = './data/face/' diff --git a/apps/disFriPoke.ts b/apps/event/disFriPoke.ts similarity index 100% rename from apps/disFriPoke.ts rename to apps/event/disFriPoke.ts diff --git a/apps/disPri.ts b/apps/event/disPri.ts similarity index 100% rename from apps/disPri.ts rename to apps/event/disPri.ts diff --git a/apps/friend.ts b/apps/event/friend.ts similarity index 100% rename from apps/friend.ts rename to apps/event/friend.ts diff --git a/apps/invite.ts b/apps/event/invite.ts similarity index 88% rename from apps/invite.ts rename to apps/event/invite.ts index 6e1920e..5d78343 100644 --- a/apps/invite.ts +++ b/apps/event/invite.ts @@ -22,6 +22,11 @@ export class invite extends Plugin { * @returns */ 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))) { logger.mark(`[邀请加群]:${this.e.group_name}:${this.e.group_id}`) return diff --git a/apps/newcomer.ts b/apps/event/newcomer.ts similarity index 100% rename from apps/newcomer.ts rename to apps/event/newcomer.ts diff --git a/apps/outNotice.ts b/apps/event/outNotice.ts similarity index 100% rename from apps/outNotice.ts rename to apps/event/outNotice.ts diff --git a/apps/quit.ts b/apps/event/quit.ts similarity index 100% rename from apps/quit.ts rename to apps/event/quit.ts diff --git a/apps/index.ts b/apps/index.ts index d02eb93..27a8015 100644 --- a/apps/index.ts +++ b/apps/index.ts @@ -4,15 +4,15 @@ * ***** */ export * from './add.js' -export * from './disFriPoke.js' -export * from './disPri.js' -export * from './friend.js' -export * from './invite.js' -export * from './quit.js' +export * from './event/disFriPoke.js' +export * from './event/disPri.js' +export * from './event/friend.js' +export * from './event/invite.js' +export * from './event/quit.js' export * from './restart.js' export * from './sendLog.js' export * from './status.js' export * from './update.js' export * from './example2.js' -export * from './newcomer.js' -export * from './outNotice.js' \ No newline at end of file +export * from './event/newcomer.js' +export * from './event/outNotice.js' \ No newline at end of file diff --git a/apps/restart.ts b/apps/restart.ts index 3356ce0..fa73e6f 100644 --- a/apps/restart.ts +++ b/apps/restart.ts @@ -5,6 +5,10 @@ import fs from 'fs' import YAML from 'yaml' import { exec } from 'child_process' +/** + * tudo + */ + /** * * @param port @@ -51,9 +55,9 @@ export class Restart extends Plugin { } async init() { - let restart = await redis.get(this.key) - if (restart) { - restart = JSON.parse(restart) + const data = await redis.get(this.key) + if (data) { + const restart = JSON.parse(data) const uin = restart?.uin || Bot.uin let time = restart.time || new Date().getTime() time = (new Date().getTime() - time) / 1000 diff --git a/apps/sendLog.ts b/apps/sendLog.ts index 95fa140..dbb9b16 100644 --- a/apps/sendLog.ts +++ b/apps/sendLog.ts @@ -4,6 +4,10 @@ import fs from "node:fs" import lodash from "lodash" import moment from "moment" +/** + * tudo + */ + /** * */ diff --git a/apps/status.ts b/apps/status.ts index 29dc30c..82dc968 100644 --- a/apps/status.ts +++ b/apps/status.ts @@ -2,6 +2,11 @@ import { ConfigController as cfg } from 'yunzai/config' import moment from 'moment' import { Plugin } from 'yunzai/core' + +/** + * tudo + */ + /** * */ diff --git a/apps/update.ts b/apps/update.ts index 3e154da..b46fad5 100644 --- a/apps/update.ts +++ b/apps/update.ts @@ -7,38 +7,52 @@ import { sleep } from 'yunzai/utils' import { exec, execSync } from 'child_process' import { BOT_NAME } from 'yunzai/config' +/** + * tudo + */ + let uping = false +const Cache = new Map() + +/** + * + */ export class update extends Plugin { typeName = BOT_NAME messages = [] + isUp = null + isNowUp = null + oldCommitId = null constructor() { - /** - name: '更新', - dsc: '#更新 #强制更新', - */ super() this.priority = 4000 this.rule = [ { - reg: '^#更新日志', + reg: /^#更新日志/, fnc: this.updateLog.name }, { - reg: '^#(强制)?更新', + reg: /^#(强制)?更新/, fnc: this.update.name }, { - reg: '^#(静默)?全部(强制)?更新$', + reg: /^#(静默)?全部(强制)?更新$/, fnc: this.updateAll.name, permission: 'master' } ] } - + /** + * + * @returns + */ async update() { if (!this.e.isMaster) return false - if (uping) return this.reply('已有命令更新中..请勿重复操作') + if (uping) { + this.reply('已有命令更新中..请勿重复操作') + return + } if (/详细|详情|面板|面版/.test(this.e.msg)) return false @@ -63,55 +77,60 @@ export class update extends Plugin { } } + /** + * + * @param Plugin + * @returns + */ getPlugin(Plugin = '') { if (!Plugin) { Plugin = this.e.msg.replace(/#(强制)?更新(日志)?/, '') if (!Plugin) return '' } - if (!fs.existsSync(`Plugins/${Plugin}/.git`)) return false - this.typeName = Plugin return Plugin } + /** + * + * @param cmd + * @returns + */ async execSync(cmd) { - return new Promise((resolve, reject) => { + return new Promise((resolve) => { exec(cmd, { windowsHide: true }, (error, stdout, stderr) => { resolve({ error, stdout, stderr }) }) }) } + /** + * + * @param Plugin + * @returns + */ async runUpdate(Plugin = '') { this.isNowUp = false - let cm = 'git pull --no-rebase' - let type = '更新' if (this.e.msg.includes('强制')) { type = '强制更新' cm = `git reset --hard && git pull --rebase --allow-unrelated-histories` } if (Plugin) cm = `cd "Plugins/${Plugin}" && ${cm}` - this.oldCommitId = await this.getcommitId(Plugin) - logger.mark(`${this.e.logFnc} 开始${type}:${this.typeName}`) - await this.reply(`开始${type} ${this.typeName}`) uping = true const ret = await this.execSync(cm) uping = false - if (ret.error) { logger.mark(`${this.e.logFnc} 更新失败:${this.typeName}`) this.gitErr(ret.error, ret.stdout) return false } - const time = await this.getTime(Plugin) - if (/Already up|已经是最新/g.test(ret.stdout)) { await this.reply(`${this.typeName} 已是最新\n最后更新时间:${time}`) } else { @@ -119,23 +138,30 @@ export class update extends Plugin { this.isUp = true await this.reply(await this.getLog(Plugin)) } - logger.mark(`${this.e.logFnc} 最后更新时间:${time}`) return true } + /** + * + * @param Plugin + * @returns + */ async getcommitId(Plugin = '') { let cm = 'git rev-parse --short HEAD' if (Plugin) cm = `cd "Plugins/${Plugin}" && ${cm}` - const commitId = await execSync(cm, { encoding: 'utf-8' }) return lodash.trim(commitId) } + /** + * + * @param Plugin + * @returns + */ async getTime(Plugin = '') { let cm = 'git log -1 --pretty=%cd --date=format:"%F %T"' if (Plugin) cm = `cd "Plugins/${Plugin}" && ${cm}` - let time = '' try { time = await execSync(cm, { encoding: 'utf-8' }) @@ -144,41 +170,42 @@ export class update extends Plugin { logger.error(error.toString()) time = '获取时间失败' } - return time } + /** + * + * @param err + * @param stdout + * @returns + */ async gitErr(err, stdout) { const msg = '更新失败!' const errMsg = err.toString() stdout = stdout.toString() - if (errMsg.includes('Timed out')) { const remote = errMsg.match(/'(.+?)'/g)[0].replace(/'/g, '') return this.reply(`${msg}\n连接超时:${remote}`) } - if (/Failed to connect|unable to access/g.test(errMsg)) { const remote = errMsg.match(/'(.+?)'/g)[0].replace(/'/g, '') return this.reply(`${msg}\n连接失败:${remote}`) } - if (errMsg.includes('be overwritten by merge')) { return this.reply(`${msg}\n存在冲突:\n${errMsg}\n请解决冲突后再更新,或者执行#强制更新,放弃本地修改`) } - if (stdout.includes('CONFLICT')) { return this.reply(`${msg}\n存在冲突:\n${errMsg}${stdout}\n请解决冲突后再更新,或者执行#强制更新,放弃本地修改`) } - return this.reply([errMsg, stdout]) } + /** + * + */ async updateAll() { const dirs = fs.readdirSync('./Plugins/') - const originalReply = this.reply - const testReg = /^#静默全部(强制)?更新$/.test(this.e.msg) if (testReg) { await this.reply(`开始执行静默全部更新,请稍等...`) @@ -208,10 +235,18 @@ export class update extends Plugin { this.reply = originalReply } + /** + * + */ restart() { new Restart(this.e).restart() } + /** + * + * @param Plugin + * @returns + */ async getLog(Plugin = '') { let cm = 'git log -100 --pretty="%h||[%cd] %s" --date=format:"%F %T"' 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}条`) } + /** + * + * @returns + */ async updateLog() { const Plugin = this.getPlugin() if (Plugin === false) return false - return this.reply(await this.getLog(Plugin)) + this.reply(await this.getLog(Plugin)) + return } } diff --git a/component/List.tsx b/component/List.tsx new file mode 100644 index 0000000..983dba4 --- /dev/null +++ b/component/List.tsx @@ -0,0 +1,9 @@ +import React from "react"; + +export default function List({ children }) { + return ( + + ) + } \ No newline at end of file diff --git a/component/ListItem.tsx b/component/ListItem.tsx new file mode 100644 index 0000000..27da2e5 --- /dev/null +++ b/component/ListItem.tsx @@ -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 ( +
+ +
+

{movie.title}

+
+
+
+ Star rating + + + +
+
{movie.starRating}
+
+
+
Rating
+
{movie.rating}
+
+
+
Year
+
{movie.year}
+
+
+
Genre
+
+ + {movie.genre} +
+
+
+
Runtime
+
+ + {movie.runtime} +
+
+
+
Cast
+
{movie.cast}
+
+
+
+
+ ) + } + \ No newline at end of file diff --git a/component/Nav.tsx b/component/Nav.tsx new file mode 100644 index 0000000..8241c59 --- /dev/null +++ b/component/Nav.tsx @@ -0,0 +1,10 @@ +import React from "react"; +export default function Nav({ children }) { + return ( + + ) + } \ No newline at end of file diff --git a/component/NavItem.tsx b/component/NavItem.tsx new file mode 100644 index 0000000..ecafb89 --- /dev/null +++ b/component/NavItem.tsx @@ -0,0 +1,13 @@ +import React from "react"; +export default function NavItem({ href, children }) { + return ( +
  • + + {children} + +
  • + ) + } \ No newline at end of file diff --git a/deploy.sh b/deploy.sh deleted file mode 100644 index 4f11b54..0000000 --- a/deploy.sh +++ /dev/null @@ -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 \ No newline at end of file diff --git a/hello.tsx b/hello.tsx index b9b6c34..84a9308 100644 --- a/hello.tsx +++ b/hello.tsx @@ -1,12 +1,26 @@ 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 }: PropsType) { +export default function App({ data, movies }: PropsType) { return ( -
    Hello, {data.name}!
    +
    + + + {movies.map((movie) => ( + + ))} + +
    ) } \ No newline at end of file diff --git a/routes.tsx b/routes.tsx index df8e8b6..554b399 100644 --- a/routes.tsx +++ b/routes.tsx @@ -1,10 +1,42 @@ import React from "react" import { type RouterType } from "yunzai/image/types" 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 = [ - { - url: "/", - element: + { + url: "/", + element: + }, + { + url: "/new", + element:
    + hello Word ! +
    } ] export default Config \ No newline at end of file