docs: 调整文档

This commit is contained in:
ningmengchongshui 2024-06-10 17:11:16 +08:00
parent eaa2ad1e89
commit 8899018a4e
10 changed files with 12 additions and 230 deletions

View File

@ -17,7 +17,6 @@ module.exports = {
segment: true
},
rules: {
'eqeqeq': ['off'],
'prefer-const': ['off'],
'arrow-body-style': 'off'
}

141
README.md
View File

@ -10,6 +10,8 @@
推荐使用`18.18.2`版本,如果系统不支持,最低要求`16.14.0`,这是新版`puppeteer`的限制
[点击阅读Miao-Yunzai文档了解更多](https://ningmengchongshui.github.io/Miao-Yunzai-Docs/)
## 使用教程
- 安装源码
@ -47,7 +49,7 @@ npm run app
- 重新登录
```sh
npm run app login
npm run login
```
- 进程托管
@ -62,133 +64,12 @@ npm run start
npm run kill
```
## 新特性
## 致谢
支持TS、TSX环境提供Miao-Yunzai完全的类型声明及其开发文档。
- 消息回调
[查看 开发示例](./example/apps.ts)
- 图片组件
你无需再写原生的htmlReact将为你进行组件和管理
[学习 React.js](https://react.docschina.org/)
你无需再写原生从css !
tailwindcss将识别plugins目录下的tsx和jsx文件
为你自动生成css , 存放在`./public/output.css`
[学习 tailwindcss](https://www.tailwindcss.cn/)
- 测试生成HTML
```sh
npm run css
npx ts-node ./example/index.ts
```
> 插件间浏览器都将独立控制
[查看 开发示例](./example/index.tsx)
- 热开发图片
```sh
npm run image
```
[查看 配置示例](./example/routes.tsx)
## 生成开发文档
```sh
npm run docs
```
浏览器打开文件`docs/index.html`
## 关于lib
将在未来逐渐放弃,在版本发布后,开发者需要有意识的对此变化做出调整.
```ts
// 已废弃
--lib / puppeteer
// 无扩展性,计划废弃
--lib / renderer
// 非机器人框架的核心处理代码
// 消耗服务器内存,无扩展性,计划废弃
--lib / tools / web.js / test.js / log.js / ksr.js
// 计划废弃
--renderers
// 其他内容逐步优化。。。
```
# 开发者需知
- 提交
```ts
/**
* feature新功能
* update更新某功能
* fix修补某功能
* refactor重构某个功能
* optimize: 优化构建工具或运行时性能
* style仅样式改动
* docs仅文档新增/改动
* chore构建过程或辅助工具的变动
*/
```
- 注释风格
```ts
/**
* 返回false
* @param T 任意字符串
* @returns false
*/
function getTest(T: string) {
return false
}
```
- 命名风格
```ts
// 获得test值
function getTest(T: string) {}
// 设置
function setTest(T: string) {}
// 删除
function delTest(T: string) {}
// 获取某数据依据为id
function getDataById(T: string) {}
// 系统常量
const ENV_TEST = 'dev'
// 局域常量
const MyName = 'yunzai'
// 可修改变量
let values = ''
// 禁止使用 var values = ''
// 声明数组
const Arr = []
// 不推荐 new
// 声明对象
const Obj = {}
// 不推荐new
```
| Nickname | Contribution |
| :-----------------------------------------------------------: | -------------------- |
| [Yunzai v3.0](https://gitee.com/le-niao/Yunzai-Bot) | 乐神的Yunzai-Bot V3 |
| [GardenHamster](https://github.com/GardenHamster/GenshinPray) | 模拟抽卡背景素材来源 |
| [西风驿站](https://bbs.mihoyo.com/ys/collection/839181) | 角色攻略图来源 |
| [米游社友人A](https://bbs.mihoyo.com/ys/collection/428421) | 角色突破素材图来源 |
| [icqq](https://github.com/icqqjs/icqq) | ICQQ |

View File

@ -1,18 +0,0 @@
#!/usr/bin/env sh
# 确保脚本抛出遇到的错误
set -e
# 生成静态文件
npm run docs
# 进入生成的文件夹
cd docs/
git init
git add -A
git commit -m 'add'
git push -f git@github.com:yoimiya-kokomi/Miao-Yunzai.git master:docs

View File

@ -1,7 +0,0 @@
import { Messages } from '../src/core/index.js'
const message = new Messages({
priority: 9000
})
message.response(/^你好/, async e => {
e.reply('你好')
})

View File

@ -1,12 +0,0 @@
import React from 'react'
export type DataType = {
name: string
}
export type PropsType = {
data: DataType
}
export default function App({ data }: PropsType) {
return (
<div className="text-red-500 p-2 text-xl m-80">Hello, {data.name}!</div>
)
}

View File

@ -1,38 +0,0 @@
import React from 'react'
import { Component, Puppeteer } from '../src/utils/index.js'
import Hello, { type DataType } from './hello.tsx'
export const Com = new Component()
export const Pup = new Puppeteer()
export class Image {
constructor() {
// 启动
Pup.start()
}
/**
* html html文件
* @returns
*/
getHelloComponent(uid: number, data: DataType) {
// 生成 html 地址 或 html字符串
const Address = Com.create(<Hello data={data} />, {
/**
* json_dir时
* html_head路径应该是../public/output.css
* html_head默认值路径也是../public/output.css
* head的话html_head和join_dir都可以省略
* { html_name: `${uid}.html`}
*/
html_head: `<link rel="stylesheet" href="../../public/output.css"></link>`,
// html/hello/uid.html
join_dir: 'hello',
html_name: `${uid}.html`
// 不生成文件返回的将是html字符串
// file_create:false
})
return Pup.render(Address)
}
}
export const imgae = new Image()
// render 是异步的,因此 此处也是异步的
await imgae.getHelloComponent(1715713638, { name: 'word' })
// e.reply(segment.buffer(img))

View File

@ -1,17 +0,0 @@
import React from 'react'
import { type RouterType } from '../image/types.js'
import Hello from './hello.tsx'
/**
* *********
*
* routes.jsx
* routes.tsx
*
* *********
*/
export default [
{
url: '/',
element: <Hello data={{ name: 'word' }}></Hello>
}
] as RouterType

View File

@ -9,7 +9,7 @@ const argvs = argv.join(' ').replace(/(\S+\.js|\S+\.ts)/g, '')
*/
exec(
'tailwindcss -i ./src/input.css -o ./public/output.css',
(error, stdout, stderr) => {
(error, _, __) => {
if (error) {
//
}

View File

@ -17,7 +17,6 @@
"monit": "pm2 monit",
"pm2": "pm2",
"image": "nodemon --config image/nodemon.json",
"docs": "typedoc --options typedoc.json",
"css": "tailwindcss -i ./src/input.css -o ./public/output.css",
"format": "prettier --write .",
"prepare": "husky"
@ -77,7 +76,6 @@
"rollup": "^4.16.4",
"tailwindcss": "^3.4.3",
"ts-node": "^10.9.1",
"typedoc": "^0.25.4",
"typescript": "^5.0.4"
},
"imports": {

View File

@ -1,4 +0,0 @@
{
"entryPoints": ["./src"],
"out": "./docs"
}