Browse Source

feat: xcat tool settheme

Cat 3 years ago
parent
commit
6a336d07e5
1 changed files with 16 additions and 1 deletions
  1. 16 1
      src/Command/Tool.php

+ 16 - 1
src/Command/Tool.php

@@ -31,7 +31,8 @@ final class Tool extends Command
 │ ├─ resetAllPort            - 重置所有用户端口
 │ ├─ resetTraffic            - 重置所有用户流量
 │ ├─ generateUUID            - 为所有用户生成新的 UUID
-│ ├─ generateGa              - 为所有用户生成新的 Ga Secret;
+│ ├─ generateGa              - 为所有用户生成新的 Ga Secret
+│ ├─ setTheme                - 为所有用户设置新的主题;
 
 EOL;
 
@@ -348,4 +349,18 @@ EOL;
             echo Hash::cookieHash($user->pass, $expire_in) . ' ' . $expire_in;
         }
     }
+
+    /**
+     * 为所有用户设置新的主题
+     */
+    public function setTheme(): void
+    {
+        fwrite(STDOUT, '请输入要设置的主题名称: ');
+        $theme = trim(fgets(STDIN));
+        $users = ModelsUser::all();
+        foreach ($users as $user) {
+            $user->theme = $theme;
+            $user->save();
+        }
+    }
 }