跳到主要内容

快速入门指南

以当前默认宿主 src\Services\Host\FreeKit.Host 为主,从仓库代码直接对应到可访问入口。

前置要求

必需环境

  • .NET SDK 10.0+
  • Git
  • MySQL 8.x、SQL Server、PostgreSQL 或 SQLite 之一
  • Redis 7.x

按需启用

  • RabbitMQ:CAP 消息总线相关功能
  • MeiliSearch:CmsKit 搜索、搜索建议、增量索引
  • Docker Desktop:使用 Compose 一键启动整套依赖

方式一:本地直接运行默认宿主

1. 克隆并还原

git clone https://github.com/luoyunchong/FreeKitModules.git
cd FreeKitModules
dotnet restore FreeKitModules.sln

2. 修改主宿主配置

编辑 src\Services\Host\FreeKit.Host\appsettings.Development.json,至少确认这些配置段可用:

{
"ASPNETCORE_PATHBASE": "/kit_api",
"ConnectionStrings": {
"DefaultDB": "0",
"MySql": "Data Source=localhost;Port=3306;User ID=root;Password=<your-password>;Initial Catalog=freekit;Charset=utf8mb4;SslMode=none;",
"Redis": "localhost:6379,password=<your-password>,defaultDatabase=1"
},
"ShortUrlConnectionStrings": {
"MySql": "Data Source=localhost;Port=3306;User ID=root;Password=<your-password>;Initial Catalog=freekit_shorturl;Charset=utf8mb4;SslMode=none;"
},
"LogConnectionStrings": {
"MySql": "Data Source=localhost;Port=3306;User ID=root;Password=<your-password>;Initial Catalog=freekit_log;Charset=utf8mb4;SslMode=none;"
}
}

如果暂时不使用搜索,可保持 MeiliSearch.Enable = false

3. 启动主 API 宿主

dotnet run --project src\Services\Host\FreeKit.Host --launch-profile https-dev

launchSettings.json 中的本地默认地址为:

  • https://localhost:7002/kit_api
  • http://localhost:5002/kit_api

4. 验证入口

入口地址
Swagger UIhttps://localhost:7002/kit_api/swagger
RapiDochttps://localhost:7002/kit_api/r
健康检查https://localhost:7002/kit_api/health
FreeScheduler UIhttps://localhost:7002/kit_api/job
在线用户 Hubhttps://localhost:7002/kit_api/hubs/onlineuser
通知 Hubhttps://localhost:7002/kit_api/hubs/notifications

方式二:本地运行三类默认宿主

如果你需要完整体验任务与消息处理,可分别启动:

dotnet run --project src\Services\Host\FreeKit.Job.Host --launch-profile https-dev
dotnet run --project src\Services\Host\FreeKit.MessageHandler.Host --launch-profile https-dev
dotnet run --project src\Services\Host\FreeKit.HealthChecks\FreeKit.HealthChecks

对应本地默认地址:

宿主本地地址
FreeKit.Job.Hosthttps://localhost:7000/job_api
FreeKit.MessageHandler.Hosthttps://localhost:7003/message_api
FreeKit.HealthCheckshttps://localhost:5005

方式三:Docker Compose 一键启动

仓库已提供统一脚本:

build\run_freekit_pro_modules.bat

或:

bash build/run_freekit_pro_modules.bash

脚本会优先读取:

  1. build/compose/freekit_pro_modules/.env.local
  2. 若不存在则回退到 build/compose/freekit_pro_modules/.env

Compose 默认启动的服务:

  • mysql
  • redis
  • rabbitmq
  • meilisearch
  • host
  • job
  • message

容器模式默认访问地址:

入口地址
主 API Swaggerhttp://localhost:18080/kit_api/swagger
主 API RapiDochttp://localhost:18080/kit_api/r
Job Swaggerhttp://localhost:18081/job_api/swagger
Job FreeScheduler UIhttp://localhost:18081/job_api/job
Message Swaggerhttp://localhost:18082/message_api/swagger
RabbitMQ 管理台http://localhost:15673
MeiliSearchhttp://localhost:17700

首次运行时会发生什么

默认宿主调用 builder.UseFreeKit(moduleTypeMap: E.Modules, ...) 装载模块,并在启动后执行:

  • app.MapModules().Init()
  • await app.MigrationStartAsync()
  • 各模块 IModuleStartup.Configure(...) 中的 FreeSql CodeFirst SyncStructure(...)

这意味着开发环境下,模块会在应用启动时自动同步表结构。

默认模块清单

主宿主当前默认注册模块来自 src\Services\Host\FreeKit.DI\E.cs

  • Identity
  • Identity.Infrastructure
  • Platform
  • Holiday
  • ToDo
  • CmsKit
  • ToolKit
  • IM
  • Member
  • Short

Mall 代码存在于仓库中,但当前默认主宿主未启用。

推荐下一步

  1. 阅读 技术栈介绍
  2. 查看 配置项参考
  3. 使用 API 总览 对照真实路由前缀
  4. 需要扩展模块时阅读 新模块开发指南