添加项目文件。

This commit is contained in:
2026-04-25 10:21:34 +08:00
parent c04cb001fb
commit 2e763dd1c3
98 changed files with 89974 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
using AcdiuTools.Services;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
namespace AcdiuTools.Controllers
{
/// <summary>
/// 基础控制器
/// 所有需要主题功能的控制器应继承此类
/// </summary>
public class BaseController(IThemeService themeService) : Controller
{
private readonly IThemeService _themeService = themeService;
/// <summary>
/// 在执行 Action 之前加载主题配置并注入 ViewBag
/// </summary>
public override async void OnActionExecuting(ActionExecutingContext context)
{
base.OnActionExecuting(context);
// 异步操作在 OnActionExecuting 中处理需小心,通常建议在 Action 内部或中间件中处理
// 这里为了演示简单,使用同步等待或改为中间件方案更佳
// 更好的方式:使用 ViewComponent 或 TagHelper
var theme = await _themeService.GetUserThemeAsync();
ViewBag.CurrentTheme = theme;
}
}
}