Initial commit
This commit is contained in:
44
Oqtane.Client/Skins/Controls/Mode.razor
Normal file
44
Oqtane.Client/Skins/Controls/Mode.razor
Normal file
@ -0,0 +1,44 @@
|
||||
@using Oqtane.Skins
|
||||
@using Oqtane.Shared;
|
||||
@using Microsoft.JSInterop
|
||||
@inject IJSRuntime jsRuntime
|
||||
|
||||
@inherits SkinObjectBase
|
||||
|
||||
<button type="button" class="btn btn-primary" onclick="@SetMode">
|
||||
@displayMode
|
||||
</button>
|
||||
|
||||
@functions {
|
||||
string displayMode = "";
|
||||
|
||||
protected override async Task OnInitAsync()
|
||||
{
|
||||
var interop = new Interop(jsRuntime);
|
||||
string value = await interop.GetCookie("blazor");
|
||||
|
||||
if (value == "client")
|
||||
{
|
||||
displayMode = "Server Mode";
|
||||
}
|
||||
else
|
||||
{
|
||||
displayMode = "Client Mode";
|
||||
}
|
||||
}
|
||||
|
||||
public async void SetMode()
|
||||
{
|
||||
var interop = new Interop(jsRuntime);
|
||||
string mode = await interop.GetCookie("blazor");
|
||||
if (mode == "client")
|
||||
{
|
||||
mode = "server";
|
||||
}
|
||||
else
|
||||
{
|
||||
mode = "client";
|
||||
}
|
||||
await interop.SetCookie("blazor", mode, 7);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user