命名空间:ZhonTai.Admin.Core.Configs
概述
中台 Admin 的核心配置文件为 appconfig.json,对应 AppConfig 类。此外还包括数据库、JWT、邮件、OSS、缓存、限流等独立配置文件。
AppConfig 主配置
配置文件:Configs/appconfig.json
配置项说明
| 配置项 | 类型 | 说明 |
|---|---|---|
AppType |
string | 应用程序类型:Controllers / ControllersWithViews / MVC |
Urls |
string[] | 监听地址列表,如["http://*:18010"] |
CorUrls |
string[] | 跨域地址列表 |
AssemblyNames |
string[] | 要扫描的程序集名称列表 |
EnumListAssemblyNames |
string[] | 枚举列表程序集名称 |
Tenant |
bool | 是否启用多租户 |
DistributeKey |
string | 分布式事务唯一标识,为空则不生成分布式事务表 |
DefaultPassword |
string | 默认密码 |
Lang |
object | 语言配置 |
Validate |
object | 验证配置 |
Aop |
object | AOP 配置 |
Swagger |
object | Swagger 配置 |
ApiUI |
object | 新版接口文档展示配置 |
MiniProfiler |
bool | 启用 MiniProfiler 性能分析器 |
Log |
object | 日志配置 |
RateLimit |
bool | 启用限流 |
VarifyCode |
object | 验证码配置 |
DynamicApi |
object | 动态 API 配置 |
PasswordHasher |
bool | 实现标准标识密码哈希 |
Kestrel |
object | Kestrel 服务器配置 |
HealthChecks |
object | 健康检查配置 |
PreflightMaxAge |
int | 跨域预检等待时间(秒),默认 1800 |
TaskSchedulerUI |
object | 任务调度管理界面 |
IdGenerator |
object | ID 生成器配置 |
IP2Region |
object | IP 地址定位配置 |
Lang 语言配置
| 配置项 | 类型 | 说明 |
|---|---|---|
EnableJson |
bool | 启用语言配置 |
DefaultLang |
string | 默认语言,如zh-CN |
Langs |
string[] | 支持的语言列表 |
RequestCultureProviders |
string[] | 语言请求解析列表:QueryString、Cookie、AcceptLanguageHeader |
Validate 验证配置
| 配置项 | 类型 | 说明 |
|---|---|---|
Login |
bool | 启用登录验证 |
Permission |
bool | 启用权限验证 |
DataPermission |
bool | 启用数据权限 |
ApiDataPermission |
bool | 启用接口级数据权限 |
Swagger 配置
| 配置项 | 类型 | 说明 |
|---|---|---|
Enable |
bool | 启用 Swagger |
EnableEnumSchemaFilter |
bool | 启用枚举架构过滤器 |
EnableOrderTagsDocumentFilter |
bool | 启用接口排序文档过滤器 |
EnableJsonStringEnumConverter |
bool | 启用枚举属性名 |
EnableSchemaIdNamespace |
bool | 启用 SchemaId 命名空间 |
AssemblyNameList |
string[] | 用于启用 SchemaId 命名空间的程序集列表 |
RoutePrefix |
string | 路由前缀,如配置微服务文档地址:doc/module/swagger |
Url |
string | Swagger 地址 |
Projects |
object[] | Swagger 项目分组列表 |
ApiUI 接口文档配置
| 配置项 | 类型 | 说明 |
|---|---|---|
Enable |
bool | 启用 ApiUI |
RoutePrefix |
string | 路由前缀 |
Footer |
object | 页脚配置 |
Log 日志配置
| 配置项 | 类型 | 说明 |
|---|---|---|
Operation |
bool | 启用操作日志 |
Method |
string | 记录日志方式:Grpc / Cap |
VarifyCode 验证码配置
| 配置项 | 类型 | 说明 |
|---|---|---|
Enable |
bool | 启用验证码 |
Fonts |
string[] | 字体列表 |
DynamicApi 动态 API 配置
| 配置项 | 类型 | 说明 |
|---|---|---|
FormatResult |
bool | 启用结果格式化 |
Kestrel 服务器配置
| 配置项 | 类型 | 说明 |
|---|---|---|
KeepAliveTimeout |
int | HTTP 连接保活最长时间(秒) |
RequestHeadersTimeout |
int | 发送请求头最长时间(秒) |
MaxRequestBodySize |
long | 最大请求大小(bytes),null 不限制 |
HealthChecks 健康检查配置
| 配置项 | 类型 | 说明 |
|---|---|---|
Enable |
bool | 启用健康检查 |
Path |
string | 健康检查访问路径 |
TaskSchedulerUI 任务调度管理界面
| 配置项 | 类型 | 说明 |
|---|---|---|
Enable |
bool | 启用任务调度管理界面 |
Path |
string | 访问路径 |
IdGenerator ID 生成器配置
| 配置项 | 类型 | 说明 |
|---|---|---|
DataCenterId |
int | 数据中心 ID |
WorkerId |
int | 机器码,必须全局唯一 |
WorkerIdBitLength |
int | 机器码位长,默认 6 |
SeqBitLength |
int | 序列数位长,默认 6 |
CachePrefix |
string | 缓存前缀 |
IP2Region IP 地址定位配置
| 配置项 | 类型 | 说明 |
|---|---|---|
Enable |
bool | 启用 IP 地址定位 |
DbPath |
string | 绝对数据库路径,为空则默认使用网站根目录ip2region.xdb |
配置示例
1 | { |
DbConfig 数据库配置
配置文件:Configs/dbconfig.json
配置项说明
| 配置项 | 类型 | 说明 |
|---|---|---|
Key |
string | 数据库注册键(如AdminDb、LogDb) |
Type |
string | 数据库类型:MySql / SqlServer / PostgreSQL / Sqlite / Oracle / TiDB 等 |
ConnectionString |
string | 连接字符串 |
AssemblyNames |
string[] | 程序集名称,自动获取实体表,为空则通过ConfigureFreeSql 自定义配置 |
IncludeEntityDbs |
string[] | 指定实体数据库列表,不填同步所有数据库表实体 |
ExcludeEntityDbs |
string[] | 排除实体数据库列表,指定不同步数据库表实体 |
MonitorCommand |
bool | 监听所有操作 |
Curd |
bool | 监听 Curd 操作 |
SyncStructureSql |
bool | 监听同步结构脚本 |
SyncDataCurd |
bool | 监听同步数据 Curd 操作 |
CreateDb |
bool | 建库 |
CreateDbConnectionString |
string | 建库连接字符串 |
CreateDbSql |
string | 建库脚本 |
SyncStructure |
bool | 自动同步表结构 |
SyncStructureEntityBatchSize |
int | 同步结构批次实体数 |
SyncDataBatchSize |
int | 同步数据分批处理大小,默认 500,过大可能会导致内存溢出 |
SyncData |
bool | 自动同步种子数据 |
SyncUpdateData |
bool | 同步更新数据,生产环境谨慎开启 |
SyncDataPath |
string | 同步数据地址 |
SyncDataIncludeTables |
string[] | 同步数据包含表,指定表同步,不填同步所有表 |
SyncDataExcludeTables |
string[] | 同步数据排除表,指定表不同步 |
SyncDataUser |
object | 同步数据操作用户 |
GenerateData |
bool | 生成种子数据包,发布生产环境前使用完记得关闭 |
ProviderType |
string | 指定程序集 |
SlaveList |
object[] | 读写分离从库列表 |
IdleTime |
int | 空闲时间(分),0 不自动回收 |
ForceUpdate |
bool | 新增时强制更新EntityUpdate 数据 |
Dbs |
object[] | 多库配置(子库列表) |
配置示例
1 | { |
JwtConfig JWT 配置
配置文件:Configs/jwtconfig.json
配置项说明
| 配置项 | 类型 | 说明 |
|---|---|---|
Issuer |
string | 发行者 |
Audience |
string | 订阅者 |
SecurityKey |
string | 密钥,自定义 |
Expires |
int | Access Token 有效期(分钟),120 = 2 小时 |
RefreshExpires |
int | Refresh Token 有效期(分钟),1440 = 1 天 |
配置示例
1 | { |
EmailConfig 邮件配置
配置文件:Configs/appsettings.json 中的 Email 节点
配置项说明
| 配置项 | 类型 | 说明 |
|---|---|---|
Host |
string | SMTP 主机,如smtp.qq.com |
Port |
int | 端口号,如 465、587、25 |
UseSsl |
bool | 是否使用 SSL |
UserName |
string | 邮箱账号 |
Password |
string | 邮箱密码 |
FromEmail |
object | 发件人信息 |
ToEmail |
object | 收件人信息 |
配置示例
1 | { |
#中台 #中台/数据库配置 #中台/多数据库配置