From 04439c323a910a44c225d3a0937ecec3afd81d8c Mon Sep 17 00:00:00 2001 From: Maiko Sinkyaet Tan Date: Thu, 26 Sep 2024 04:11:27 +0800 Subject: [PATCH] Update workflow for direct invocation de Koishi (#191) --- zh-CN/manual/starter/direct.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/zh-CN/manual/starter/direct.md b/zh-CN/manual/starter/direct.md index a4e3c01232e8..4eae8548b4b1 100644 --- a/zh-CN/manual/starter/direct.md +++ b/zh-CN/manual/starter/direct.md @@ -36,6 +36,7 @@ npm init # 安装 Koishi 和相关插件 npm i koishi \ + @koishijs/plugin-server \ @koishijs/plugin-console \ @koishijs/plugin-sandbox \ @koishijs/plugin-echo @@ -49,6 +50,7 @@ yarn init # 安装 Koishi 和相关插件 yarn add koishi + @koishijs/plugin-server \ @koishijs/plugin-console \ @koishijs/plugin-sandbox \ @koishijs/plugin-echo @@ -62,16 +64,18 @@ yarn add typescript @types/node esbuild esbuild-register -D ```ts title=index.ts no-extra-header import { Context } from 'koishi' +import server from '@koishijs/plugin-server' import console from '@koishijs/plugin-console' import * as sandbox from '@koishijs/plugin-sandbox' import * as echo from '@koishijs/plugin-echo' // 创建一个 Koishi 应用 -const ctx = new Context({ - port: 5140, -}) +const ctx = new Context() // 启用上述插件 +ctx.plugin(server, { + port: 5140, +}) // 提供后端服务 ctx.plugin(console) // 提供控制台 ctx.plugin(sandbox) // 提供调试沙盒 ctx.plugin(echo) // 提供回声指令