WIn_RustTools/RustTools/ApiFox/user.cs
2024-08-16 18:09:19 +08:00

84 lines
2.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using RustTools.muqing;
using RustTools.Views;
namespace RustTools.ApiFox;
#pragma warning disable CS8981 // 该类型名称仅包含小写 ascii 字符。此类名称可能会成为该语言的保留值。
#pragma warning disable IDE1006 // 命名样式
public class user
{
/// <summary>
/// 登陆
/// </summary>
/// <param name="account"></param>
/// <param name="passWord"></param>
/// <returns></returns>
public static async Task<string> loginPc(string account, string passWord)
{
var pattern = @"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$";
var v = Regex.IsMatch(account, pattern);
//gj.sc(account + " " + v); //这里不知道为什么会出现 True 而不是 true 导致识别邮箱失败
var task = await wl.postAsync("/php/user.php?action=loginPc", new string[][]
{
new[]{ "account",account},
new[]{ "passWord", passWord },
new[]{ "isEmail", v.ToString().ToLower() }
});
return task;
}
/// <summary>
/// 获取信息
/// </summary>
/// <param name="account"></param>
/// <returns></returns>
public static async Task<string> SpaceInfo(string account)
{
var task = await wl.postAsync("/php/user.php?action=getSpaceInfo", new string[][]
{
new[]{ "account",account}
});
return task;
}
/// <summary>
/// 注册
/// </summary>
/// <param name="account"></param>
/// <param name="email"></param>
/// <param name="passWord"></param>
/// <param name="userName"></param>
/// <returns></returns>
public static async Task<string> register(string account,string userName,string passWord,string email)
{
var task = await wl.postAsync("/php/user.php?action=register", new string[][]
{
new []{ "account",account},
new []{ "userName", userName },
new []{ "passWord", passWord },
new []{ "email", email },
new []{ "appID",gj.GetUUID()}
});
return task;
}
public static async Task<string> enableAccount(string account, string key)
{
var task = await wl.postAsync("/php/user.php?action=enableAccount", new string[][]
{
new []{ "account",account},
new []{ "key", key }
});
return task;
}
}