Skip to content

Commit

Permalink
in work time, v2.8.13
Browse files Browse the repository at this point in the history
  • Loading branch information
trueai-org committed Aug 1, 2024
1 parent 961636f commit 6fde51f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
- [x] 支持客户端路径指定模式,默认地址例子 https://{BASE_URL}/mj/submit/imagine, /mj-turbo/mj 是 turbo mode, /mj-relax/mj 是 relax mode, /mj-fast/mj 是 fast mode, /mj 不指定模式
- [x] CloudFlare 手动真人验证,触发后自动锁定账号,通过 GUI 直接验证或通过邮件通知验证
- [x] [⚠⚠暂不稳定] CloudFlare 自动真人验证,配置验证服务器地址(自动验证器仅支持 Windows 部署)
- [x] 支持工作时间段配置,24 小时不间断绘图可能会触发警告,建议休息 6~8 小时
- [x] 支持工作时间段配置,连续 24 小时不间断绘图可能会触发警告,建议休息 6~8 小时,示例:`09:10-23:55, 13:00-08:10`

## 在线预览

Expand Down
24 changes: 23 additions & 1 deletion src/Midjourney.Infrastructure/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,29 @@ public static bool IsInWorkTime(this DateTime dateTime, string input)
{
return true;
}
return input.ToTimeSlots().Any(slot => currentTime >= slot.Start && currentTime <= slot.End);

var ts = input.ToTimeSlots();
foreach (var slot in ts)
{
if (slot.Start <= slot.End)
{
// 正常时间段:例如 09:00-17:00
if (currentTime >= slot.Start && currentTime <= slot.End)
{
return true;
}
}
else
{
// 跨越午夜的时间段:例如 23:00-02:00
if (currentTime >= slot.Start || currentTime <= slot.End)
{
return true;
}
}
}

return false;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Midjourney.Infrastructure/GlobalConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class GlobalConfiguration
/// <summary>
/// 版本号
/// </summary>
public static string Version { get; set; } = "v2.8.12";
public static string Version { get; set; } = "v2.8.13";

/// <summary>
/// 判断是否是 Windows 系统
Expand Down

0 comments on commit 6fde51f

Please sign in to comment.