Fix chat window opening as library instead of chat
Some checks failed
LANCommander Release / prep (push) Failing after 15s
LANCommander Release / build_server_linux_arm64 (push) Has been skipped
LANCommander Release / build_server_linux_x64 (push) Has been skipped
LANCommander Release / build_server_osx_arm64 (push) Has been skipped
LANCommander Release / build_server_osx_x64 (push) Has been skipped
LANCommander Release / build_server_win_arm64 (push) Has been skipped
LANCommander Release / build_server_win_x64 (push) Has been skipped
LANCommander Release / build_launcher_linux_arm64 (push) Has been skipped
LANCommander Release / build_launcher_linux_x64 (push) Has been skipped
LANCommander Release / build_launcher_osx_arm64 (push) Has been skipped
LANCommander Release / build_launcher_osx_x64 (push) Has been skipped
LANCommander Release / build_launcher_win_arm64 (push) Has been skipped
LANCommander Release / build_launcher_win_x64 (push) Has been skipped
LANCommander Release / build_release (push) Has been skipped
Some checks failed
LANCommander Release / prep (push) Failing after 15s
LANCommander Release / build_server_linux_arm64 (push) Has been skipped
LANCommander Release / build_server_linux_x64 (push) Has been skipped
LANCommander Release / build_server_osx_arm64 (push) Has been skipped
LANCommander Release / build_server_osx_x64 (push) Has been skipped
LANCommander Release / build_server_win_arm64 (push) Has been skipped
LANCommander Release / build_server_win_x64 (push) Has been skipped
LANCommander Release / build_launcher_linux_arm64 (push) Has been skipped
LANCommander Release / build_launcher_linux_x64 (push) Has been skipped
LANCommander Release / build_launcher_osx_arm64 (push) Has been skipped
LANCommander Release / build_launcher_osx_x64 (push) Has been skipped
LANCommander Release / build_launcher_win_arm64 (push) Has been skipped
LANCommander Release / build_launcher_win_x64 (push) Has been skipped
LANCommander Release / build_release (push) Has been skipped
This commit is contained in:
parent
860e5298f9
commit
f31d730bf8
4 changed files with 41 additions and 323 deletions
|
|
@ -1,303 +0,0 @@
|
|||
<<<<<<< HEAD
|
||||
using System.Web;
|
||||
using LANCommander.Launcher.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Photino.Blazor;
|
||||
using Photino.NET;
|
||||
using Serilog;
|
||||
|
||||
namespace LANCommander.Launcher.Startup;
|
||||
|
||||
public static class MainWindow
|
||||
{
|
||||
public static PhotinoBlazorApp RegisterMainWindow(this PhotinoBlazorApp app)
|
||||
{
|
||||
app.MainWindow
|
||||
.SetTitle("LANCommander Launcher")
|
||||
.RegisterWebMessageReceivedHandler(ChatWindowMessageDelegate)
|
||||
.SetChromeless(true);
|
||||
|
||||
app.MainWindow.WindowClosing += SaveWindowPosition;
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
public static PhotinoBlazorApp RegisterMediaHandler(this PhotinoBlazorApp app)
|
||||
{
|
||||
var settingsProvider = app.Services.GetRequiredService<SettingsProvider<Settings.Settings>>();
|
||||
|
||||
app.MainWindow.RegisterCustomSchemeHandler("media",
|
||||
(object sender, string scheme, string url, out string? contentType) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var uri = new Uri(url);
|
||||
|
||||
var query = HttpUtility.ParseQueryString(uri.Query);
|
||||
|
||||
var id = query["id"];
|
||||
var fileId = query["fileId"];
|
||||
var crc32 = query["crc32"];
|
||||
var mime = query["mime"];
|
||||
|
||||
contentType = mime;
|
||||
|
||||
var filePath = Path.Combine(settingsProvider.CurrentValue.Media.StoragePath, $"{fileId}-{crc32}");
|
||||
|
||||
if (File.Exists(filePath))
|
||||
return new FileStream(filePath, FileMode.Open, FileAccess.Read);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Warning(ex, "Unable to load media file from local disk {FileUrl}", url);
|
||||
|
||||
contentType = "";
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
public static PhotinoBlazorApp RegisterNotificationHandler(this PhotinoBlazorApp app)
|
||||
{
|
||||
app.MainWindow.RegisterWebMessageReceivedHandler((sender, message) =>
|
||||
{
|
||||
if (message == "notification")
|
||||
app.MainWindow.SendNotification("Test", "test");
|
||||
});
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
public static PhotinoBlazorApp RegisterImportHandler(this PhotinoBlazorApp app)
|
||||
{
|
||||
app.MainWindow.RegisterWebMessageReceivedHandler(async (sender, message) =>
|
||||
{
|
||||
if (message != "import" || sender is null)
|
||||
return;
|
||||
|
||||
using var scope = app.Services.CreateScope();
|
||||
var importService = scope.ServiceProvider.GetRequiredService<ImportService>();
|
||||
|
||||
var window = (PhotinoWindow)sender;
|
||||
|
||||
await importService.ImportAsync();
|
||||
|
||||
window.SendWebMessage("importComplete");
|
||||
});
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
static void ChatWindowMessageDelegate(object? sender, string message)
|
||||
{
|
||||
if (sender == null)
|
||||
return;
|
||||
|
||||
var parent = (PhotinoWindow)sender;
|
||||
|
||||
if (message == "openChat")
|
||||
{
|
||||
new PhotinoWindow(parent)
|
||||
.SetTitle("LANCommander Chat")
|
||||
.Load("wwwroot/index.html")
|
||||
.WaitForClose();
|
||||
}
|
||||
}
|
||||
|
||||
public static PhotinoBlazorApp RestoreWindowPosition(this PhotinoBlazorApp app)
|
||||
{
|
||||
var settingsProvider = app.Services.GetRequiredService<SettingsProvider<Settings.Settings>>();
|
||||
|
||||
if (settingsProvider.CurrentValue.Window.Maximized)
|
||||
app.MainWindow.SetMaximized(true);
|
||||
else
|
||||
{
|
||||
if (settingsProvider.CurrentValue.Window.Width != 0 && settingsProvider.CurrentValue.Window.Height != 0)
|
||||
{
|
||||
app.MainWindow.SetSize(settingsProvider.CurrentValue.Window.Width, settingsProvider.CurrentValue.Window.Height);
|
||||
app.MainWindow.SetLocation(new System.Drawing.Point(settingsProvider.CurrentValue.Window.X, settingsProvider.CurrentValue.Window.Y));
|
||||
}
|
||||
else
|
||||
{
|
||||
app.MainWindow.SetSize(1024, 768);
|
||||
app.MainWindow.Center();
|
||||
}
|
||||
}
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
private static bool SaveWindowPosition(object sender, EventArgs e)
|
||||
{
|
||||
var window = sender as PhotinoWindow;
|
||||
|
||||
/*var settings = SettingService.GetSettings();
|
||||
|
||||
settings.Window.Maximized = window.Maximized;
|
||||
settings.Window.Width = window.Width;
|
||||
settings.Window.Height = window.Height;
|
||||
settings.Window.X = window.Left;
|
||||
settings.Window.Y = window.Top;
|
||||
|
||||
SettingService.SaveSettings(settings);*/
|
||||
|
||||
return true;
|
||||
}
|
||||
=======
|
||||
using System.Web;
|
||||
using LANCommander.Launcher.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Photino.Blazor;
|
||||
using Photino.NET;
|
||||
|
||||
namespace LANCommander.Launcher.Startup;
|
||||
|
||||
public static class MainWindow
|
||||
{
|
||||
public static PhotinoBlazorApp RegisterMainWindow(this PhotinoBlazorApp app)
|
||||
{
|
||||
app.MainWindow
|
||||
.SetTitle("LANCommander Launcher")
|
||||
.RegisterWebMessageReceivedHandler(ChatWindowMessageDelegate)
|
||||
.SetChromeless(true);
|
||||
|
||||
app.MainWindow.WindowClosing += SaveWindowPosition;
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
public static PhotinoBlazorApp RegisterMediaHandler(this PhotinoBlazorApp app)
|
||||
{
|
||||
var settingsProvider = app.Services.GetRequiredService<SettingsProvider<Settings.Settings>>();
|
||||
var logger = app.Services.GetRequiredService<ILogger<PhotinoBlazorApp>>();
|
||||
|
||||
app.MainWindow.RegisterCustomSchemeHandler("media",
|
||||
(object sender, string scheme, string url, out string? contentType) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var uri = new Uri(url);
|
||||
|
||||
var query = HttpUtility.ParseQueryString(uri.Query);
|
||||
|
||||
var id = query["id"];
|
||||
var fileId = query["fileId"];
|
||||
var crc32 = query["crc32"];
|
||||
var mime = query["mime"];
|
||||
|
||||
contentType = mime;
|
||||
|
||||
var filePath = Path.Combine(settingsProvider.CurrentValue.Media.StoragePath, $"{fileId}-{crc32}");
|
||||
|
||||
if (File.Exists(filePath))
|
||||
return new FileStream(filePath, FileMode.Open, FileAccess.Read);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogWarning(ex, "Unable to load media file from local disk {FileUrl}", url);
|
||||
|
||||
contentType = "";
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
public static PhotinoBlazorApp RegisterNotificationHandler(this PhotinoBlazorApp app)
|
||||
{
|
||||
app.MainWindow.RegisterWebMessageReceivedHandler((sender, message) =>
|
||||
{
|
||||
if (message == "notification")
|
||||
app.MainWindow.SendNotification("Test", "test");
|
||||
});
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
public static PhotinoBlazorApp RegisterImportHandler(this PhotinoBlazorApp app)
|
||||
{
|
||||
app.MainWindow.RegisterWebMessageReceivedHandler(async (sender, message) =>
|
||||
{
|
||||
if (message != "import" || sender is null)
|
||||
return;
|
||||
|
||||
using var scope = app.Services.CreateScope();
|
||||
var importService = scope.ServiceProvider.GetRequiredService<ImportService>();
|
||||
|
||||
var window = (PhotinoWindow)sender;
|
||||
|
||||
await importService.ImportAsync();
|
||||
|
||||
window.SendWebMessage("importComplete");
|
||||
});
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
static void ChatWindowMessageDelegate(object? sender, string message)
|
||||
{
|
||||
if (sender == null)
|
||||
return;
|
||||
|
||||
var parent = (PhotinoWindow)sender;
|
||||
|
||||
if (message == "openChat")
|
||||
{
|
||||
new PhotinoWindow(parent)
|
||||
.SetTitle("LANCommander Chat")
|
||||
.Load("wwwroot/index.html")
|
||||
.WaitForClose();
|
||||
}
|
||||
}
|
||||
|
||||
public static PhotinoBlazorApp RestoreWindowPosition(this PhotinoBlazorApp app)
|
||||
{
|
||||
var settingsProvider = app.Services.GetRequiredService<SettingsProvider<Settings.Settings>>();
|
||||
|
||||
if (settingsProvider.CurrentValue.Window.Maximized)
|
||||
app.MainWindow.SetMaximized(true);
|
||||
else
|
||||
{
|
||||
if (settingsProvider.CurrentValue.Window.Width != 0 && settingsProvider.CurrentValue.Window.Height != 0)
|
||||
{
|
||||
app.MainWindow.SetSize(settingsProvider.CurrentValue.Window.Width, settingsProvider.CurrentValue.Window.Height);
|
||||
app.MainWindow.SetLocation(new System.Drawing.Point(settingsProvider.CurrentValue.Window.X, settingsProvider.CurrentValue.Window.Y));
|
||||
}
|
||||
else
|
||||
{
|
||||
app.MainWindow.SetSize(1024, 768);
|
||||
app.MainWindow.Center();
|
||||
}
|
||||
}
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
private static bool SaveWindowPosition(object sender, EventArgs e)
|
||||
{
|
||||
var window = sender as PhotinoWindow;
|
||||
|
||||
/*var settings = SettingService.GetSettings();
|
||||
|
||||
settings.Window.Maximized = window.Maximized;
|
||||
settings.Window.Width = window.Width;
|
||||
settings.Window.Height = window.Height;
|
||||
settings.Window.X = window.Left;
|
||||
settings.Window.Y = window.Top;
|
||||
|
||||
SettingService.SaveSettings(settings);*/
|
||||
|
||||
return true;
|
||||
}
|
||||
>>>>>>> main
|
||||
}
|
||||
|
|
@ -1,10 +1,13 @@
|
|||
<div class="chat-window">
|
||||
<Router AppAssembly="@typeof(Program).Assembly">
|
||||
<Found Context="routeData">
|
||||
<RouteView RouteData="@routeData" DefaultLayout="@typeof(ChatWindow)" />
|
||||
</Found>
|
||||
<NotFound>
|
||||
<RedirectToRoute Route="/Chat" />
|
||||
</NotFound>
|
||||
</Router>
|
||||
@using LANCommander.Launcher.Enums
|
||||
<div class="chat-window">
|
||||
<CascadingValue Name="WindowType" Value="WindowType.Chat">
|
||||
<Router AppAssembly="@typeof(Program).Assembly">
|
||||
<Found Context="routeData">
|
||||
<RouteView RouteData="@routeData" DefaultLayout="@typeof(ChatWindow)"/>
|
||||
</Found>
|
||||
<NotFound>
|
||||
<RedirectToRoute Route="/Chat"/>
|
||||
</NotFound>
|
||||
</Router>
|
||||
</CascadingValue>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
<div class="main-window">
|
||||
<Router AppAssembly="@typeof(Program).Assembly">
|
||||
<Found Context="routeData">
|
||||
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainWindow)" />
|
||||
</Found>
|
||||
<NotFound>
|
||||
<RedirectToRoute Route="/Authenticate" />
|
||||
</NotFound>
|
||||
</Router>
|
||||
@using LANCommander.Launcher.Enums
|
||||
<div class="main-window">
|
||||
<CascadingValue Name="WindowType" Value="WindowType.Main">
|
||||
<Router AppAssembly="@typeof(Program).Assembly">
|
||||
<Found Context="routeData">
|
||||
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainWindow)"/>
|
||||
</Found>
|
||||
<NotFound>
|
||||
<RedirectToRoute Route="/Authenticate"/>
|
||||
</NotFound>
|
||||
</Router>
|
||||
</CascadingValue>
|
||||
</div>
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
@using Photino.Blazor.CustomWindow.Components
|
||||
@using LANCommander.Launcher.Enums
|
||||
@using Photino.Blazor.CustomWindow.Components
|
||||
@namespace LANCommander.Launcher.UI
|
||||
@inherits LayoutComponentBase
|
||||
@inject AuthenticationClient AuthenticationClient
|
||||
|
|
@ -25,10 +26,24 @@
|
|||
</CustomWindow>
|
||||
|
||||
@code {
|
||||
[CascadingParameter(Name = "WindowType")]
|
||||
public WindowType WindowType { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (await AuthenticationClient.ValidateTokenAsync())
|
||||
NavigationManager.NavigateTo("/Library");
|
||||
{
|
||||
switch (WindowType)
|
||||
{
|
||||
case WindowType.Chat:
|
||||
NavigationManager.NavigateTo("/Chat");
|
||||
break;
|
||||
case WindowType.Main:
|
||||
default:
|
||||
NavigationManager.NavigateTo("/Library");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
NavigationManager.NavigateTo("/Authenticate");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue