mirror of
https://github.com/Megghy/MegghysAPI.git
synced 2025-12-06 14:16:56 +08:00
将项目从 Fluent UI 迁移到 Ant Design Blazor: - 替换 UI 组件,更新样式和脚本。 - 移除 Fluent UI 相关依赖,添加 Ant Design 依赖。 优化 DNS 解析接口: - 将解析接口从 POST 改为 GET,简化参数结构。 - 更新 `DnsResponse` 和配置文件结构。 数据库模型优化: - 为 JSON 数据存储添加 `JArray` 映射支持。 初始化逻辑重构: - 简化 `AutoInit` 初始化逻辑,提升代码可读性。 其他改动: - 升级依赖包版本。 - 移除无用命名空间和属性。
81 lines
2.0 KiB
Plaintext
81 lines
2.0 KiB
Plaintext
@rendermode InteractiveServer
|
|
@implements IDisposable
|
|
|
|
<Menu Mode="MenuMode.Inline"
|
|
Theme="MenuTheme.Dark"
|
|
InlineCollapsed="@InlineCollapsed"
|
|
SelectedKeys="@selectedKeys"
|
|
OnMenuItemClicked="HandleMenuClick"
|
|
Class="app-menu">
|
|
<MenuItem Key="/">
|
|
<Icon Type="IconType.OutlineHome" />
|
|
<span>Home</span>
|
|
</MenuItem>
|
|
<MenuItem Key="pixiv">
|
|
<Icon Type="IconType.OutlinePicture" />
|
|
<span>Pixiv</span>
|
|
</MenuItem>
|
|
<MenuItem Key="weather">
|
|
<Icon Type="IconType.OutlineCloud" />
|
|
<span>Weather</span>
|
|
</MenuItem>
|
|
</Menu>
|
|
|
|
@code {
|
|
[Parameter]
|
|
public bool InlineCollapsed { get; set; }
|
|
|
|
private string[] selectedKeys = ["/"];
|
|
|
|
[Inject]
|
|
private NavigationManager NavigationManager { get; set; } = default!;
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
UpdateSelectedKeys(NavigationManager.Uri);
|
|
}
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
UpdateSelectedKeys(NavigationManager.Uri);
|
|
NavigationManager.LocationChanged += HandleLocationChanged;
|
|
}
|
|
|
|
private void HandleLocationChanged(object? sender, LocationChangedEventArgs e)
|
|
{
|
|
UpdateSelectedKeys(e.Location);
|
|
StateHasChanged();
|
|
}
|
|
|
|
private void UpdateSelectedKeys(string uri)
|
|
{
|
|
var relative = NavigationManager.ToBaseRelativePath(uri);
|
|
if (string.IsNullOrEmpty(relative))
|
|
{
|
|
selectedKeys = ["/"];
|
|
}
|
|
else
|
|
{
|
|
var key = relative.Split('/', StringSplitOptions.RemoveEmptyEntries).FirstOrDefault() ?? string.Empty;
|
|
selectedKeys = [key];
|
|
}
|
|
}
|
|
|
|
private void HandleMenuClick(MenuItem menuItem)
|
|
{
|
|
if (menuItem.Key is null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
selectedKeys = [menuItem.Key];
|
|
var target = menuItem.Key == "/" ? "/" : $"/{menuItem.Key}";
|
|
NavigationManager.NavigateTo(target);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
NavigationManager.LocationChanged -= HandleLocationChanged;
|
|
}
|
|
}
|