Skip to content

Commit

Permalink
🆕 feat: add the appvisit analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
capdiem committed Jan 14, 2025
1 parent 049c9f6 commit a57bc68
Show file tree
Hide file tree
Showing 6 changed files with 814 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<PackageReference Include="Humanizer.Core.zh-CN" Version="2.14.1" />
<PackageReference Include="Mapster" Version="7.3.0" />
<!-- <PackageReference Include="Masa.Blazor" Version="1.8.3" />-->
<PackageReference Include="Masa.Stack.Components" Version="0.0.496" />
<PackageReference Include="Masa.Stack.Components" Version="0.0.497" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="$(DotnetVersion)" />
</ItemGroup>

Expand Down
184 changes: 184 additions & 0 deletions src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Analysis/AppVisitAnalysis.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
@page "/analysis/appvisit"

<MRow Dense>
<MCol Cols="12" Class="d-flex align-center justify-end">
<MMenu>
<ActivatorContent>
<MButton Plain Small @attributes="@context.Attrs">
@(_interval)分钟刷新一次,上次刷新时间:@_lastRefreshTime.ToString("HH:mm:ss")
</MButton>
</ActivatorContent>
<ChildContent>
<MList Dense>
<MListItemGroup Value="@_interval"
ValueChanged="@OnIntervalChanged"
Mandatory>
<MListItem Value="5">每5分钟</MListItem>
<MListItem Value="15">每15分钟</MListItem>
<MListItem Value="30">每30分钟</MListItem>
<MListItem Value="60">每60分钟</MListItem>
</MListItemGroup>
</MList>
</ChildContent>
</MMenu>
<MButton IconName="mdi-reload"
Loading="@_loading"
OnClick="@ReloadAll"/>
</MCol>
<MCol Cols="12"
Sm="6"
Md="3">
@GenAppVisitCard(UvTitle, _uva)
</MCol>
<MCol Cols="12"
Sm="6"
Md="3">
@GenAppVisitCard(UvTitle, _uvta)
</MCol>
<MCol Cols="12"
Sm="6"
Md="3">
@GenAppVisitCard(PvTitle, _pva)
</MCol>
<MCol Cols="12"
Sm="6"
Md="3">
@GenAliveRate(_aliverate)
</MCol>
<MCol Cols="12">
<MCard Class="pa-4">
<MECharts Option="@_mapOption"
IncludeFunctionsInOption
Height="600">
</MECharts>
</MCard>
</MCol>
<MCol Cols="12">
<MCard Class="pa-4">
<MECharts Option="_uvOption"
Height="260"/>
</MCard>
</MCol>
<MCol Cols="12">
<MCard Class="pa-4">
<MECharts Option="_uvtOption"
Height="260"/>
</MCard>
</MCol>
<MCol Cols="12">
<MCard Class="pa-4">
<MECharts Option="_pvOption"
Height="260"/>
</MCard>
</MCol>
<MCol Cols="12">
<MCard Class="echarts-card"
Title="@Top10UvTitle">
<MCardText>
@GenPageFilter()
<MECharts Option="_uvPageOption"
IncludeFunctionsInOption
Height="500"/>
</MCardText>
</MCard>
</MCol>
<MCol Cols="12">
<MCard Class="echarts-card"
Title="@Top10UvtTitle">
<MCardText>
@GenPageFilter()
<MECharts Option="_uvtPageOption"
IncludeFunctionsInOption
Height="500"/>
</MCardText>
</MCard>
</MCol>
<MCol Cols="12">
<MCard Class="echarts-card"
Title="@Top10PvTitle">
<MCardText>
@GenPageFilter()
<MECharts Option="_pvPageOption"
IncludeFunctionsInOption
Height="500"/>
</MCardText>
</MCard>
</MCol>
</MRow>

@code {

private static RenderFragment GenAppVisitCard(string title, AppVisit? appVisit) => __builder =>
{
<MCard Class="echarts-card"
Title="@title"
MinHeight="156">
@if (appVisit is not null)
{
<MCardText Class="text-center">
<div class="text-h5">@appVisit!.Data1.ToString("N0")</div>
@GenRate("较昨日", appVisit.Data2)
@GenRate("较七天前", appVisit.Data3)
</MCardText>
}
</MCard>
};

private static RenderFragment GenRate(string label, double rate) => __builder =>
{
var color = rate > 0 ? "success--text" : "error--text";
var icon = rate > 0 ? "mdi-arrow-up" : "mdi-arrow-down";

<div class="subtitle-2">
<span>
@label
</span>
<span class="@color">
<MIcon Style="color: inherit;" Small>@icon</MIcon>
<span>@(rate.ToString("P"))%</span>
</span>
</div>
};

private static RenderFragment GenAliveRate(AppVisit? appVisit) => __builder =>
{
var color = "success--text";

<MCard Title="用户新增及留存"
Class="echarts-card"
MinHeight="156">
@if (appVisit is not null)
{
<MCardText Class="text-center">
<div class="text-h5 @color">
<span class="body-2">留存率:</span>
<span>@appVisit!.Data1.ToString("P")</span>
</div>
<div>日新增用户:@appVisit.Data2</div>
<div>打开次数(新用户):@appVisit.Data3</div>
</MCardText>
}
</MCard>
};

private RenderFragment GenPageFilter() => __builder =>
{
<div class="d-flex align-center justify-end pr-4">
<MCheckbox Value="ignoreLogin"
ValueChanged="OnIgnoreLoginChanged"
TValue="bool"
Label="忽视登录页"
HideDetails="@true"
Class="mt-0 mr-2"
Dense/>
<MCheckbox Value="ignoreHome"
ValueChanged="OnIgnoreHomeChanged"
TValue="bool"
Label="忽视首页"
HideDetails="@true"
Class="mt-0"
Dense/>
</div>
};

}
Loading

0 comments on commit a57bc68

Please sign in to comment.