Skip to content

Commit

Permalink
docs: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Feb 21, 2022
1 parent 0c50ca0 commit abd4866
Show file tree
Hide file tree
Showing 14 changed files with 441 additions and 424 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ yarn create koishi
- 支持 QQ,Telegram,Discord 等主流聊天平台,支持多账户和跨平台数据互通
- 随时随机通过控制面板监控运行状态,控制机器人的行为,甚至上号聊天

参见:[创建控制台项目](https://koishi.js.org/guide/introduction/console.html)
参见:[创建模板项目](https://koishi.js.org/guide/introduction/template.html)

### 功能强大的 API

Expand Down
14 changes: 9 additions & 5 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ module.exports = {
},
{ text: '指南', link: '/guide/introduction/' },
{ text: 'API', link: '/api/' },
{ text: '官方插件', link: '/plugins/' },
{ text: '插件', link: '/plugins/' },
{ text: '更多', link: '/about/glossary' },
// ...devOnly({ text: '演练场', link: '/playground.html' }),
],
sidebar: {
Expand All @@ -57,12 +58,10 @@ module.exports = {
isGroup: true,
children: [
'/guide/introduction/index.md',
'/guide/introduction/console.md',
'/guide/introduction/coding.md',
'/guide/introduction/direct.md',
'/guide/introduction/template.md',
'/guide/introduction/cli.md',
// '/guide/introduction/comparison.md',
'/guide/introduction/workspace.md',
// '/guide/introduction/glossary.md',
],
}, {
text: '处理交互',
Expand Down Expand Up @@ -296,6 +295,11 @@ module.exports = {
'/plugins/other/puppeteer.md',
],
}],

'/about/': [
'/about/glossary.md',
'/about/history.md',
],
},

lastUpdated: '上次更新',
Expand Down
4 changes: 2 additions & 2 deletions docs/.vuepress/layouts/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
MADE WITH <span class="koi">LOVE</span>
</p>
<div class="actions">
<router-link class="action-button primary" to="/guide/introduction/console">Get Started</router-link>
<router-link class="action-button primary" to="/guide/introduction/template">Get Started</router-link>
<a class="action-button secondary" @click="scroll(1)">Learn More</a>
</div>
<svg aria-hidden="true" focusable="false" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512" class="w-10 h-10">
Expand All @@ -29,7 +29,7 @@
<li>支持 QQ,Telegram,Discord 等主流聊天平台</li>
<li>随时随机通过控制面板监控运行状态,甚至上号聊天</li>
</ul>
<p>查看指南:<router-link to="/guide/introduction/console">创建 Koishi 控制台项目</router-link></p>
<p>查看指南:<router-link to="/guide/introduction/template">创建 Koishi 模板项目</router-link></p>
</div>
<div class="image">
<carousel></carousel>
Expand Down
File renamed without changes.
33 changes: 33 additions & 0 deletions docs/about/history.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
sidebarDepth: 2
---

# 发展史

2019 年 8 月,我开始编写我的第一个基于 Node.js 的聊天机器人,名为四季酱。当时我浏览各种聊天机器人框架,发现并没有自己真正想要的,遂决定从零开始编写。一开始这个机器人只包含了很少的功能,但随着其更多功能的加入,我开始调整起底层架构,并计划逐步将其开源出来。

到目前为止 Koishi 大约每 8 个月发布一个大版本。可以说 Koishi 的发展完全是由需求推动的,在迭代中形成了一套聊天机器人开发的最佳实践。

## v1 时期

Koishi v1 发布于 2020 年 1 月。此时的 Koishi 虽然体量尚小,但已具备了许多一直沿袭至今的特征:通过插件系统实现了功能的模块化,通过事件模型和中间件处理各种输入,上下文负责对输入的事件进行过滤,以及一个通过链式调用进行开发的指令系统等等。

最初的 v1 官方插件只有 common, schedule 和 teach,其他在这个时期开发的插件大都已经弃用了。

## v2 时期

Koishi v2 发布于 2020 年 9 月,主要改动存在于应用层设计上。在这个大版本中,应用作为程序的入口对所需的资源统一管理,第一次有了生命周期钩子的概念,也将 v1 时期的元信息对象进化为了会话对象。这些改动将许多底层的接口进行了封装,允许插件开发者通过更为现代化的方式组织业务逻辑。

v2 时期也是官方插件发展迅猛的时期,许多功能强大的插件如 eval, github, image-search 和 puppeteer 等都是在这个阶段被开发出来的。

## v3 时期

Koishi v3 发布于 2021 年 5 月。这个版本最核心的变化是我们抽象出了 Adapter / Bot 的概念,并成功将 Koishi 适配到 Discord 和 Telegram 等其他主流聊天平台中。另一个值得一提的改动则是我们实现了插件的热重载,并由此催生了网页控制台和插件市场的发展。

在此期间社区开发者贡献了大量或有趣或实用的插件,也意味着 Koishi 在功能模块化的推行上取得了令人满意的成效。

## v4 时期

Koishi v4 发布于 2022 年 1 月,在底层架构中进行了大幅优化。我们引入了 Service 的概念,这将使我们得以通过类似于 IoC / DI 的方式管理 Koishi 的各项功能。同时对于数据库,我们也提供了一个 ORM 解决方案,这大幅优化了插件的开发体验。此外,我们正式围绕 Service 确立了 Assets 和 Cache 等接口,并提供了许多官方插件实现。

在这个版本中,我们出于维护性的考虑将一些官方插件移出了 koishijs/koishi。即便如此,官方插件的数量也较上一个大版本有了一个激增。以插件市场为核心的生态也正在被快速完善起来。
2 changes: 1 addition & 1 deletion docs/guide/adapter/adapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ sidebarDepth: 2

当然,这三种方法并不是对立的,你完全可以同时使用上述三种方法中的两种或者更多。但是这里需要指出的是,如果使用前两种方法,由于这些机器人的运行程序本身是分离的,并不需要做特殊处理,同时你将可能面临数据竞争等问题。而对于第三种方法,机器人管理程序可以对每个账号进行妥善的管理,并且能够通过复用连接的形式获得更高的性能。因此,本章节将着重介绍同一进程的多机器人开发。

[快速上手](../introduction/coding.md#配置多机器人) 一章中我们已经给出了一个简单的例子:
[快速上手](../introduction/direct.md#配置多机器人) 一章中我们已经给出了一个简单的例子:

::: code-group language koishi.config
```js
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/introduction/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sidebarDepth: 2

# 命令行工具

@koishijs/cli 提供了名为 `koishi` 的命令行工具。如果你之前已经搭建了 [控制台应用](./console.md),这套命令行工具就已经被集成在其中了。但如果你刚刚完成 [代码上手](./coding.md),那么你需要手动安装这个包:
@koishijs/cli 提供了名为 `koishi` 的命令行工具。如果你之前已经搭建了 [控制台应用](./template.md),这套命令行工具就已经被集成在其中了。但如果你刚刚完成 [代码上手](./direct.md),那么你需要手动安装这个包:

::: code-group manager
```npm
Expand Down
Loading

0 comments on commit abd4866

Please sign in to comment.