diff --git a/src/TelegramPanel.Web/Components/Pages/Channels.razor b/src/TelegramPanel.Web/Components/Pages/Channels.razor new file mode 100644 index 0000000..cac547a --- /dev/null +++ b/src/TelegramPanel.Web/Components/Pages/Channels.razor @@ -0,0 +1,171 @@ +@page "/channels" +@inject IChannelService ChannelService +@inject ISnackbar Snackbar +@inject NavigationManager Navigation + +频道列表 - Telegram Panel + +频道列表 + + + + + + 我的频道 + + + 全部账号 + 账号1 (+86xxx) + 账号2 (+86yyy) + + + 全部 + 公开 + 私密 + + + + + 频道名称 + 用户名 + 类型 + 成员数 + 创建账号 + 最后同步 + 操作 + + + +
+ @context.Title[0] +
+ @context.Title + @if (!string.IsNullOrEmpty(context.About)) + { + @context.About + } +
+
+
+ + @if (!string.IsNullOrEmpty(context.Username)) + { + @context.Username + } + else + { + - + } + + + + @(string.IsNullOrEmpty(context.Username) ? "私密" : "公开") + + + @context.MemberCount + 账号 @context.CreatorAccountId + @context.SyncedAt.ToString("yyyy-MM-dd HH:mm") + + + 查看详情 + 编辑频道 + 邀请用户 + 复制链接 + + 删除频道 + + +
+ + 暂无频道数据 + + + + +
+
+
+ +@code { + private List channels = new(); + private bool loading = true; + private string searchString = ""; + private int filterAccount = 0; + private string filterType = "all"; + + protected override async Task OnInitializedAsync() + { + await LoadChannels(); + } + + private async Task LoadChannels() + { + loading = true; + try + { + // TODO: 从数据库加载频道列表 + channels = new List(); + Snackbar.Add("频道列表加载成功", Severity.Success); + } + catch (Exception ex) + { + Snackbar.Add($"加载失败:{ex.Message}", Severity.Error); + } + finally + { + loading = false; + } + } + + private bool FilterFunc(ChannelInfo channel) + { + if (filterAccount > 0 && channel.CreatorAccountId != filterAccount) + return false; + + if (filterType == "public" && string.IsNullOrEmpty(channel.Username)) + return false; + + if (filterType == "private" && !string.IsNullOrEmpty(channel.Username)) + return false; + + if (string.IsNullOrWhiteSpace(searchString)) + return true; + + if (channel.Title.Contains(searchString, StringComparison.OrdinalIgnoreCase)) + return true; + + if (channel.Username?.Contains(searchString, StringComparison.OrdinalIgnoreCase) == true) + return true; + + return false; + } + + private void ShowDetails(ChannelInfo channel) + { + Snackbar.Add($"查看频道详情:{channel.Title}", Severity.Info); + } + + private void EditChannel(ChannelInfo channel) + { + Snackbar.Add($"编辑频道:{channel.Title}", Severity.Info); + } + + private void InviteUsers(ChannelInfo channel) + { + Navigation.NavigateTo($"/batch/invite?channelId={channel.Id}"); + } + + private void CopyLink(ChannelInfo channel) + { + var link = string.IsNullOrEmpty(channel.Username) + ? $"私密频道(邀请链接待实现)" + : $"https://t.me/{channel.Username}"; + Snackbar.Add($"链接:{link}", Severity.Info); + } + + private async Task DeleteChannel(int id) + { + Snackbar.Add("删除功能开发中", Severity.Warning); + } +}