登录连接信息
This commit is contained in:
commit
5c51e96f67
6 files changed
+176
-59
No files matched your search
@@ -66,6 +66,36 @@ namespace SunlightAggregationTerminal.Models
|
||||
|
||||
return userdata;
|
||||
}
|
||||
|
||||
public async static Task<bool> LogIn()
|
||||
{
|
||||
App.GlobalData.LogNo = false;
|
||||
|
||||
//发生登录请求
|
||||
|
||||
// 创建一个 5 秒的延时任务
|
||||
Task delayTask = Task.Delay(15000);
|
||||
// 创建一个监测任务,不断检查变量
|
||||
Task monitorTask = Task.Run(async () =>
|
||||
{
|
||||
while (!App.GlobalData.LogNo)
|
||||
{
|
||||
// 每隔 100 毫秒检查一次,避免 CPU 占用过高
|
||||
await Task.Delay(100);
|
||||
}
|
||||
});
|
||||
// 使用 Task.WhenAny 等待任意一个任务完成
|
||||
await Task.WhenAny(delayTask, monitorTask);
|
||||
|
||||
if (App.GlobalData.LogNo)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetAppUniqueId()
|
||||
{
|
||||
@@ -85,5 +115,25 @@ namespace SunlightAggregationTerminal.Models
|
||||
return id;
|
||||
}
|
||||
|
||||
public static string? GetSERVER()
|
||||
{
|
||||
const string key = "sunlight_server";
|
||||
|
||||
// 尝试从安全存储中读取
|
||||
string? dat = SecureStorage.GetAsync(key).Result;
|
||||
return dat;
|
||||
}
|
||||
public static void GetSERVERWait(string dat)
|
||||
{
|
||||
const string key = "sunlight_server";
|
||||
|
||||
if (string.IsNullOrEmpty(dat))
|
||||
{
|
||||
// 如果不存在,生成一个新的 GUID
|
||||
dat = Guid.NewGuid().ToString();
|
||||
// 保存到安全存储
|
||||
SecureStorage.SetAsync(key, dat).Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user