EnvironmentHelper 增加 Rease 编译 只允许生产环境

This commit is contained in:
chfei committed 2026-08-06 15:04:05 +08:00
1 parent 7f15eb9c0b
commit e6660f03f6
3 files changed
+7 -2

No files matched your search

+5
View File
@@ -29,6 +29,10 @@ public class EnvironmentHelper
private static string DetermineEnvironment()
{
#if RELEASE
// Release 构建:只允许生产环境,不允许其他环境
return "Production";
#else
// 1. 检查环境变量
var envVar = Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT") ??
Environment.GetEnvironmentVariable("ENVIRONMENT");
@@ -49,6 +53,7 @@ public class EnvironmentHelper
// 4. 默认返回 Production
return "Production";
#endif
}
// 获取环境描述