mirror of
https://github.com/real-zony/ZonyLrcToolsX.git
synced 2025-09-04 12:26:52 +00:00
refactor: Removed the local server project.
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
namespace ZonyLrcTools.LocalServer.Contract.Dtos;
|
||||
|
||||
public class PagedListRequestDto
|
||||
{
|
||||
public int PageIndex { get; set; }
|
||||
public int PageSize { get; set; }
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
namespace ZonyLrcTools.LocalServer.Contract.Dtos;
|
||||
|
||||
public class PagedListResultDto<T>
|
||||
{
|
||||
public int TotalCount { get; set; }
|
||||
public int PageIndex { get; set; }
|
||||
public int PageSize { get; set; }
|
||||
public List<T> Items { get; set; } = new List<T>();
|
||||
}
|
@@ -1,24 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ZonyLrcTools.Common.Infrastructure.DependencyInject;
|
||||
using ZonyLrcTools.LocalServer.Contract.Dtos;
|
||||
using ZonyLrcTools.LocalServer.Services.MusicInfo;
|
||||
using ZonyLrcTools.LocalServer.Services.MusicInfo.Dtos;
|
||||
|
||||
namespace ZonyLrcTools.LocalServer.Controllers;
|
||||
|
||||
[Route("api/music-infos")]
|
||||
public class MusicInfoController : Controller, IMusicInfoService, ITransientDependency
|
||||
{
|
||||
private readonly IMusicInfoService _musicInfoService;
|
||||
|
||||
public MusicInfoController(IMusicInfoService musicInfoService)
|
||||
{
|
||||
_musicInfoService = musicInfoService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public Task<PagedListResultDto<MusicInfoListItemDto>> GetMusicInfoListAsync(MusicInfoListInput input)
|
||||
{
|
||||
return _musicInfoService.GetMusicInfoListAsync(input);
|
||||
}
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
using SuperSocket.WebSocket.Server;
|
||||
|
||||
namespace ZonyLrcTools.LocalServer.EventBus;
|
||||
|
||||
public class SuperSocketListener
|
||||
{
|
||||
public async Task ListenAsync()
|
||||
{
|
||||
var host = WebSocketHostBuilder.Create()
|
||||
.UseWebSocketMessageHandler(async (session, message) => { await session.SendAsync(message); })
|
||||
.Build();
|
||||
|
||||
await host.StartAsync();
|
||||
}
|
||||
}
|
@@ -1,66 +0,0 @@
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using ZonyLrcTools.Common.Infrastructure.DependencyInject;
|
||||
using ZonyLrcTools.LocalServer.EventBus;
|
||||
|
||||
#region Main Flow
|
||||
|
||||
var app = RegisterAndConfigureServices();
|
||||
await ListenServices();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Configure Services
|
||||
|
||||
async Task ListenServices()
|
||||
{
|
||||
await new SuperSocketListener().ListenAsync();
|
||||
await app?.RunAsync()!;
|
||||
}
|
||||
|
||||
WebApplication? RegisterAndConfigureServices()
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.WebHost.ConfigureKestrel(k => k.ListenAnyIP(50002));
|
||||
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.BeginAutoDependencyInject<Program>();
|
||||
|
||||
var insideApp = builder.Build();
|
||||
insideApp.UseSpaStaticFiles(new StaticFileOptions
|
||||
{
|
||||
RequestPath = "",
|
||||
FileProvider = new Microsoft.Extensions.FileProviders
|
||||
.ManifestEmbeddedFileProvider(
|
||||
Assembly.GetExecutingAssembly(), "UiStaticResources"
|
||||
)
|
||||
});
|
||||
|
||||
insideApp.MapControllers();
|
||||
#if !DEBUG
|
||||
insideApp.Lifetime.ApplicationStarted.Register(OpenBrowser);
|
||||
#endif
|
||||
|
||||
return insideApp;
|
||||
}
|
||||
|
||||
void OpenBrowser()
|
||||
{
|
||||
const string url = "http://localhost:50002/index.html";
|
||||
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
Process.Start("explorer.exe", url);
|
||||
}
|
||||
else if (OperatingSystem.IsMacOS())
|
||||
{
|
||||
Process.Start("open", url);
|
||||
}
|
||||
else if (OperatingSystem.IsLinux())
|
||||
{
|
||||
Process.Start("xdg-open", url);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"ZonyLrcTools.LocalServer": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "http://localhost:50002",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,16 +0,0 @@
|
||||
using ZonyLrcTools.LocalServer.Contract.Dtos;
|
||||
|
||||
namespace ZonyLrcTools.LocalServer.Services.MusicInfo.Dtos;
|
||||
|
||||
public class MusicInfoListItemDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public int Size { get; set; }
|
||||
|
||||
public int Status { get; set; }
|
||||
}
|
||||
|
||||
public class MusicInfoListInput : PagedListRequestDto
|
||||
{
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
using ZonyLrcTools.LocalServer.Contract.Dtos;
|
||||
using ZonyLrcTools.LocalServer.Services.MusicInfo.Dtos;
|
||||
|
||||
namespace ZonyLrcTools.LocalServer.Services.MusicInfo;
|
||||
|
||||
public interface IMusicInfoService
|
||||
{
|
||||
Task<PagedListResultDto<MusicInfoListItemDto>> GetMusicInfoListAsync(MusicInfoListInput input);
|
||||
}
|
@@ -1,38 +0,0 @@
|
||||
using ZonyLrcTools.Common.Infrastructure.DependencyInject;
|
||||
using ZonyLrcTools.LocalServer.Contract.Dtos;
|
||||
using ZonyLrcTools.LocalServer.Services.MusicInfo.Dtos;
|
||||
|
||||
namespace ZonyLrcTools.LocalServer.Services.MusicInfo;
|
||||
|
||||
public class MusicInfoService : ITransientDependency, IMusicInfoService
|
||||
{
|
||||
public async Task<PagedListResultDto<MusicInfoListItemDto>> GetMusicInfoListAsync(MusicInfoListInput input)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
return new PagedListResultDto<MusicInfoListItemDto>
|
||||
{
|
||||
Items = new List<MusicInfoListItemDto>
|
||||
{
|
||||
new MusicInfoListItemDto
|
||||
{
|
||||
Name = "测试歌曲",
|
||||
Size = 1024,
|
||||
Status = 1
|
||||
},
|
||||
new MusicInfoListItemDto
|
||||
{
|
||||
Name = "测试歌曲2",
|
||||
Size = 1024,
|
||||
Status = 1
|
||||
},
|
||||
new MusicInfoListItemDto
|
||||
{
|
||||
Name = "测试歌曲3",
|
||||
Size = 1024,
|
||||
Status = 1
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@@ -1,36 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper"/>
|
||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection"/>
|
||||
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions"/>
|
||||
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded"/>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting"/>
|
||||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions"/>
|
||||
<PackageReference Include="Serilog.Extensions.Hosting"/>
|
||||
<PackageReference Include="Serilog.Sinks.Console"/>
|
||||
<PackageReference Include="Serilog.Sinks.File"/>
|
||||
<PackageReference Include="SuperSocket.WebSocket"/>
|
||||
<PackageReference Include="SuperSocket.WebSocket.Server"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="UiStaticResources\**"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ZonyLrcTools.Common\ZonyLrcTools.Common.csproj"/>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- <ItemGroup>-->
|
||||
<!-- <ProjectReference Include="..\ZonyLrcTools.Cli\ZonyLrcTools.Cli.csproj" />-->
|
||||
<!-- </ItemGroup>-->
|
||||
|
||||
</Project>
|
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Debug",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"serverOptions": {
|
||||
"name": "ZonyLRcToolsServer",
|
||||
"listeners": [
|
||||
{
|
||||
"ip": "Any",
|
||||
"port": 50001
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user