diff --git a/src/ZonyLrcTools.Cli/config.yaml b/src/ZonyLrcTools.Cli/config.yaml index a39beee..2592637 100644 --- a/src/ZonyLrcTools.Cli/config.yaml +++ b/src/ZonyLrcTools.Cli/config.yaml @@ -36,7 +36,7 @@ globalOption: plugin: - name: NetEase # 基于网易云音乐的歌词下载器。 priority: 1 # 优先级,升序排列,改为 -1 时禁用。 - depth: 30 # 搜索深度,值越大搜索结果越多,但搜索时间越长。 + depth: 10 # 搜索深度,值越大搜索结果越多,但搜索时间越长。 - name: QQ # 基于 QQ 音乐的歌词下载器。 priority: 2 # depth: 10 # 暂时不支持。 diff --git a/src/ZonyLrcTools.LocalServer/Program.cs b/src/ZonyLrcTools.LocalServer/Program.cs index 8264bac..b9baca1 100644 --- a/src/ZonyLrcTools.LocalServer/Program.cs +++ b/src/ZonyLrcTools.LocalServer/Program.cs @@ -1,25 +1,36 @@ -var builder = WebApplication.CreateBuilder(args); +using ZonyLrcTools.LocalServer; + +var app = RegisterAndConfigureServices(); +await ListenServices(); + +async Task ListenServices() +{ + await new SuperSocketListener().ListenAsync(); + await app?.RunAsync()!; +} + +WebApplication? RegisterAndConfigureServices() +{ + var builder = WebApplication.CreateBuilder(args); // Add services to the container. -builder.Services.AddControllers(); + builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle -builder.Services.AddEndpointsApiExplorer(); -builder.Services.AddSwaggerGen(); + builder.Services.AddEndpointsApiExplorer(); + builder.Services.AddSwaggerGen(); -var app = builder.Build(); + var app = builder.Build(); // Configure the HTTP request pipeline. -if (app.Environment.IsDevelopment()) -{ - app.UseSwagger(); - app.UseSwaggerUI(); -} + if (app.Environment.IsDevelopment()) + { + app.UseSwagger(); + app.UseSwaggerUI(); + } -app.UseHttpsRedirection(); + app.UseAuthorization(); + app.MapControllers(); -app.UseAuthorization(); - -app.MapControllers(); - -app.Run(); \ No newline at end of file + return app; +} \ No newline at end of file diff --git a/src/ZonyLrcTools.LocalServer/Properties/launchSettings.json b/src/ZonyLrcTools.LocalServer/Properties/launchSettings.json index 9ed3509..4621ca5 100644 --- a/src/ZonyLrcTools.LocalServer/Properties/launchSettings.json +++ b/src/ZonyLrcTools.LocalServer/Properties/launchSettings.json @@ -1,28 +1,12 @@ { "$schema": "https://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:49856", - "sslPort": 44367 - } - }, "profiles": { "ZonyLrcTools.LocalServer": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "swagger", - "applicationUrl": "https://localhost:7015;http://localhost:5265", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "swagger", + "applicationUrl": "http://localhost:50002", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/src/ZonyLrcTools.LocalServer/SuperSocketListener.cs b/src/ZonyLrcTools.LocalServer/SuperSocketListener.cs new file mode 100644 index 0000000..72c69fd --- /dev/null +++ b/src/ZonyLrcTools.LocalServer/SuperSocketListener.cs @@ -0,0 +1,15 @@ +using SuperSocket.WebSocket.Server; + +namespace ZonyLrcTools.LocalServer; + +public class SuperSocketListener +{ + public async Task ListenAsync() + { + var host = WebSocketHostBuilder.Create() + .UseWebSocketMessageHandler(async (session, message) => { await session.SendAsync(message.Message); }) + .Build(); + + await host.StartAsync(); + } +} \ No newline at end of file diff --git a/src/ZonyLrcTools.LocalServer/ZonyLrcTools.LocalServer.csproj b/src/ZonyLrcTools.LocalServer/ZonyLrcTools.LocalServer.csproj index ec26747..4329fec 100644 --- a/src/ZonyLrcTools.LocalServer/ZonyLrcTools.LocalServer.csproj +++ b/src/ZonyLrcTools.LocalServer/ZonyLrcTools.LocalServer.csproj @@ -7,6 +7,11 @@ + + + + + @@ -14,4 +19,8 @@ + + + + diff --git a/src/ZonyLrcTools.LocalServer/appsettings.Development.json b/src/ZonyLrcTools.LocalServer/appsettings.Development.json index 0c208ae..a6e86ac 100644 --- a/src/ZonyLrcTools.LocalServer/appsettings.Development.json +++ b/src/ZonyLrcTools.LocalServer/appsettings.Development.json @@ -1,7 +1,7 @@ { "Logging": { "LogLevel": { - "Default": "Information", + "Default": "Debug", "Microsoft.AspNetCore": "Warning" } } diff --git a/src/ZonyLrcTools.LocalServer/appsettings.json b/src/ZonyLrcTools.LocalServer/appsettings.json index 10f68b8..7de5527 100644 --- a/src/ZonyLrcTools.LocalServer/appsettings.json +++ b/src/ZonyLrcTools.LocalServer/appsettings.json @@ -5,5 +5,14 @@ "Microsoft.AspNetCore": "Warning" } }, - "AllowedHosts": "*" + "AllowedHosts": "*", + "serverOptions": { + "name": "ZonyLRcToolsServer", + "listeners": [ + { + "ip": "Any", + "port": 50001 + } + ] + } }