Skip to content

Commit

Permalink
fix favorite pages when without records.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwecho committed Jan 5, 2024
1 parent 690c063 commit 4d36bb0
Show file tree
Hide file tree
Showing 11 changed files with 133 additions and 181 deletions.
5 changes: 2 additions & 3 deletions src/V2ex.Api/FavoriteNodeInfo.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using HtmlAgilityPack;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace V2ex.Api;

Expand All @@ -12,7 +10,8 @@ namespace V2ex.Api;
public class FavoriteNodeInfo
{
[XPath("//a[contains(@class, 'av-node')]", ReturnType.OuterHtml)]
public List<ItemInfo> Items { get; init; } = new();
[SkipNodeNotFound]
public List<ItemInfo> Items { get; init; } = [];

[HasXPath]
[DebuggerDisplay("{Name,nq}")]
Expand Down
1 change: 0 additions & 1 deletion src/V2ex.Api/FavoriteTopicsInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class FavoriteTopicsInfo
[XPath("//div[@id='Wrapper']//div[@class='cell item']", ReturnType.OuterHtml)]
[SkipNodeNotFound]
public List<ItemInfo> Items { get; set; } = new();
public string Url { get; internal set; } = null!;

[HasXPath]
[DebuggerDisplay("{UserName,nq} {TopicTitle,nq}")]
Expand Down
2 changes: 0 additions & 2 deletions src/V2ex.Blazor.Shared/Components/Shared/NavBar.razor
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@
[Parameter]
public bool ShowBackButton { get; set; } = false;

[CascadingParameter]
public Status Status { get; set; } = null!;
[Inject]
private INativeNavigation Navigation { get; set; } = null!;

Expand Down
88 changes: 42 additions & 46 deletions src/V2ex.Blazor.Shared/Components/Shared/SideBar.razor
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
</li>
</ul>
<ul class="pt-4 mt-4 space-y-2 font-medium border-t border-gray-200 dark:border-gray-700">

<li>
<a href="/write"
class="flex items-center p-2 text-gray-900 transition duration-75 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white group">
Expand Down Expand Up @@ -87,52 +86,52 @@

@if (currentUser != null && currentUser.IsAuthenticated)
{
<div class="pt-4 mt-4 flex flex-col divide-y space-y-2 w-full font-medium border-t-2 border-gray-200 dark:border-gray-700">
<div class="flex justify-end">
<div class="flex flex-row w-auto p-2 items-center space-x-1 bg-gray-200 rounded-lg">
@if (currentUser.MoneyGold>0)
{
<img class="w-4 h-4" src="https://v2ex.com/static/img/[email protected]" />
<span class="text-gray-400">@currentUser.MoneyGold</span>
}
<div class="pt-4 mt-4 flex flex-col divide-y space-y-4 w-full font-medium border-t-2 border-gray-200 dark:border-gray-700">
<div class="flex justify-end">
<div class="flex flex-row w-auto p-2 items-center space-x-1 bg-gray-200 rounded-lg">
@if (currentUser.MoneyGold>0)
{
<img class="w-4 h-4" src="https://v2ex.com/static/img/[email protected]" />
<span class="text-gray-400">@currentUser.MoneyGold</span>
}

@if (!(currentUser.MoneyGold == 0 && currentUser.MoneySilver == 0))
{
<img class="w-4 h-4" src="https://v2ex.com/static/img/[email protected]" />
<span class="text-gray-400">@currentUser.MoneySilver</span>
}
<img class="w-4 h-4" src="https://v2ex.com/static/img/[email protected]" />
<span class="text-gray-400">@currentUser.MoneyBronze</span>
</div>
@if (!(currentUser.MoneyGold == 0 && currentUser.MoneySilver == 0))
{
<img class="w-4 h-4" src="https://v2ex.com/static/img/[email protected]" />
<span class="text-gray-400">@currentUser.MoneySilver</span>
}
<img class="w-4 h-4" src="https://v2ex.com/static/img/[email protected]" />
<span class="text-gray-400">@currentUser.MoneyBronze</span>
</div>
</div>

<div class="grid grid-cols-3 divide-x">
<a href="/favorite/nodes" class="group py-2">
<div class="flex flex-col items-center space-y-2">
<svg class="w-6 h-6 text-gray-400 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 18 18">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 14h6m-3 3v-6M1.857 1h4.286c.473 0 .857.384.857.857v4.286A.857.857 0 0 1 6.143 7H1.857A.857.857 0 0 1 1 6.143V1.857C1 1.384 1.384 1 1.857 1Zm10 0h4.286c.473 0 .857.384.857.857v4.286a.857.857 0 0 1-.857.857h-4.286A.857.857 0 0 1 11 6.143V1.857c0-.473.384-.857.857-.857Zm-10 10h4.286c.473 0 .857.384.857.857v4.286a.857.857 0 0 1-.857.857H1.857A.857.857 0 0 1 1 16.143v-4.286c0-.473.384-.857.857-.857Z" />
</svg>
<span class="text-gray-400">节点收藏</span>
</div>
</a>
<a href="/favorite/topics" class="group py-2">
<div class="flex flex-col items-center space-y-2">
<svg class="w-6 h-6 text-gray-400 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 18">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 16.5c0-1-8-2.7-9-2V1.8c1-1 9 .707 9 1.706M10 16.5V3.506M10 16.5c0-1 8-2.7 9-2V1.8c-1-1-9 .707-9 1.706" />
</svg>
<span class="text-gray-400">主题收藏</span>
</div>
</a>
<div class="grid grid-cols-3 divide-x">
<a href="/favorite/nodes" class="group py-2">
<div class="flex flex-col items-center space-y-2">
<svg class="w-6 h-6 text-gray-400 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 18 18">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 14h6m-3 3v-6M1.857 1h4.286c.473 0 .857.384.857.857v4.286A.857.857 0 0 1 6.143 7H1.857A.857.857 0 0 1 1 6.143V1.857C1 1.384 1.384 1 1.857 1Zm10 0h4.286c.473 0 .857.384.857.857v4.286a.857.857 0 0 1-.857.857h-4.286A.857.857 0 0 1 11 6.143V1.857c0-.473.384-.857.857-.857Zm-10 10h4.286c.473 0 .857.384.857.857v4.286a.857.857 0 0 1-.857.857H1.857A.857.857 0 0 1 1 16.143v-4.286c0-.473.384-.857.857-.857Z" />
</svg>
<span class="text-gray-400">节点收藏</span>
</div>
</a>
<a href="/favorite/topics" class="group py-2">
<div class="flex flex-col items-center space-y-2">
<svg class="w-6 h-6 text-gray-400 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 18">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 16.5c0-1-8-2.7-9-2V1.8c1-1 9 .707 9 1.706M10 16.5V3.506M10 16.5c0-1 8-2.7 9-2V1.8c-1-1-9 .707-9 1.706" />
</svg>
<span class="text-gray-400">主题收藏</span>
</div>
</a>

<a href="/favorite/following" class="group py-2">
<div class="flex flex-col items-center space-y-2">
<svg class="w-6 h-6 text-gray-400 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 21 20">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m11.479 1.712 2.367 4.8a.532.532 0 0 0 .4.292l5.294.769a.534.534 0 0 1 .3.91l-3.83 3.735a.534.534 0 0 0-.154.473l.9 5.272a.535.535 0 0 1-.775.563l-4.734-2.49a.536.536 0 0 0-.5 0l-4.73 2.487a.534.534 0 0 1-.775-.563l.9-5.272a.534.534 0 0 0-.154-.473L2.158 8.48a.534.534 0 0 1 .3-.911l5.294-.77a.532.532 0 0 0 .4-.292l2.367-4.8a.534.534 0 0 1 .96.004Z" />
</svg>
<span class="text-gray-400">特别关注</span>
</div>
</a>
</div>
<a href="/favorite/following" class="group py-2">
<div class="flex flex-col items-center space-y-2">
<svg class="w-6 h-6 text-gray-400 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 21 20">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m11.479 1.712 2.367 4.8a.532.532 0 0 0 .4.292l5.294.769a.534.534 0 0 1 .3.91l-3.83 3.735a.534.534 0 0 0-.154.473l.9 5.272a.535.535 0 0 1-.775.563l-4.734-2.49a.536.536 0 0 0-.5 0l-4.73 2.487a.534.534 0 0 1-.775-.563l.9-5.272a.534.534 0 0 0-.154-.473L2.158 8.48a.534.534 0 0 1 .3-.911l5.294-.77a.532.532 0 0 0 .4-.292l2.367-4.8a.534.534 0 0 1 .96.004Z" />
</svg>
<span class="text-gray-400">特别关注</span>
</div>
</a>
</div>
</div>
}
</div>
Expand All @@ -152,7 +151,4 @@
currentUser = new CurrentUser((await AuthenticationStateTask).User);
}
}

[CascadingParameter]
private Status Status { get; set; } = null!;
}
55 changes: 0 additions & 55 deletions src/V2ex.Blazor.Shared/Components/Shared/Status.razor

This file was deleted.

22 changes: 10 additions & 12 deletions src/V2ex.Blazor.Shared/Main.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@
<Found Context="routeData">
<CascadingAuthenticationState>
<Navigation>
<Status>
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(ReturnLayout)">
<Authorizing>
<div>正在加载用户数据...</div>
</Authorizing>
<NotAuthorized>
<LoginRedirect></LoginRedirect>
</NotAuthorized>
</AuthorizeRouteView>
@* <RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" /> *@
<FocusOnNavigate RouteData="@routeData" Selector="input" />
</Status>
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(ReturnLayout)">
<Authorizing>
<div>正在加载用户数据...</div>
</Authorizing>
<NotAuthorized>
<LoginRedirect></LoginRedirect>
</NotAuthorized>
</AuthorizeRouteView>
@* <RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" /> *@
<FocusOnNavigate RouteData="@routeData" Selector="input" />
</Navigation>
</CascadingAuthenticationState>
</Found>
Expand Down
16 changes: 11 additions & 5 deletions src/V2ex.Blazor.Shared/Pages/FavoriteFollowing.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<HeadTitle Title="我的关注"></HeadTitle>

<RefreshView Refresh="()=> LoadAsync(1)">
<LoadingBox Load="()=> LoadAsync(1)">
@if (viewModel != null)
{
@if (viewModel != null && viewModel.Topics.Count > 0)
{
<LoadingBox Load="()=> LoadAsync(1)">
<CollectionView TItem="TopicViewModel" Items="viewModel.Topics" RemainingReachedCallback="OnRemainingReached">
<ItemContent Context="item">
<Topic ViewModel="item"></Topic>
Expand Down Expand Up @@ -38,8 +38,14 @@
}
</Footer>
</CollectionView>
}
</LoadingBox>
</LoadingBox>
}
else
{
<div class="flex flex-col items-center text-gray-400 pt-32">
<div>暂无数据</div>
</div>
}
</RefreshView>


Expand Down
38 changes: 22 additions & 16 deletions src/V2ex.Blazor.Shared/Pages/FavoriteNodes.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,29 @@

<RefreshView Refresh="LoadAsync">
<ScrollView>
<LoadingBox Load="LoadAsync">
@if (nodeInfo != null)
{
<div class="flex flex-wrap">
@foreach (var item in nodeInfo.Items)
{
@if (nodeInfo != null && nodeInfo.Items.Count > 0 )
{
<LoadingBox Load="LoadAsync">
<div class="flex flex-wrap">
@foreach (var item in nodeInfo.Items)
{
<div class="flex flex-col text-center items-center w-24 text-gray-400 m-4">
<a href="@item.Link" >
<img class="w-24 h-24 rounded-full shadow-md" src="@item.Image" alt="node image" />
<div class="text-ellipsis w-24">@item.Name</div>
<div>@item.Topics</div>
</a>
</div>
}
</div>
}
</LoadingBox>
<a href="@item.Link" >
<img class="w-24 h-24 rounded-full shadow-md" src="@item.Image" alt="node image" />
<div class="text-ellipsis w-24">@item.Name</div>
<div>@item.Topics</div>
</a>
</div>
}
</div>
</LoadingBox>
}
else
{
<div class="flex flex-col items-center text-gray-400 pt-32">
<div>暂无数据</div>
</div>
}
</ScrollView>
</RefreshView>
@code {
Expand Down
Loading

0 comments on commit 4d36bb0

Please sign in to comment.