File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ npm init
3636
3737# 安装 Koishi 和相关插件
3838npm i koishi \
39+ @koishijs/plugin-server \
3940 @koishijs/plugin-console \
4041 @koishijs/plugin-sandbox \
4142 @koishijs/plugin-echo
@@ -49,6 +50,7 @@ yarn init
4950
5051# 安装 Koishi 和相关插件
5152yarn add koishi
53+ @koishijs/plugin-server \
5254 @koishijs/plugin-console \
5355 @koishijs/plugin-sandbox \
5456 @koishijs/plugin-echo
@@ -62,16 +64,18 @@ yarn add typescript @types/node esbuild esbuild-register -D
6264
6365``` ts title=index.ts no-extra-header
6466import { Context } from ' koishi'
67+ import server from ' @koishijs/plugin-server'
6568import console from ' @koishijs/plugin-console'
6669import * as sandbox from ' @koishijs/plugin-sandbox'
6770import * as echo from ' @koishijs/plugin-echo'
6871
6972// 创建一个 Koishi 应用
70- const ctx = new Context ({
71- port: 5140 ,
72- })
73+ const ctx = new Context ()
7374
7475// 启用上述插件
76+ ctx .plugin (server , {
77+ port: 5140 ,
78+ }) // 提供后端服务
7579ctx .plugin (console ) // 提供控制台
7680ctx .plugin (sandbox ) // 提供调试沙盒
7781ctx .plugin (echo ) // 提供回声指令
You can’t perform that action at this time.
0 commit comments