mirror of
https://github.com/jie65535/GrasscutterCommandGenerator.git
synced 2025-06-08 23:19:14 +08:00
Update host url check
This commit is contained in:
parent
6855b6299f
commit
abf970b783
@ -109,14 +109,9 @@ namespace GrasscutterTools.Pages
|
|||||||
/// <param name="host">主机地址</param>
|
/// <param name="host">主机地址</param>
|
||||||
private async Task UpdateServerStatus(string host)
|
private async Task UpdateServerStatus(string host)
|
||||||
{
|
{
|
||||||
// "http://127.0.0.1/" -> "http://127.0.0.1"
|
|
||||||
host = host.TrimEnd('/');
|
|
||||||
var status = await DispatchServerAPI.QueryServerStatus(host);
|
var status = await DispatchServerAPI.QueryServerStatus(host);
|
||||||
LblServerVersion.Text = status.Version;
|
LblServerVersion.Text = status.Version;
|
||||||
if (status.MaxPlayer >= 0)
|
LblPlayerCount.Text = status.MaxPlayer > 0 ? $"{status.PlayerCount}/{status.MaxPlayer}" : status.PlayerCount.ToString();
|
||||||
LblPlayerCount.Text = $"{status.PlayerCount}/{status.MaxPlayer}";
|
|
||||||
else
|
|
||||||
LblPlayerCount.Text = status.PlayerCount.ToString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -137,9 +132,11 @@ namespace GrasscutterTools.Pages
|
|||||||
btn.Cursor = Cursors.WaitCursor;
|
btn.Cursor = Cursors.WaitCursor;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// "http://127.0.0.1/" -> "http://127.0.0.1"
|
||||||
|
var host = TxtHost.Text.TrimEnd('/');
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await UpdateServerStatus(TxtHost.Text);
|
await UpdateServerStatus(host);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -150,7 +147,7 @@ namespace GrasscutterTools.Pages
|
|||||||
var isOcEnabled = false;
|
var isOcEnabled = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Common.OC = new OpenCommandAPI(TxtHost.Text);
|
Common.OC = new OpenCommandAPI(host);
|
||||||
isOcEnabled = await Common.OC.Ping();
|
isOcEnabled = await Common.OC.Ping();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
Loading…
Reference in New Issue
Block a user