Esempio n. 1
0
 private static async Task LoginIfNeedAsync(Arguments arguments)
 {
     if (string.IsNullOrEmpty(arguments.Account) || string.IsNullOrEmpty(arguments.Password))
     {
         FastConsole.WriteLine("登录可避免出现大部分API错误!!!当前是免登录状态,若软件出错请尝试登录!!!", ConsoleColor.Green);
         FastConsole.WriteLine("强烈建议登录使用软件:\"NLyric.exe -d C:\\Music -a [email protected] -p 123456\"", ConsoleColor.Green);
     }
     else
     {
         FastConsole.WriteLine("登录中...", ConsoleColor.Green);
         if (await _cloudMusic.LoginAsync(arguments.Account, arguments.Password))
         {
             FastConsole.WriteLine("登录成功!", ConsoleColor.Green);
         }
         else
         {
             FastConsole.WriteError("登录失败,输入任意键以免登录模式运行或重新运行尝试再次登录!");
             try {
                 FastConsole.ReadKey(true);
             }
             catch {
             }
         }
     }
     FastConsole.WriteNewLine();
 }
Esempio n. 2
0
        private static async Task LoginIfNeedAsync()
        {
            do
            {
                string userInput;

                Logger.Instance.LogInfo("如果需要登录,请输入Y,反之输入N");
                userInput = Console.ReadLine().Trim().ToUpperInvariant();
                if (userInput == "Y")
                {
                    string account;
                    string password;

                    Console.WriteLine("请输入账号");
                    account = Console.ReadLine();
                    Console.WriteLine("请输入密码");
                    password = Console.ReadLine();
                    if (await CloudMusic.LoginAsync(account, password))
                    {
                        Logger.Instance.LogInfo("登录成功", ConsoleColor.Green);
                        break;
                    }
                    else
                    {
                        Logger.Instance.LogError("登录失败,请重试");
                        Logger.Instance.LogNewLine();
                    }
                }
                else if (userInput == "N")
                {
                    break;
                }
                else
                {
                    Logger.Instance.LogWarning("输入有误,请重新输入!");
                }
            } while (true);
            Logger.Instance.LogNewLine();
        }