增加功能:设置只有管理员才可以设置

This commit is contained in:
2026-02-06 20:30:20 +08:00
parent 361931c091
commit 96930adf91
3 changed files with 56 additions and 0 deletions

View File

@@ -309,6 +309,48 @@ namespace CMLeonOS
Console.WriteLine("===================================="); Console.WriteLine("====================================");
Console.WriteLine(" First Time Setup"); Console.WriteLine(" First Time Setup");
Console.WriteLine("===================================="); Console.WriteLine("====================================");
Console.WriteLine();
Console.WriteLine("User Terms and Conditions:");
Console.WriteLine("====================================");
Console.WriteLine("1. This operating system is provided as-is without warranty");
Console.WriteLine("2. You are responsible for your data and backups");
Console.WriteLine("3. Unauthorized access attempts may be logged");
Console.WriteLine("4. System administrators have full access to all data");
Console.WriteLine("5. By using this system, you agree to these terms");
Console.WriteLine("6. Data privacy: Your personal data is stored locally");
Console.WriteLine("7. System updates may be installed automatically");
Console.WriteLine("8. No liability for data loss or corruption");
Console.WriteLine("9. Support available at: leonmmcoset@outlook.com");
Console.WriteLine("10. This license is for personal use only");
Console.WriteLine("====================================");
Console.WriteLine();
bool termsAccepted = false;
while (!termsAccepted)
{
Console.Write("Do you accept the User Terms? (yes/no): ");
string response = Console.ReadLine()?.ToLower();
if (response == "yes" || response == "y")
{
termsAccepted = true;
Console.WriteLine("Terms accepted.");
Console.WriteLine();
}
else if (response == "no" || response == "n")
{
Console.WriteLine("You must accept the User Terms to continue.");
Console.WriteLine("Please restart the setup process.");
Thread.Sleep(2000);
Sys.Power.Reboot();
}
else
{
Console.WriteLine("Invalid response. Please enter 'yes' or 'no'.");
}
}
Console.WriteLine("Please set admin username and password:"); Console.WriteLine("Please set admin username and password:");
Console.Write("Username: "); Console.Write("Username: ");

View File

@@ -5,6 +5,13 @@ namespace CMLeonOS.Commands
{ {
public static class SettingsCommand public static class SettingsCommand
{ {
private static UserSystem userSystem;
public static void SetUserSystem(UserSystem system)
{
userSystem = system;
}
public static void ProcessSettings(string args) public static void ProcessSettings(string args)
{ {
if (string.IsNullOrWhiteSpace(args)) if (string.IsNullOrWhiteSpace(args))
@@ -13,6 +20,12 @@ namespace CMLeonOS.Commands
return; return;
} }
if (userSystem == null || userSystem.CurrentLoggedInUser == null || !userSystem.CurrentLoggedInUser.IsAdmin)
{
Console.WriteLine("Error: Only administrators can change settings.");
return;
}
string[] parts = args.Split(new char[] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries); string[] parts = args.Split(new char[] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length == 1) if (parts.Length == 1)

View File

@@ -59,6 +59,7 @@ namespace CMLeonOS
envManager = EnvironmentVariableManager.Instance; envManager = EnvironmentVariableManager.Instance;
Commands.AliasCommand.LoadAliases(); Commands.AliasCommand.LoadAliases();
Commands.SettingsCommand.SetUserSystem(userSystem);
User currentUser = userSystem.CurrentLoggedInUser; User currentUser = userSystem.CurrentLoggedInUser;
if (currentUser != null && !string.IsNullOrWhiteSpace(currentUser.Username)) if (currentUser != null && !string.IsNullOrWhiteSpace(currentUser.Username))