mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-04-19 13:32:24 +00:00
Add webBasePath update feature to CLI (#2300)
This commit is contained in:
parent
bd2d7bce62
commit
c422214ae8
2 changed files with 21 additions and 2 deletions
13
main.go
13
main.go
|
@ -216,7 +216,7 @@ func updateTgbotSetting(tgBotToken string, tgBotChatid string, tgBotRuntime stri
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateSetting(port int, username string, password string) {
|
func updateSetting(port int, username string, password string, webBasePath string) {
|
||||||
err := database.InitDB(config.GetDBPath())
|
err := database.InitDB(config.GetDBPath())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
@ -243,6 +243,15 @@ func updateSetting(port int, username string, password string) {
|
||||||
fmt.Println("set username and password success")
|
fmt.Println("set username and password success")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if webBasePath != "" {
|
||||||
|
err := settingService.SetBasePath(webBasePath)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("set base URI path failed:", err)
|
||||||
|
} else {
|
||||||
|
fmt.Println("set base URI path success")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func migrateDb() {
|
func migrateDb() {
|
||||||
|
@ -357,7 +366,7 @@ func main() {
|
||||||
if reset {
|
if reset {
|
||||||
resetSetting()
|
resetSetting()
|
||||||
} else {
|
} else {
|
||||||
updateSetting(port, username, password)
|
updateSetting(port, username, password, webBasePath)
|
||||||
}
|
}
|
||||||
if show {
|
if show {
|
||||||
showSetting(show)
|
showSetting(show)
|
||||||
|
|
|
@ -352,6 +352,16 @@ func (s *SettingService) GetSecret() ([]byte, error) {
|
||||||
return []byte(secret), err
|
return []byte(secret), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *SettingService) SetBasePath(basePath string) error {
|
||||||
|
if !strings.HasPrefix(basePath, "/") {
|
||||||
|
basePath = "/" + basePath
|
||||||
|
}
|
||||||
|
if !strings.HasSuffix(basePath, "/") {
|
||||||
|
basePath += "/"
|
||||||
|
}
|
||||||
|
return s.setString("webBasePath", basePath)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *SettingService) GetBasePath() (string, error) {
|
func (s *SettingService) GetBasePath() (string, error) {
|
||||||
basePath, err := s.getString("webBasePath")
|
basePath, err := s.getString("webBasePath")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue