Skip to content

Commit

Permalink
Merge pull request #1 from DearVa/main
Browse files Browse the repository at this point in the history
* 修复了WebView2的生命周期和透明度问题,进行了跨平台的适配,同时强迫症犯了帮你重构了项目结构
  • Loading branch information
AuroraZiling authored Jul 21, 2024
2 parents c313545 + 22376de commit b50cd85
Show file tree
Hide file tree
Showing 78 changed files with 684 additions and 627 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Hollow.Core.Helpers;
namespace Hollow.Abstractions.JsonConverters;

public class JsonIntToStringConverter: JsonConverter<string>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.IO;
using System.Reflection;
using System.Reflection;

namespace Hollow.Models;
namespace Hollow.Abstractions.Models;

public class AppInfo
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;

namespace Hollow.Models.Configs;
namespace Hollow.Abstractions.Models.Configs;

public class AppConfig
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;

namespace Hollow.Core.Gacha.Common;
namespace Hollow.Abstractions.Models.HttpContrasts.Gacha.Common;

public class GachaItem
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Text.Json.Serialization;
using Hollow.Core.Gacha.Common;
using Hollow.Abstractions.Models.HttpContrasts.Gacha.Common;

namespace Hollow.Core.Gacha;
namespace Hollow.Abstractions.Models.HttpContrasts.Gacha;

public class GachaPage
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Text.Json.Serialization;
using Hollow.Core.Gacha.Common;
using Hollow.Core.Helpers;
using Hollow.Abstractions.JsonConverters;
using Hollow.Abstractions.Models.HttpContrasts.Gacha.Common;

namespace Hollow.Core.Gacha.Uigf;
namespace Hollow.Abstractions.Models.HttpContrasts.Gacha.Uigf;

public class GachaRecords
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;

namespace Hollow.Core.MiHoYoLauncher.Models.Common;
namespace Hollow.Abstractions.Models.HttpContrasts.MiHoYoLauncher.Common;

public class ImageModel
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Text.Json.Serialization;
using Hollow.Core.MiHoYoLauncher.Models.Common;
using Hollow.Abstractions.Models.HttpContrasts.MiHoYoLauncher.Common;

namespace Hollow.Core.MiHoYoLauncher.Models;
namespace Hollow.Abstractions.Models.HttpContrasts.MiHoYoLauncher;

public class ZzzAllGameBasicInfo
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;

namespace Hollow.Core.MiHoYoLauncher.Models;
namespace Hollow.Abstractions.Models.HttpContrasts.MiHoYoLauncher;

public class ZzzAnnouncement
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;

namespace Hollow.Core.MiHoYoLauncher.Models;
namespace Hollow.Abstractions.Models.HttpContrasts.MiHoYoLauncher;

public class ZzzAnnouncementContent
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Text.Json.Serialization;
using Hollow.Core.MiHoYoLauncher.Models.Common;
using Hollow.Abstractions.Models.HttpContrasts.MiHoYoLauncher.Common;

namespace Hollow.Core.MiHoYoLauncher.Models;
namespace Hollow.Abstractions.Models.HttpContrasts.MiHoYoLauncher;


public class ZzzGameContent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Text.Json.Serialization;
using Hollow.Core.MiHoYoLauncher.Models.Common;
using Hollow.Abstractions.Models.HttpContrasts.MiHoYoLauncher.Common;

namespace Hollow.Core.MiHoYoLauncher.Models;
namespace Hollow.Abstractions.Models.HttpContrasts.MiHoYoLauncher;

public class ZzzGameInfo
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Hollow.Models;
namespace Hollow.Abstractions.Models.HttpContrasts;

public struct Response<T>(bool isSuccess, string message="")
public struct Response<T>(bool isSuccess, string message = "")
{
public T Data { get; set; }
public readonly bool IsSuccess = isSuccess;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Hollow.Core.MiHoYoLauncher;
namespace Hollow.Abstractions.Models.MiHoYoLauncher;

public class GameId
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Hollow.Core.MiHoYoLauncher;
namespace Hollow.Abstractions.Models.MiHoYoLauncher;

public class LauncherId
{
Expand Down
File renamed without changes.
27 changes: 27 additions & 0 deletions Hollow.Windows/Hollow.Windows.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<ApplicationManifest>app.manifest</ApplicationManifest>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<TieredPGO>true</TieredPGO>
<TieredCompilationQuickJitForLoops>true</TieredCompilationQuickJitForLoops>
<ApplicationIcon>Assets\Icons\small_icon.ico</ApplicationIcon>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.106">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2646-prerelease"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Hollow\Hollow.csproj"/>
</ItemGroup>

</Project>
9 changes: 9 additions & 0 deletions Hollow.Windows/NativeMethods.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
GetModuleHandle
RegisterClassEx
CreateWindowEx
PostQuitMessage
WM_DESTROY
DefWindowProc
DestroyWindow
GetWindowLong
SetLayeredWindowAttributes
25 changes: 10 additions & 15 deletions Hollow/Program.cs → Hollow.Windows/Program.cs
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
using Avalonia;
using System;
using System.IO;
using Hollow.Models;
using Hollow.Abstractions.Models;
using Hollow.Views.Controls.WebView;
using Hollow.Windows.Services;
using Microsoft.Extensions.DependencyInjection;
using Serilog;

namespace Hollow;
namespace Hollow.Windows;

sealed class Program
public static class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
[STAThread]
public static void Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
.Enrich.WithProperty("Version", AppInfo.AppVersion)
.MinimumLevel.Debug()
.WriteTo.Console(outputTemplate: "{Timestamp:HH:mm:ss} [{Level}] {Message}{NewLine}{Exception}")
.WriteTo.File(Path.Combine(AppInfo.LogDir, "log_.txt"), outputTemplate: "{Timestamp:HH:mm:ss} [{Level}] {Message}{NewLine}{Exception}", rollingInterval: RollingInterval.Day, retainedFileCountLimit: null)
.CreateLogger();

Log.Information("Hollow is starting...");

//TODO: Platform specific
Environment.SetEnvironmentVariable("WEBVIEW2_USER_DATA_FOLDER", AppInfo.CachesDir);

try
{
App.ConfigureServices(x =>
x.AddTransient<IWebViewAdapter, WebView2Adapter>()
);
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
}
catch (Exception e)
Expand Down
Loading

0 comments on commit b50cd85

Please sign in to comment.