diff --git a/src/ZonyLrcTools.Common/ZonyLrcTools.Common.csproj b/src/ZonyLrcTools.Common/ZonyLrcTools.Common.csproj index 259a221..6bdf0cd 100644 --- a/src/ZonyLrcTools.Common/ZonyLrcTools.Common.csproj +++ b/src/ZonyLrcTools.Common/ZonyLrcTools.Common.csproj @@ -16,11 +16,6 @@ - - - - - diff --git a/src/ZonyLrcTools.LocalServer/Contract/Dtos/PagedListRequestDto.cs b/src/ZonyLrcTools.LocalServer/Contract/Dtos/PagedListRequestDto.cs new file mode 100644 index 0000000..77c07ac --- /dev/null +++ b/src/ZonyLrcTools.LocalServer/Contract/Dtos/PagedListRequestDto.cs @@ -0,0 +1,7 @@ +namespace ZonyLrcTools.LocalServer.Contract.Dtos; + +public class PagedListRequestDto +{ + public int PageIndex { get; set; } + public int PageSize { get; set; } +} \ No newline at end of file diff --git a/src/ZonyLrcTools.LocalServer/Contract/Dtos/PagedListResultDto.cs b/src/ZonyLrcTools.LocalServer/Contract/Dtos/PagedListResultDto.cs new file mode 100644 index 0000000..2689077 --- /dev/null +++ b/src/ZonyLrcTools.LocalServer/Contract/Dtos/PagedListResultDto.cs @@ -0,0 +1,9 @@ +namespace ZonyLrcTools.LocalServer.Contract.Dtos; + +public class PagedListResultDto +{ + public int TotalCount { get; set; } + public int PageIndex { get; set; } + public int PageSize { get; set; } + public List Items { get; set; } = new List(); +} \ No newline at end of file diff --git a/src/ZonyLrcTools.LocalServer/Controllers/MusicInfoController.cs b/src/ZonyLrcTools.LocalServer/Controllers/MusicInfoController.cs new file mode 100644 index 0000000..bff56cc --- /dev/null +++ b/src/ZonyLrcTools.LocalServer/Controllers/MusicInfoController.cs @@ -0,0 +1,24 @@ +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> GetMusicInfoListAsync(MusicInfoListInput input) + { + return _musicInfoService.GetMusicInfoListAsync(input); + } +} \ No newline at end of file diff --git a/src/ZonyLrcTools.LocalServer/EventBus/SuperSocketListener.cs b/src/ZonyLrcTools.LocalServer/EventBus/SuperSocketListener.cs new file mode 100644 index 0000000..74e4f7b --- /dev/null +++ b/src/ZonyLrcTools.LocalServer/EventBus/SuperSocketListener.cs @@ -0,0 +1,15 @@ +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(); + } +} \ No newline at end of file diff --git a/src/ZonyLrcTools.LocalServer/Program.cs b/src/ZonyLrcTools.LocalServer/Program.cs index 1f02925..bb97489 100644 --- a/src/ZonyLrcTools.LocalServer/Program.cs +++ b/src/ZonyLrcTools.LocalServer/Program.cs @@ -1,9 +1,17 @@ using System.Diagnostics; -using ZonyLrcTools.LocalServer; +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(); @@ -17,6 +25,7 @@ WebApplication? RegisterAndConfigureServices() builder.Services.AddControllers(); builder.Services.AddEndpointsApiExplorer(); + builder.Services.BeginAutoDependencyInject(); var insideApp = builder.Build(); insideApp.UseSpaStaticFiles(new StaticFileOptions @@ -24,13 +33,14 @@ WebApplication? RegisterAndConfigureServices() RequestPath = "", FileProvider = new Microsoft.Extensions.FileProviders .ManifestEmbeddedFileProvider( - typeof(Program).Assembly, "UiStaticResources" + Assembly.GetExecutingAssembly(), "UiStaticResources" ) }); - insideApp.UseAuthorization(); insideApp.MapControllers(); - // insideApp.Lifetime.ApplicationStarted.Register(OpenBrowser); +#if !DEBUG + insideApp.Lifetime.ApplicationStarted.Register(OpenBrowser); +#endif return insideApp; } @@ -51,4 +61,6 @@ void OpenBrowser() { Process.Start("xdg-open", url); } -} \ No newline at end of file +} + +#endregion \ No newline at end of file diff --git a/src/ZonyLrcTools.LocalServer/Services/MusicInfo/Dtos/MusicInfoListItemDto.cs b/src/ZonyLrcTools.LocalServer/Services/MusicInfo/Dtos/MusicInfoListItemDto.cs new file mode 100644 index 0000000..9556899 --- /dev/null +++ b/src/ZonyLrcTools.LocalServer/Services/MusicInfo/Dtos/MusicInfoListItemDto.cs @@ -0,0 +1,16 @@ +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 +{ +} \ No newline at end of file diff --git a/src/ZonyLrcTools.LocalServer/Services/MusicInfo/IMusicInfoService.cs b/src/ZonyLrcTools.LocalServer/Services/MusicInfo/IMusicInfoService.cs new file mode 100644 index 0000000..ee17aa1 --- /dev/null +++ b/src/ZonyLrcTools.LocalServer/Services/MusicInfo/IMusicInfoService.cs @@ -0,0 +1,9 @@ +using ZonyLrcTools.LocalServer.Contract.Dtos; +using ZonyLrcTools.LocalServer.Services.MusicInfo.Dtos; + +namespace ZonyLrcTools.LocalServer.Services.MusicInfo; + +public interface IMusicInfoService +{ + Task> GetMusicInfoListAsync(MusicInfoListInput input); +} \ No newline at end of file diff --git a/src/ZonyLrcTools.LocalServer/Services/MusicInfo/MusicInfoService.cs b/src/ZonyLrcTools.LocalServer/Services/MusicInfo/MusicInfoService.cs new file mode 100644 index 0000000..87cc527 --- /dev/null +++ b/src/ZonyLrcTools.LocalServer/Services/MusicInfo/MusicInfoService.cs @@ -0,0 +1,38 @@ +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> GetMusicInfoListAsync(MusicInfoListInput input) + { + await Task.CompletedTask; + + return new PagedListResultDto + { + Items = new List + { + new MusicInfoListItemDto + { + Name = "测试歌曲", + Size = 1024, + Status = 1 + }, + new MusicInfoListItemDto + { + Name = "测试歌曲2", + Size = 1024, + Status = 1 + }, + new MusicInfoListItemDto + { + Name = "测试歌曲3", + Size = 1024, + Status = 1 + }, + } + }; + } +} \ No newline at end of file diff --git a/src/ZonyLrcTools.LocalServer/SuperSocketListener.cs b/src/ZonyLrcTools.LocalServer/SuperSocketListener.cs deleted file mode 100644 index d919612..0000000 --- a/src/ZonyLrcTools.LocalServer/SuperSocketListener.cs +++ /dev/null @@ -1,72 +0,0 @@ -using Newtonsoft.Json; -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(JsonConvert.SerializeObject(new CommunicateEvent - { - Action = "output", - Type = ActionType.ResponseAction, - Data = new OutputEvent() - })); - - for (int index = 0; index < 50; index++) - { - var data = new List(); - for (int j = 0; j < 500; j++) - { - data.Add(new GetFileInfoEvent - { - Name = j.ToString(), - Size = j.ToString() - }); - } - - await session.SendAsync(JsonConvert.SerializeObject(new CommunicateEvent> - { - Action = "getFileInfo", - Type = ActionType.ResponseAction, - Data = data - })); - } - - await Task.Delay(100); - }) - .Build(); - - await host.StartAsync(); - } -} - -public class CommunicateEvent where T : class -{ - [JsonProperty("action")] public string? Action { get; set; } - - [JsonProperty("type")] public ActionType Type { get; set; } - - [JsonProperty("data")] public T? Data { get; set; } -} - -public class OutputEvent -{ - [JsonProperty("text")] public string Text => DateTime.Now.ToString("HH:mm:ss"); -} - -public class GetFileInfoEvent -{ - [JsonProperty("name")] public string Name { get; set; } - [JsonProperty("size")] public string Size { get; set; } -} - -public enum ActionType -{ - RequestAction, - ResponseAction -} \ No newline at end of file diff --git a/src/ZonyLrcTools.LocalServer/WeatherForecast.cs b/src/ZonyLrcTools.LocalServer/WeatherForecast.cs deleted file mode 100644 index 2da54ca..0000000 --- a/src/ZonyLrcTools.LocalServer/WeatherForecast.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ZonyLrcTools.LocalServer; - -public class WeatherForecast -{ - public DateTime Date { get; set; } - - public int TemperatureC { get; set; } - - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); - - public string? Summary { get; set; } -} \ No newline at end of file diff --git a/src/ZonyLrcTools.LocalServer/ZonyLrcTools.LocalServer.csproj b/src/ZonyLrcTools.LocalServer/ZonyLrcTools.LocalServer.csproj index c801246..fb754fd 100644 --- a/src/ZonyLrcTools.LocalServer/ZonyLrcTools.LocalServer.csproj +++ b/src/ZonyLrcTools.LocalServer/ZonyLrcTools.LocalServer.csproj @@ -8,6 +8,8 @@ + + @@ -21,7 +23,6 @@ - diff --git a/src/ui/src/router/index.js b/src/ui/src/router/index.js index 8d8a96e..f1b0c1d 100644 --- a/src/ui/src/router/index.js +++ b/src/ui/src/router/index.js @@ -1,6 +1,8 @@ import Vue from 'vue' import VueRouter from 'vue-router' import HomeView from '../views/HomeView.vue' +import AboutView from '../views/AboutView.vue' +import SettingView from "@/views/SettingView" Vue.use(VueRouter) @@ -13,12 +15,12 @@ const routes = [ { path: '/about', name: 'about', - component: () => import( '../views/AboutView.vue') + component: AboutView }, { path: '/setting', name: 'setting', - component: () => import('../views/SettingView.vue') + component: SettingView } ] diff --git a/src/ui/src/views/HomeView.vue b/src/ui/src/views/HomeView.vue index 4da528b..59f48b8 100644 --- a/src/ui/src/views/HomeView.vue +++ b/src/ui/src/views/HomeView.vue @@ -1,5 +1,7 @@ +
@@ -46,14 +50,7 @@ export default { {text: '状态', value: 'status'}, {text: '操作', value: 'action'}, ], - items: [ - { - name: 'Frozen Yogurt', - size: 159, - status: 'success', - action: 4.0, - } - ], + items: [], outputText: '' } }, @@ -70,17 +67,17 @@ export default { // eventBus.$on('getFile', (msgData) => { // console.log(msgData); // }); - eventBus.$on('getFileInfo', (msgData) => { - this.items = [...this.items, ...msgData.data.map(item => { - return { - name: item.name, - size: item.size, - status: 'success', - action: 4.0, - } - })] - }); - + // eventBus.$on('getFileInfo', (msgData) => { + // this.items = [...this.items, ...msgData.data.map(item => { + // return { + // name: item.name, + // size: item.size, + // status: 'success', + // action: 4.0, + // } + // })] + // }); + // eventBus.$on('output', (msgData) => { this.outputText = this.outputText.concat(msgData.data.text).concat('\n'); });