38 lines
1.0 KiB
C#
38 lines
1.0 KiB
C#
using Microsoft.UI.Xaml;
|
|
using Microsoft.UI.Xaml.Controls;
|
|
using EveryPublish.Client.Services;
|
|
|
|
namespace EveryPublish.Client.Pages;
|
|
|
|
public sealed partial class PairPage : Page
|
|
{
|
|
private ClientContext _ctx = null!;
|
|
|
|
public PairPage()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
protected override void OnNavigatedTo(NavigationEventArgs e)
|
|
{
|
|
_ctx = (ClientContext)e.Parameter;
|
|
_ctx.Core.ReloadLocalJson();
|
|
}
|
|
|
|
private async void Pair_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
var code = CodeBox.Text.Trim();
|
|
var name = NameBox.Text.Trim();
|
|
if (string.IsNullOrEmpty(code))
|
|
{
|
|
PairResult.Text = "请输入配对码";
|
|
return;
|
|
}
|
|
PairButton.IsEnabled = false;
|
|
PairResult.Text = "配对中...";
|
|
var (ok, message) = await _ctx.Core.PairAsync(code, name);
|
|
PairButton.IsEnabled = true;
|
|
PairResult.Text = ok ? "配对成功,正在连接服务器(可到「状态」页查看)" : message;
|
|
}
|
|
}
|