Skip to content

Commit

Permalink
fix: 优化#karin
Browse files Browse the repository at this point in the history
  • Loading branch information
Lain. committed Apr 21, 2024
1 parent 1f6f3d7 commit 266c0c3
Showing 1 changed file with 26 additions and 41 deletions.
67 changes: 26 additions & 41 deletions docs/develop/karin.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,46 @@
## #karin

`./lib/index.js`
## 概述
`#Karin``./lib/index.js`文件的别名,这是一个集中导出多个模块的入口文件。
通过使用别名,开发者可以更简洁地引入所需的模块,无需指定完整的路径。

```js
import Bot from './bot/bot.js'
import App from './plugins/app.js'
import Cfg from './config/config.js'
import logger from './config/log.js'
import redis from './config/redis.js'
import segment from './bot/segment.js'
import common from './common/common.js'
import plugin from './plugins/plugin.js'
import Renderer from './Renderer/Renderer.js'
import { kritor } from './adapter/kritor/protos/compiled.js'

export { App, Bot, Cfg, common, logger, plugin, redis, segment, Renderer, kritor }
import segment from './lib/bot/segment.js'
import plugin from './lib/plugins/plugin.js'

// 以上的导入麻烦且冗长,在使用别名后可以简化为
import { segment, plugin } from '#Karin'
```

### 简介
## 使用

可以看到,`#Karin` 是一个别名,指向 `./lib/index.js` 文件。
::: tip
可能会更新不及时,有一定阅读能力的可以查看 [lib/index.js](https://github.com/KarinJS/Karin/blob/main/lib/index.js)
:::

此文件为入口文件,开发者无需像以下这样引入模块:
- ## `segment`
请点击 [elements](./elements.md) 查看详情

```js
import segment from './lib/bot/segment.js'
import plugin from './lib/plugins/plugin.js'
```
- ## `YamlEditor`
请点击 [YamlEditor](./YamlEditor.md) 查看详情

### 使用
- ## `kritor`
内部方法,若无特殊需求,不建议使用

- `APP`
- ## `APP`
```js
import { App } from '#Karin'
// ...
```
- `Bot`
- ## `Bot`
```js
import { Bot } from '#Karin'
// ...
```
- `Cfg`
- ## `Cfg`
```js
import { Cfg } from '#Karin'
// ...
```
- `common`
- ## `common`
```js
import { common } from '#Karin'
Expand Down Expand Up @@ -80,7 +74,7 @@ import plugin from './lib/plugins/plugin.js'
// 输出 buffer
```
- `logger`
- ## `logger`
```js
import { logger } from '#Karin'
Expand Down Expand Up @@ -124,12 +118,12 @@ import plugin from './lib/plugins/plugin.js'
logger.info(logger.chalk.hex('#FF0000')('这是一条自定义颜色的info日志'))
```
- `plugin`
- ## `plugin`
```js
import { plugin } from '#Karin'
// ...
```
- `redis`
- ## `redis`
```js
import { redis } from '#Karin'
Expand Down Expand Up @@ -158,18 +152,9 @@ import plugin from './lib/plugins/plugin.js'
console.log(value)
}
```
- `segment`
```js
import { segment } from '#Karin'
// ...
```
- `Renderer`

- ## `Renderer`
```js
import { Renderer } from '#Karin'
// ...
```
- `kritor`
```js
import { kritor } from '#Karin'
// 内部方法,若无特殊需求,不建议使用
```

0 comments on commit 266c0c3

Please sign in to comment.