diff --git a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Analysis/AppVisitAnalysis.razor b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Analysis/AppVisitAnalysis.razor index e83fe001..2a7049e4 100644 --- a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Analysis/AppVisitAnalysis.razor +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Analysis/AppVisitAnalysis.razor @@ -1,11 +1,12 @@ @page "/analysis/appvisit" +@inherits TscComponentBase - 每@(_interval)分钟刷新一次,上次刷新时间:@_lastRefreshTime.ToString("HH:mm:ss") + 每@(_interval)分钟刷新一次,上次刷新时间:@_lastRefreshTime.Add(CurrentTimeZone.BaseUtcOffset).ToString("HH:mm:ss") @@ -25,53 +26,50 @@ Loading="@_loading" OnClick="@ReloadAll"/> - - @GenAppVisitCard(UvTitle, _uva) + + + + @GenAppVisitCard(UvTitle, _uva) + + + @GenAppVisitCard(UvTitle, _uvta) + + + @GenAppVisitCard(PvTitle, _pva) + + + @GenAliveRate(_aliverate) + + - - @GenAppVisitCard(UvTitle, _uvta) - - - @GenAppVisitCard(PvTitle, _pva) - - - @GenAliveRate(_aliverate) - - + + MinHeight="616"> + Height="@("100%")"> - + - + - + - + @@ -82,7 +80,7 @@ - + @@ -93,7 +91,7 @@ - + diff --git a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Analysis/AppVisitAnalysis.razor.cs b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Analysis/AppVisitAnalysis.razor.cs index 6abacfb5..f5d6e360 100644 --- a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Analysis/AppVisitAnalysis.razor.cs +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Analysis/AppVisitAnalysis.razor.cs @@ -9,7 +9,7 @@ namespace Masa.Tsc.Web.Admin.Rcl.Pages.Analysis { - public partial class AppVisitAnalysis : IDisposable + public partial class AppVisitAnalysis : TscComponentBase { [Inject] private IHttpClientFactory HttpClientFactory { get; set; } = null!; @@ -120,10 +120,10 @@ private void OnIgnoreHomeChanged(bool val) private async Task RefreshMapDataAsync() { - var response = await _graphClient.SendQueryAsync>(GetMapDataQuery()); + var response = await _graphClient.SendQueryAsync>(GetMapDataQuery()); var data = response.Data.Items.Select(x => new { - name = ADCodeName[x.AreaVisit.ADCode], + name = TerminalAnalysisData.ADCodeName[x.AreaVisit.ADCode], value = x.AreaVisit.Pv, uv = x.AreaVisit.Uv, uvt = x.AreaVisit.Uvt @@ -135,7 +135,7 @@ private async Task RefreshMapDataAsync() private async Task RefreshAppVisitHourAsync() { - var response = await _graphClient.SendQueryAsync>(GetAppVisitHourQuery()); + var response = await _graphClient.SendQueryAsync>(GetAppVisitHourQuery()); var x = response.Data.Items.Select(u => u.AppVisitHour.TimeKey).ToArray(); var tuv = response.Data.Items.Select(u => u.AppVisitHour.Tuv).ToArray(); @@ -164,7 +164,7 @@ private async Task RefreshAppVisitPageAsync2() private async Task RefreshAppVisitPageAsync(AppVisitType type) { - var response = await _graphClient.SendQueryAsync>(GetAppVisitPageQuery(type)); + var response = await _graphClient.SendQueryAsync>(GetAppVisitPageQuery(type)); var data = response.Data.Items.Select(x => new { x.AppVisitPage.Path, @@ -191,7 +191,7 @@ private async Task RefreshAppVisitDataAsync() private async Task GetAppVisitAsync(AppVisitType type) { var query = GetAppVisitQuery(type); - var response = await _graphClient.SendQueryAsync>(query); + var response = await _graphClient.SendQueryAsync>(query); return response.Data.Items.First().AppVisit; } @@ -500,6 +500,21 @@ private static int RoundUpToNearest(int value) return (first + 1) * (int)Math.Pow(10, length - 1); } + protected override ValueTask DisposeAsyncCore() + { + _graphClient.Dispose(); + + if (_timer != null) + { + _timer.Stop(); + _timer.Elapsed -= TimerOnElapsed; + _timer.Dispose(); + _timer = null; + } + + return base.DisposeAsyncCore(); + } + private enum AppVisitType { /// @@ -523,8 +538,6 @@ private enum AppVisitType Aliverate } - private record Data([property: JsonPropertyName("cube")] List Items) where T : class; - private record AppVisitItem( [property: JsonPropertyName("appinitvisit")] AppVisit AppVisit); @@ -559,56 +572,5 @@ private record AppVisitPageItem( AppVisitPage AppVisitPage); private record AppVisitPage(string Path, int Count, double Rate); - - private static IReadOnlyDictionary ADCodeName = new Dictionary() - { - { "110000", "北京" }, - { "120000", "天津" }, - { "130000", "河北" }, - { "140000", "山西" }, - { "150000", "内蒙古" }, - { "210000", "辽宁" }, - { "220000", "吉林" }, - { "230000", "黑龙江" }, - { "310000", "上海" }, - { "320000", "江苏" }, - { "330000", "浙江" }, - { "340000", "安徽" }, - { "350000", "福建" }, - { "360000", "江西" }, - { "370000", "山东" }, - { "410000", "河南" }, - { "420000", "湖北" }, - { "430000", "湖南" }, - { "440000", "广东" }, - { "450000", "广西" }, - { "460000", "海南" }, - { "500000", "重庆" }, - { "510000", "四川" }, - { "520000", "贵州" }, - { "530000", "云南" }, - { "540000", "西藏" }, - { "610000", "陕西" }, - { "620000", "甘肃" }, - { "630000", "青海" }, - { "640000", "宁夏" }, - { "650000", "新疆" }, - { "710000", "台湾" }, - { "810000", "香港" }, - { "820000", "澳门" } - }; - - public void Dispose() - { - _graphClient.Dispose(); - - if (_timer != null) - { - _timer.Stop(); - _timer.Elapsed -= TimerOnElapsed; - _timer.Dispose(); - _timer = null; - } - } } } \ No newline at end of file diff --git a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Analysis/CubeData.cs b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Analysis/CubeData.cs new file mode 100644 index 00000000..02dd7e48 --- /dev/null +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Analysis/CubeData.cs @@ -0,0 +1,7 @@ +// Copyright (c) MASA Stack All rights reserved. +// Licensed under the Apache License. See LICENSE.txt in the project root for license information. + +namespace Masa.Tsc.Web.Admin.Rcl.Pages.Analysis +{ + internal record CubeData([property: JsonPropertyName("cube")] List Items) where T : class; +} \ No newline at end of file diff --git a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Analysis/TerminalAnalysis.razor b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Analysis/TerminalAnalysis.razor index f0273dd3..541b28e0 100644 --- a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Analysis/TerminalAnalysis.razor +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Analysis/TerminalAnalysis.razor @@ -91,35 +91,55 @@ @if (_platforms.Count > 0) { - + + + + + } - + @if (_brands.Count > 0) { - + + + + + } - + @if (_appVersions.Count > 0) { - + + + + + } - + @if (_devices.Count > 0) { - + + + + + } - + @if (_models.Count > 0) { - + + + + + } diff --git a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Analysis/TerminalAnalysis.razor.cs b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Analysis/TerminalAnalysis.razor.cs index ce32f660..106f55b2 100644 --- a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Analysis/TerminalAnalysis.razor.cs +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Analysis/TerminalAnalysis.razor.cs @@ -69,12 +69,12 @@ private async Task RefreshBrandECharts() await InvokeAsync(StateHasChanged); } - private async Task> QueryAsync(string type) + private async Task> QueryAsync(string type) { try { var query = GetQuery(type); - var result = await _graphClient.SendQueryAsync(query); + var result = await _graphClient.SendQueryAsync>(query); return result.Data.Items; } catch (Exception e) @@ -208,10 +208,6 @@ private static object GetPieOption(string name, IEnumerable data) { return new { - title = new - { - text = name, - }, tooltip = new { trigger = "item", @@ -261,10 +257,6 @@ private static object GetBarOption(string name, IEnumerable keys, IEnume { return new { - title = new - { - text = name - }, tooltip = new { trigger = "axis", @@ -352,9 +344,7 @@ private GraphQLHttpRequest GetQuery(string type) """); } - private record Data([property: JsonPropertyName("cube")] List Items); - - private record DataItem( + private record DeviceVisitItem( [property: JsonPropertyName("devicevisit")] DeviceVisit DeviceVisit); diff --git a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Analysis/TerminalAnalysisData.cs b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Analysis/TerminalAnalysisData.cs index 4d758518..31becc70 100644 --- a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Analysis/TerminalAnalysisData.cs +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Analysis/TerminalAnalysisData.cs @@ -5,6 +5,44 @@ namespace Masa.Tsc.Web.Admin.Rcl.Pages.Analysis { internal static class TerminalAnalysisData { + internal static IReadOnlyDictionary ADCodeName = new Dictionary() + { + { "110000", "北京" }, + { "120000", "天津" }, + { "130000", "河北" }, + { "140000", "山西" }, + { "150000", "内蒙古" }, + { "210000", "辽宁" }, + { "220000", "吉林" }, + { "230000", "黑龙江" }, + { "310000", "上海" }, + { "320000", "江苏" }, + { "330000", "浙江" }, + { "340000", "安徽" }, + { "350000", "福建" }, + { "360000", "江西" }, + { "370000", "山东" }, + { "410000", "河南" }, + { "420000", "湖北" }, + { "430000", "湖南" }, + { "440000", "广东" }, + { "450000", "广西" }, + { "460000", "海南" }, + { "500000", "重庆" }, + { "510000", "四川" }, + { "520000", "贵州" }, + { "530000", "云南" }, + { "540000", "西藏" }, + { "610000", "陕西" }, + { "620000", "甘肃" }, + { "630000", "青海" }, + { "640000", "宁夏" }, + { "650000", "新疆" }, + { "710000", "台湾" }, + { "810000", "香港" }, + { "820000", "澳门" } + }; + private static readonly string[] EchartsBuiltInColor = ["#5470c6", "#91cc75", "#fac858", "#ee6666", "#73c0de", "#3ba272", "#fc8452", "#9a60b4", "#ea7ccc"]; diff --git a/src/Web/Masa.Tsc.Web.Admin.Rcl/wwwroot/css/tsc.css b/src/Web/Masa.Tsc.Web.Admin.Rcl/wwwroot/css/tsc.css index 21c238cf..83b4a8ad 100644 --- a/src/Web/Masa.Tsc.Web.Admin.Rcl/wwwroot/css/tsc.css +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/wwwroot/css/tsc.css @@ -416,7 +416,7 @@ div[style*="visibility: hidden; opacity: 0;"] { .analysis__filter { padding: 12px; margin: 0 0 8px 0; - border-radius: 4px; + border-radius: 20px; background-color: white; transition: all 0.3s ease; }