Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Commit

Permalink
为评论/消息/空间视频添加相对时间显示 (#1110)
Browse files Browse the repository at this point in the history
  • Loading branch information
Richasy authored Apr 23, 2022
1 parent 708c04c commit 0dcb807
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 24 deletions.
20 changes: 0 additions & 20 deletions .github/workflows/release-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ jobs:
$manifest.Package.Identity.Version = "${{github.event.inputs.version}}"
$manifest.save(".\$env:UWP_Project_Directory\Package.appxmanifest")
- name: Build x86
run: msbuild $env:Solution_Path /p:Platform=x86 /p:AppxBundlePlatforms="x86" /p:AppxPackageDir=C:\Package\x86 /p:PackageCertificateKeyFile=$env:SigningCertificate /restore
env:
BuildMode: SideloadOnly
Configuration: Release

- name: Build x64
run: msbuild $env:Solution_Path /p:Platform=x64 /p:AppxBundlePlatforms="x64" /p:AppxPackageDir=C:\Package\x64 /p:PackageCertificateKeyFile=$env:SigningCertificate /restore
env:
Expand All @@ -62,26 +56,12 @@ jobs:
env:
BuildMode: SideloadOnly
Configuration: Release

- name: Create x86 archive
run: Compress-Archive -Path C:\Package\x86\App_${{github.event.inputs.version}}_Test -DestinationPath C:\Package\Bili.Uwp_${{github.event.inputs.version}}_x86.zip

- name: Create x64 archive
run: Compress-Archive -Path C:\Package\x64\App_${{github.event.inputs.version}}_Test -DestinationPath C:\Package\Bili.Uwp_${{github.event.inputs.version}}_x64.zip

- name: Create ARM64 archive
run: Compress-Archive -Path C:\Package\ARM64\App_${{github.event.inputs.version}}_Test -DestinationPath C:\Package\Bili.Uwp_${{github.event.inputs.version}}_ARM64.zip

- name: Update x86 release asset
id: upload-release-asset-x86
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.release-drafter.outputs.upload_url }}
asset_path: C:\Package\Bili.Uwp_${{github.event.inputs.version}}_x86.zip
asset_name: Bili.Uwp_${{github.event.inputs.version}}_x86.zip
asset_content_type: application/zip

- name: Update x64 release asset
id: upload-release-asset-x64
Expand Down
3 changes: 3 additions & 0 deletions src/App/App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,9 @@
<PackageReference Include="FFmpegInteropX">
<Version>0.9.4</Version>
</PackageReference>
<PackageReference Include="Humanizer.Core.zh-CN">
<Version>2.14.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.2.13</Version>
</PackageReference>
Expand Down
3 changes: 2 additions & 1 deletion src/App/Controls/Common/ReplyItem.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using System;
using Bilibili.Main.Community.Reply.V1;
using Humanizer;
using Richasy.Bili.Locator.Uwp;
using Richasy.Bili.Toolkit.Interfaces;
using Richasy.Bili.ViewModels.Uwp;
Expand Down Expand Up @@ -88,7 +89,7 @@ private static void OnDataChanged(DependencyObject d, DependencyPropertyChangedE
instance.UserAvatar.Avatar = data.Member.Face;
instance.LevelImage.Source = new BitmapImage(new Uri($"ms-appx:///Assets/Level/level_{data.Member.Level}.png"));
var time = DateTimeOffset.FromUnixTimeSeconds(data.Ctime).ToLocalTime();
instance.PublishTimeBlock.Text = time.ToString("HH:mm");
instance.PublishTimeBlock.Text = time.Humanize();
ToolTipService.SetToolTip(instance.PublishTimeBlock, time.ToString("yyyy/MM/dd HH:mm:ss"));
instance.LikeButton.IsChecked = data.ReplyControl.Action == 1;
instance.LikeCountBlock.Text = ServiceLocator.Instance.GetService<INumberToolkit>().GetCountText(data.Like);
Expand Down
7 changes: 7 additions & 0 deletions src/App/Controls/Common/VideoCard/VideoCard.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,18 @@
ToolTipService.ToolTip="{loc:LocaleLocator Name=ReplyCount}"
Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=IsShowReplayCount, Converter={StaticResource BoolToVisibilityConverter}}" />
<local:IconTextBlock
Margin="0,0,12,0"
Opacity="0.6"
Symbol="People16"
Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ViewerCount}"
ToolTipService.ToolTip="{loc:LocaleLocator Name=Viewer}"
Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=IsShowViewerCount}" />
<local:IconTextBlock
Opacity="0.6"
Symbol="CalendarLtr16"
Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.PublishDate}"
ToolTipService.ToolTip="{loc:LocaleLocator Name=PublishDate}"
Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=IsShowPublishDateTime}" />
</StackPanel>
<Grid Grid.Row="3" Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=AdditionalFooterContent, Converter={StaticResource ObjectToVisibilityConverter}}">
<ContentPresenter x:Name="AdditionalFooterPresenter" Content="{TemplateBinding AdditionalFooterContent}" />
Expand Down
3 changes: 2 additions & 1 deletion src/App/Controls/Message/AtMessageItem.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using Humanizer;
using Richasy.Bili.Locator.Uwp;
using Richasy.Bili.Toolkit.Interfaces;
using Windows.Foundation;
Expand Down Expand Up @@ -57,7 +58,7 @@ private static void OnDataChanged(DependencyObject d, DependencyPropertyChangedE
instance.DetailBlock.Text = data.Item.SourceContent;
instance.TypeBlock.Text = string.Format(resourceToolkit.GetLocaleString(Models.Enums.LanguageNames.AtMessageTypeDescription), data.Item.Business);
var dateTime = DateTimeOffset.FromUnixTimeSeconds(data.AtTime).ToLocalTime();
instance.TimeBlock.Text = dateTime.ToString("HH:mm");
instance.TimeBlock.Text = dateTime.Humanize();
ToolTipService.SetToolTip(instance.TimeBlock, dateTime.ToString("yyyy/MM/dd HH:mm"));
instance.TitleBlock.Text = string.IsNullOrEmpty(data.Item.Title) ? resourceToolkit.GetLocaleString(Models.Enums.LanguageNames.NoSpecificData) : data.Item.Title;
}
Expand Down
3 changes: 2 additions & 1 deletion src/App/Controls/Message/LikeMessageItem.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using System;
using System.Linq;
using Humanizer;
using Richasy.Bili.Locator.Uwp;
using Richasy.Bili.Toolkit.Interfaces;
using Windows.Foundation;
Expand Down Expand Up @@ -83,7 +84,7 @@ private static void OnDataChanged(DependencyObject d, DependencyPropertyChangedE

instance.DetailBlock.Text = detail;
var dateTime = DateTimeOffset.FromUnixTimeSeconds(data.LikeTime).ToLocalTime();
instance.TimeBlock.Text = dateTime.ToString("HH:mm");
instance.TimeBlock.Text = dateTime.Humanize();
ToolTipService.SetToolTip(instance.TimeBlock, dateTime.ToString("yyyy/MM/dd HH:mm"));
instance.TitleBlock.Text = string.IsNullOrEmpty(data.Item.Title) ? data.Item.Description : data.Item.Title;
}
Expand Down
3 changes: 2 additions & 1 deletion src/App/Controls/Message/ReplyMessageItem.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using Humanizer;
using Richasy.Bili.Locator.Uwp;
using Richasy.Bili.Models.Enums.Bili;
using Richasy.Bili.Toolkit.Interfaces;
Expand Down Expand Up @@ -62,7 +63,7 @@ private static void OnDataChanged(DependencyObject d, DependencyPropertyChangedE
data.Item.Business,
data.Counts);
var dateTime = DateTimeOffset.FromUnixTimeSeconds(data.ReplyTime).ToLocalTime();
instance.TimeBlock.Text = dateTime.ToString("HH:mm");
instance.TimeBlock.Text = dateTime.Humanize();
ToolTipService.SetToolTip(instance.TimeBlock, dateTime.ToString("yyyy/MM/dd HH:mm"));
instance.TitleBlock.Text = string.IsNullOrEmpty(data.Item.Title) ? data.Item.Description : data.Item.Title;
}
Expand Down
1 change: 1 addition & 0 deletions src/App/Controls/User/UserView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
IsShowDanmakuCount="True"
IsShowDuration="True"
IsShowPlayCount="True"
IsShowPublishDateTime="True"
ItemClick="OnVideoCardClick"
Orientation="Horizontal"
ViewModel="{x:Bind}" />
Expand Down
3 changes: 3 additions & 0 deletions src/App/Resources/Strings/zh-CN/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,9 @@ BV号以 BV 开头,是一串英文数字混合的编号, 如 BV1JL4y1875w</v
<data name="PublicServer" xml:space="preserve">
<value>公共服务器</value>
</data>
<data name="PublishDate" xml:space="preserve">
<value>发布时间</value>
</data>
<data name="PublisherApp" xml:space="preserve">
<value>开发者的其它应用</value>
</data>
Expand Down
1 change: 1 addition & 0 deletions src/Models/Models.Enums/App/LanguageNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ public enum LanguageNames
FixContent,
UnfixContent,
StartQuickPlay,
PublishDate,
#pragma warning restore SA1602 // Enumeration items should be documented
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ public partial class VideoViewModel
[Reactive]
public string ViewerCount { get; set; }

/// <summary>
/// 发布时间.
/// </summary>
[Reactive]
public string PublishDate { get; set; }

/// <summary>
/// 发布者.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Bilibili.App.Interfaces.V1;
using Bilibili.App.Show.V1;
using Bilibili.App.View.V1;
using Humanizer;
using Richasy.Bili.Locator.Uwp;
using Richasy.Bili.Models.App.Constants;
using Richasy.Bili.Models.BiliBili;
Expand Down Expand Up @@ -278,6 +279,7 @@ public VideoViewModel(UserSpaceVideoItem item)
DanmakuCount = _numberToolkit.GetCountText(item.DanmakuCount);
Publisher = new UserViewModel(item.PublisherName);
Duration = _numberToolkit.GetDurationText(TimeSpan.FromSeconds(item.Duration));
PublishDate = DateTimeOffset.FromUnixTimeSeconds(item.CreateTime).ToLocalTime().Humanize();
LimitCover(item.Cover);
Source = item;
}
Expand Down
3 changes: 3 additions & 0 deletions src/ViewModels/ViewModels.Uwp/ViewModels.Uwp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@
<PackageReference Include="FFmpegInteropX">
<Version>0.9.4</Version>
</PackageReference>
<PackageReference Include="Humanizer.Core.zh-CN">
<Version>2.14.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection">
<Version>6.0.0</Version>
</PackageReference>
Expand Down

0 comments on commit 0dcb807

Please sign in to comment.