Merge remote-tracking branch 'origin/main'

This commit is contained in:
耗子
2026-06-17 18:24:29 +08:00
5 changed files with 323 additions and 298 deletions
+1
View File
@@ -50,6 +50,7 @@ const (
SettingKeyIPDBType SettingKey = "ipdb_type" // "" / "custom" / "subscribe"
SettingKeyIPDBURL SettingKey = "ipdb_url" // 订阅链接
SettingKeyIPDBPath SettingKey = "ipdb_path"
SettingKeyInfoRan SettingKey = "info_ran" // info 命令是否已运行过
)
type Setting struct {
+8 -1
View File
@@ -58,8 +58,15 @@ func (route *Cli) Commands() []*cli.Command {
},
{
Name: "info",
Usage: route.t.Get("Output AcePanel basic information and generate new password"),
Usage: route.t.Get("Output AcePanel basic information"),
Action: route.cli.Info,
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "force",
Aliases: []string{"f"},
Usage: route.t.Get("Force reset password"),
},
},
},
{
Name: "user",
+27 -10
View File
@@ -164,16 +164,29 @@ func (s *CliService) Info(ctx context.Context, cmd *cli.Command) error {
return errors.New(s.t.Get("Failed to get user info: %v", err))
}
password := str.Random(16)
hashed, err := s.hash.Make(password)
if err != nil {
return errors.New(s.t.Get("Failed to generate password: %v", err))
}
user.Username = str.Random(8)
user.Password = hashed
// 判断是否首次运行或使用了 -f 参数
force := cmd.Bool("force")
infoRan, _ := s.settingRepo.Get(biz.SettingKeyInfoRan)
isFirstRun := infoRan == ""
if err = s.db.Save(user).Error; err != nil {
return errors.New(s.t.Get("Failed to save user info: %v", err))
var password string
if isFirstRun || force {
password = str.Random(16)
hashed, err := s.hash.Make(password)
if err != nil {
return errors.New(s.t.Get("Failed to generate password: %v", err))
}
user.Username = str.Random(8)
user.Password = hashed
if err = s.db.Save(user).Error; err != nil {
return errors.New(s.t.Get("Failed to save user info: %v", err))
}
// 标记 info 命令已运行过
if err = s.settingRepo.Set(biz.SettingKeyInfoRan, "1"); err != nil {
return errors.New(s.t.Get("Failed to save setting: %v", err))
}
}
protocol := "http"
@@ -191,7 +204,11 @@ func (s *CliService) Info(ctx context.Context, cmd *cli.Command) error {
}
fmt.Println(s.t.Get("Username: %s", user.Username))
fmt.Println(s.t.Get("Password: %s", password))
if isFirstRun || force {
fmt.Println(s.t.Get("Password: %s", password))
} else {
fmt.Println(s.t.Get("Password: ******* (use -f to force reset)"))
}
fmt.Println(s.t.Get("Port: %d", port))
fmt.Println(s.t.Get("Entrance: %s", entrance))
+6 -6
View File
@@ -57,7 +57,7 @@
"vue": "3.5.38",
"vue-echarts": "8.0.1",
"vue-router": "5.1.0",
"vue3-gettext": "4.0.0",
"vue3-gettext": "4.0.1",
"vuedraggable": "4.1.0"
},
"devDependencies": {
@@ -76,12 +76,12 @@
"cpx2": "9.0.0",
"eslint": "10.5.0",
"eslint-config-prettier": "10.1.8",
"eslint-plugin-oxlint": "1.69.0",
"eslint-plugin-oxlint": "1.70.0",
"eslint-plugin-vue": "10.9.2",
"naive-ui": "2.44.1",
"npm-run-all2": "9.0.2",
"oxfmt": "0.54.0",
"oxlint": "1.69.0",
"oxfmt": "0.55.0",
"oxlint": "1.70.0",
"sass": "1.101.0",
"tsx": "4.22.4",
"typescript": "6.0.3",
@@ -89,12 +89,12 @@
"unplugin-auto-import": "21.0.0",
"unplugin-icons": "23.0.1",
"unplugin-vue-components": "32.1.0",
"vite": "8.0.13",
"vite": "8.0.16",
"vite-plugin-compression2": "2.5.3",
"vite-plugin-html": "3.2.2",
"vite-plugin-mock": "3.0.2",
"vite-plugin-vue-devtools": "8.1.3",
"vue-tsc": "3.3.5"
},
"packageManager": "pnpm@11.6.0+sha512.9a36518224080c6fe5165afdcfe79bfa118c29be703f3f462b1e32efe1e98e47e8750b148e08286250aad4113cc7993ca413c4e2cd447752708c2ee5751bc95f"
"packageManager": "pnpm@11.7.0+sha512.19cc852c120c7125760f2443ee6be0ca5b40f9f50598de1a09a1f177503e010e57c23c77646e01e761de59bf874fb22a3398c33ab9691fc13eb946b6f0f4d620"
}
+281 -281
View File
File diff suppressed because it is too large Load Diff