Skip to content

Commit

Permalink
Bump v0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
ProJend committed Oct 16, 2024
1 parent 0503302 commit 826b4d0
Show file tree
Hide file tree
Showing 28 changed files with 110 additions and 658 deletions.
4 changes: 2 additions & 2 deletions BackgroundTasks/BackgroundTasks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<AssemblyName>BackgroundTasks</AssemblyName>
<DefaultLanguage>zh-CN</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.26100.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.15063.0</TargetPlatformMinVersion>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.22621.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
Expand Down
2 changes: 0 additions & 2 deletions BackgroundTasks/TileFeedBackgroundTask.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Diagnostics;
using TrueLove.Lib.Notification;
using Windows.ApplicationModel.Background;
using Windows.UI.Notifications;

namespace BackgroundTasks
{
Expand All @@ -16,7 +15,6 @@ public void Run(IBackgroundTaskInstance taskInstance)
BackgroundTaskDeferral deferral = taskInstance.GetDeferral();

Assembly.Tile(); // 组装动态磁贴
TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);

// Inform the system that the task is finished.
deferral.Complete();
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The building of the project was in progress...
- [Windows10 OS](https://www.microsoft.com/en-us/software-download/windows10) (ARM) : Windows 10 Creators Update (10.0; version 15063) or higher
- &gt;= Windows 1703
- [Visual Studio](https://visualstudio.microsoft.com/downloads/) with UWP : Version 2017 or higher
- [SDK](https://developer.microsoft.com/en-us/windows/downloads/sdk-archive/) : Windows 11 SDK (10.0.26100.0)
- [SDK](https://developer.microsoft.com/en-us/windows/downloads/sdk-archive/) : Windows 11 SDK (10.0.22621.0)
- Can be installed in the Visual Studio Installer as well.

### Installation
Expand Down
8 changes: 4 additions & 4 deletions TrueLove.Lib/Models/Code/CommentCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class CommentCollection : ObservableCollection<CommentItem>, ISupportIncr
public async void LoadMoreItemsManually()
{
CommentParser commentParser = new();
commentParser.ParseCommentWithNetwork(++_pageNumber);
commentParser.ForegroundParseComment(++_pageNumber);
for (int element = 1; element <= 50; element++)
{
var latestItem = await commentParser.Append(element);
Expand All @@ -38,7 +38,7 @@ public async Task<bool> LoadMoreItemsManuallyAsync()
try
{
CommentParser commentParser = new();
commentParser.ParseCommentWithNetwork(++_pageNumber);
commentParser.ForegroundParseComment(++_pageNumber);
for (int element = 1; element <= 99; element++)
{
var latestItem = await commentParser.Append(element);
Expand Down Expand Up @@ -74,7 +74,7 @@ public void Load5ItemsRandomly()
{
List<int> list = [];
CommentParser commentParser = new();
commentParser.ParseComment();
commentParser.BackgroundParseComment(++_pageNumber);
for (int j = 1; j <= 5; j++)
{
Random random = new();
Expand Down Expand Up @@ -109,7 +109,7 @@ async Task<LoadMoreItemsResult> LoadMoreItemsAsyncCore(CancellationToken cancel,
{
// 向集合中添加指定项
CommentParser commentParser = new();
commentParser.ParseComment();
commentParser.BackgroundParseComment(++_pageNumber);
var latestItem = await commentParser.Append(1);
Add(latestItem);
}
Expand Down
8 changes: 4 additions & 4 deletions TrueLove.Lib/Models/Code/ImageCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ImageCollection : ObservableCollection<string>, ISupportIncremental
public async void LoadMoreItemsManually()
{
ImageParser imageParser = new();
imageParser.ParseImageWithNetwork(++_pageNumber);
imageParser.ForegroundParseImage(++_pageNumber);
for (int element = 1; element <= 50; element++)
{
var latestItem = await imageParser.Append(element);
Expand All @@ -31,7 +31,7 @@ public async Task<bool> LoadMoreItemsManuallyAsync()
try
{
ImageParser imageParser = new();
imageParser.ParseImageWithNetwork(++_pageNumber);
imageParser.ForegroundParseImage(++_pageNumber);
for (int element = 1; element <= 99; element++)
{
var latestItem = await imageParser.Append(element);
Expand Down Expand Up @@ -66,7 +66,7 @@ public void Load9ItemsRandomly()
{
List<int> list = [];
ImageParser imageParser = new();
imageParser.ParseImage();
imageParser.BackgroundParseImage(++_pageNumber);
for (int j = 0; j < 9; j++)
{
Random random = new();
Expand Down Expand Up @@ -100,7 +100,7 @@ async Task<LoadMoreItemsResult> LoadMoreItemsAsyncCore(CancellationToken cancel,
else
{
ImageParser imageParser = new();
imageParser.ParseImage();
imageParser.BackgroundParseImage(++_pageNumber);
var latestItem = await imageParser.Append(1);
Add(latestItem);
}
Expand Down
1 change: 0 additions & 1 deletion TrueLove.Lib/Models/Enum/DialogType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
public enum DialogType
{
CommentCreate,
ReleaseNotes,
}
}
8 changes: 1 addition & 7 deletions TrueLove.Lib/Notification/Assembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ public static async void Dialog(DialogType name)
dialogCreate.BorderBrush = (Brush)Application.Current.Resources["SystemControlBackgroundListMediumRevealBorderBrush"];
}
break;

case DialogType.ReleaseNotes:
dialogCreate.Title = "Release Notes";
dialogCreate.CloseButtonText = "Okay";
dialogCreate.Content = new Template.ContentDialog.ReleaseNotes();
dialogCreate.Background = new SolidColorBrush(Colors.Black);
break;
}
try
{
Expand All @@ -57,6 +50,7 @@ public static void Tile()
// Create a tile update manager for the specified syndication feed.
var updater = TileUpdateManager.CreateTileUpdaterForApplication();
updater.Clear();
updater.EnableNotificationQueue(true);

CommentCollection commentCollection = [];
commentCollection.Load5ItemsRandomly();
Expand Down
52 changes: 0 additions & 52 deletions TrueLove.Lib/Notification/Template/ContentDialog/ReleaseNotes.xaml

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion TrueLove.Lib/Notification/Template/Toast.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Toast
public static ToastContent CheckNetwork() => new ToastContentBuilder()
.AddArgument("conversationId", 98143)
.AddText("No Internet Connection")
.AddText("Loading local data.")
.AddText("Loading local data...")
.AddButton(new ToastButton()
.SetContent("Settings")
.AddArgument("action", "settings")
Expand Down
6 changes: 4 additions & 2 deletions TrueLove.Lib/Spider/CommentParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ public class CommentParser
{
string _src;

public void ParseComment()
public void BackgroundParseComment(int _pageNumber)
{
var doctypeGenerator = new DoctypeGenerator();
_src = doctypeGenerator.GetSourceCode(ApplicationData.Current.LocalFolder.Path + @"\Comment.html");
Debug.WriteLine(ApplicationData.Current.LocalFolder.Path + @"\Comment.html");
if (NetworkHelper.Instance.ConnectionInformation.IsInternetAvailable)
_ = doctypeGenerator.SaveSourceCodeAsync($"https://avicii.com/page/{_pageNumber}", "comment");
}

public async void ParseCommentWithNetwork(int _pageNumber)
public async void ForegroundParseComment(int _pageNumber)
{
var doctypeGenerator = new DoctypeGenerator();
_src = doctypeGenerator.GetSourceCode(ApplicationData.Current.LocalFolder.Path + @"\Comment.html");
Expand Down
33 changes: 9 additions & 24 deletions TrueLove.Lib/Spider/DoctypeGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
using System;
using System.IO;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Windows.Storage;

namespace TrueLove.Lib.Spider
{
public class DoctypeGenerator
{
public string GetSourceCode(string path)
{
sourceCode = File.ReadAllText(path);
//TimeToNow();
return sourceCode;
}
public string GetSourceCode(string path) => File.ReadAllText(path);

/// <summary>
///
/// </summary>
/// <param name="path">Use URL address</param>
public async Task<string> SaveSourceCodeAsync(string path, string page)
{
string sourceCode = null;
using var httpClient = new HttpClient();
try
{
sourceCode = await httpClient.GetStringAsync(new Uri(path));
}
catch (HttpRequestException)
do
{
sourceCode = await httpClient.GetStringAsync(new Uri(path));
try
{
sourceCode = await httpClient.GetStringAsync(new Uri(path));
}
catch (HttpRequestException) { }
}
while (sourceCode == null);
var localFolder = ApplicationData.Current.LocalFolder;
if (page == "comment")
{
Expand All @@ -46,16 +42,5 @@ public async Task<string> SaveSourceCodeAsync(string path, string page)
}
return sourceCode;
}

public void TimeToNow()
{
var pattern = @"\d+-\d+-\d+";
var now = DateTime.Now;
var input = now.ToString("yyyy-MM-dd");
Regex regex = new Regex(pattern);
sourceCode = regex.Replace(sourceCode, input);
}

internal string sourceCode;
}
}
6 changes: 4 additions & 2 deletions TrueLove.Lib/Spider/ImageParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ internal class ImageParser
{
string _src;

public void ParseImage()
public void BackgroundParseImage(int _pageNumber)
{
var doctypeGenerator = new DoctypeGenerator();
_src = doctypeGenerator.GetSourceCode(ApplicationData.Current.LocalFolder.Path + @"\Image.html");
Debug.WriteLine(ApplicationData.Current.LocalFolder.Path + @"\Image.html");
if (NetworkHelper.Instance.ConnectionInformation.IsInternetAvailable)
_ = doctypeGenerator.SaveSourceCodeAsync($"https://avicii.com/images/page/{_pageNumber}", "image");
}

public async void ParseImageWithNetwork(int _pageNumber)
public async void ForegroundParseImage(int _pageNumber)
{
var doctypeGenerator = new DoctypeGenerator();
_src = doctypeGenerator.GetSourceCode(ApplicationData.Current.LocalFolder.Path + @"\Image.html");
Expand Down
11 changes: 2 additions & 9 deletions TrueLove.Lib/TrueLove.Lib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<AssemblyName>TrueLove.Lib</AssemblyName>
<DefaultLanguage>zh-CN</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.26100.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.15063.0</TargetPlatformMinVersion>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.22621.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
Expand Down Expand Up @@ -133,9 +133,6 @@
<Compile Include="Notification\Template\ContentDialog\CommentCreate.xaml.cs">
<DependentUpon>CommentCreate.xaml</DependentUpon>
</Compile>
<Compile Include="Notification\Template\ContentDialog\ReleaseNotes.xaml.cs">
<DependentUpon>ReleaseNotes.xaml</DependentUpon>
</Compile>
<Compile Include="Notification\Assembly.cs" />
<Compile Include="Notification\Template\LiveTile.cs" />
<Compile Include="Notification\Template\Toast.cs" />
Expand Down Expand Up @@ -167,10 +164,6 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Notification\Template\ContentDialog\ReleaseNotes.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
Expand Down
15 changes: 5 additions & 10 deletions TrueLove.UWP/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
using Microsoft.QueryStringDotNET;
using System;
using System.IO;
using System.Threading.Tasks;
using TrueLove.Lib.Helpers;
using TrueLove.Lib.Models.Enum;
using TrueLove.UWP.Views;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.ApplicationModel.Core;
using Windows.Storage;
using Windows.UI;
using Windows.UI.Notifications;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
Expand Down Expand Up @@ -91,11 +84,13 @@ protected override async void OnActivated(IActivatedEventArgs e)
Window.Current.Content = root;
}
if (root.Content == null)
{
{
bool loadState = e.PreviousExecutionState == ApplicationExecutionState.Terminated;
ExtendedSplash extendedSplash = new(e.SplashScreen, loadState);
root = new Frame();
root.Content = extendedSplash;
root = new Frame
{
Content = extendedSplash
};
Window.Current.Content = root;
await Task.Delay(50); // 防止初始屏幕闪烁
}
Expand Down
Binary file modified TrueLove.UWP/Assets/Fonts/iconfont.ttf
Binary file not shown.
2 changes: 1 addition & 1 deletion TrueLove.UWP/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
<Identity Name="Avicii.UWP" Publisher="CN=Admin" Version="0.8.0.0" />
<Identity Name="Avicii.UWP" Publisher="CN=Admin" Version="0.9.0.0" />
<mp:PhoneIdentity PhoneProductId="cf0148d5-01bb-4b60-b53b-da3346bf8e5e" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>Avicii.UWP</DisplayName>
Expand Down
Loading

0 comments on commit 826b4d0

Please sign in to comment.