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

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

@@ -5,6 +5,13 @@ namespace CMLeonOS.Commands
{
public static class SettingsCommand
{
private static UserSystem userSystem;
public static void SetUserSystem(UserSystem system)
{
userSystem = system;
}
public static void ProcessSettings(string args)
{
if (string.IsNullOrWhiteSpace(args))
@@ -13,6 +20,12 @@ namespace CMLeonOS.Commands
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);
if (parts.Length == 1)

View File

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