diff --git a/AppShell.xaml.cs b/AppShell.xaml.cs index d724835..d830ec0 100644 --- a/AppShell.xaml.cs +++ b/AppShell.xaml.cs @@ -22,17 +22,22 @@ namespace SunlightAggregationTerminal await Navigation.PushModalAsync(new NavigationPage(logpage)); } else - { - //发送登录请求 - TcpServer.Configuration(App.GlobalData.ServerID, - App.GlobalData.User, App.GlobalData.UserPassword, - Models.AppModels.GetAppUniqueId()); + { + var loading = new View.Loading(); + await Navigation.PushModalAsync(loading); if (await AppModels.LogIn()) {//拒绝登陆时打开登录页面 + await loading.Navigation.PopModalAsync(); + } + else + { + await loading.Navigation.PopModalAsync(); + var logpage = new View.LogPage(); await Navigation.PushModalAsync(logpage); } + } } } diff --git a/Models/AppModels.cs b/Models/AppModels.cs index 0192343..516021c 100644 --- a/Models/AppModels.cs +++ b/Models/AppModels.cs @@ -40,7 +40,7 @@ namespace SunlightAggregationTerminal.Models App.GlobalData.DarkMode = Convert.ToBoolean(dat.Field("DarkMode")); App.GlobalData.MessageNotificationMode = Convert.ToBoolean(dat.Field("MessageNotificationMode")); - TcpServer.Configuration(App.GlobalData.ServerID, App.GlobalData.User, App.GlobalData.UserPassword, dat.Field("GUID") ?? "Not"); + // TcpServer.Configuration(App.GlobalData.ServerID, App.GlobalData.User, App.GlobalData.UserPassword, dat.Field("GUID") ?? "Not"); } //启动tcp // TcpServer.CreateCustomService(); @@ -76,7 +76,10 @@ namespace SunlightAggregationTerminal.Models { App.GlobalData.LogNo = false; - //发生登录请求 + //发送登录请求 + TcpServer.Configuration(App.GlobalData.ServerID, + App.GlobalData.User, App.GlobalData.UserPassword, + Models.AppModels.GetAppUniqueId()); // 创建一个 15 秒的延时任务 Task delayTask = Task.Delay(15000); @@ -86,7 +89,7 @@ namespace SunlightAggregationTerminal.Models while (!App.GlobalData.LogNo) { // 每隔 100 毫秒检查一次,避免 CPU 占用过高 - await Task.Delay(100); + await Task.Delay(1000); } }); // 使用 Task.WhenAny 等待任意一个任务完成 diff --git a/SunlightAggregationTerminal.csproj b/SunlightAggregationTerminal.csproj index 30979ec..2dea149 100644 --- a/SunlightAggregationTerminal.csproj +++ b/SunlightAggregationTerminal.csproj @@ -116,10 +116,10 @@ MSBuild:Compile - + MSBuild:Compile - + MSBuild:Compile diff --git a/View/Loading.xaml b/View/Loading.xaml new file mode 100644 index 0000000..82bd964 --- /dev/null +++ b/View/Loading.xaml @@ -0,0 +1,21 @@ + + + + + + + + \ No newline at end of file diff --git a/View/Loading.xaml.cs b/View/Loading.xaml.cs new file mode 100644 index 0000000..1dad145 --- /dev/null +++ b/View/Loading.xaml.cs @@ -0,0 +1,9 @@ +namespace SunlightAggregationTerminal.View; + +public partial class Loading : ContentPage +{ + public Loading() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/View/LogPage.xaml.cs b/View/LogPage.xaml.cs index 30f0ae2..a61a803 100644 --- a/View/LogPage.xaml.cs +++ b/View/LogPage.xaml.cs @@ -74,8 +74,8 @@ public partial class LogPage : ContentPage private async void Log_Clicked(object sender, EventArgs e)//登录 { - TcpServer.Configuration(SERVERIP.Text, UsernameEntry.Text, PasswordEntry.Text, - Models.AppModels.GetAppUniqueId()); + //TcpServer.Configuration(SERVERIP.Text, UsernameEntry.Text, PasswordEntry.Text, + // Models.AppModels.GetAppUniqueId()); LoadingIndicator.IsVisible = true; diff --git a/View/LogWindow.xaml b/View/LogWindow.xaml deleted file mode 100644 index 36c1237..0000000 --- a/View/LogWindow.xaml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - -