mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-08 16:00:26 +08:00
高级设置/数据库/修改:数据库密码中支持特殊字符
This commit is contained in:
@@ -11,7 +11,7 @@ func init() {
|
|||||||
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
||||||
server.
|
server.
|
||||||
Helper(helpers.NewUserMustAuth(configloaders.AdminModuleCodeSetting)).
|
Helper(helpers.NewUserMustAuth(configloaders.AdminModuleCodeSetting)).
|
||||||
Helper(settingutils.NewHelper("backup")).
|
Helper(settingutils.NewAdvancedHelper("backup")).
|
||||||
Prefix("/settings/backup").
|
Prefix("/settings/backup").
|
||||||
Get("", new(IndexAction)).
|
Get("", new(IndexAction)).
|
||||||
EndAll()
|
EndAll()
|
||||||
|
|||||||
@@ -3,15 +3,13 @@ package profile
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/go-sql-driver/mysql"
|
||||||
"github.com/iwind/TeaGo/Tea"
|
"github.com/iwind/TeaGo/Tea"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
"github.com/iwind/TeaGo/dbs"
|
"github.com/iwind/TeaGo/dbs"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/url"
|
|
||||||
"path/filepath"
|
|
||||||
"regexp"
|
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -57,28 +55,33 @@ func (this *UpdateAction) RunGet(params struct{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dsn := dbConfig.Dsn
|
dsn := dbConfig.Dsn
|
||||||
dsn = regexp.MustCompile(`tcp\((.+)\)`).ReplaceAllString(dsn, "$1")
|
cfg, err := mysql.ParseDSN(dsn)
|
||||||
dsnURL, err := url.Parse("mysql://" + dsn)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
this.Data["dbConfig"] = maps.Map{
|
||||||
|
"host": "",
|
||||||
|
"port": "",
|
||||||
|
"username": "",
|
||||||
|
"password": "",
|
||||||
|
"database": "",
|
||||||
|
}
|
||||||
this.Show()
|
this.Show()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
host := dsnURL.Host
|
host := cfg.Addr
|
||||||
port := "3306"
|
port := "3306"
|
||||||
index := strings.LastIndex(dsnURL.Host, ":")
|
index := strings.LastIndex(cfg.Addr, ":")
|
||||||
if index > 0 {
|
if index > 0 {
|
||||||
host = dsnURL.Host[:index]
|
host = cfg.Addr[:index]
|
||||||
port = dsnURL.Host[index+1:]
|
port = cfg.Addr[index+1:]
|
||||||
}
|
}
|
||||||
|
|
||||||
password, _ := dsnURL.User.Password()
|
|
||||||
this.Data["dbConfig"] = maps.Map{
|
this.Data["dbConfig"] = maps.Map{
|
||||||
"host": host,
|
"host": host,
|
||||||
"port": port,
|
"port": port,
|
||||||
"username": dsnURL.User.Username(),
|
"username": cfg.User,
|
||||||
"password": password,
|
"password": cfg.Passwd,
|
||||||
"database": filepath.Base(dsnURL.Path),
|
"database": cfg.DBName,
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Show()
|
this.Show()
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ func (this *AdvancedHelper) BeforeAction(actionPtr actions.ActionWrapper) (goNex
|
|||||||
tabbar.Add("API节点", "", "/api", "", this.tab == "apiNodes")
|
tabbar.Add("API节点", "", "/api", "", this.tab == "apiNodes")
|
||||||
tabbar.Add("用户节点", "", "/settings/userNodes", "", this.tab == "userNodes")
|
tabbar.Add("用户节点", "", "/settings/userNodes", "", this.tab == "userNodes")
|
||||||
tabbar.Add("日志数据库", "", "/db", "", this.tab == "dbNodes")
|
tabbar.Add("日志数据库", "", "/db", "", this.tab == "dbNodes")
|
||||||
|
//tabbar.Add("备份", "", "/settings/backup", "", this.tab == "backup")
|
||||||
}
|
}
|
||||||
actionutils.SetTabbar(actionPtr, tabbar)
|
actionutils.SetTabbar(actionPtr, tabbar)
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ func (this *Helper) BeforeAction(actionPtr actions.ActionWrapper) (goNext bool)
|
|||||||
tabbar.Add("用户界面设置", "", "/settings/user-ui", "", this.tab == "userUI")
|
tabbar.Add("用户界面设置", "", "/settings/user-ui", "", this.tab == "userUI")
|
||||||
tabbar.Add("安全设置", "", "/settings/security", "", this.tab == "security")
|
tabbar.Add("安全设置", "", "/settings/security", "", this.tab == "security")
|
||||||
tabbar.Add("IP库", "", "/settings/ip-library", "", this.tab == "ipLibrary")
|
tabbar.Add("IP库", "", "/settings/ip-library", "", this.tab == "ipLibrary")
|
||||||
tabbar.Add("备份", "", "/settings/backup", "", this.tab == "backup")
|
|
||||||
}
|
}
|
||||||
tabbar.Add("个人资料", "", "/settings/profile", "", this.tab == "profile")
|
tabbar.Add("个人资料", "", "/settings/profile", "", this.tab == "profile")
|
||||||
tabbar.Add("登录设置", "", "/settings/login", "", this.tab == "login")
|
tabbar.Add("登录设置", "", "/settings/login", "", this.tab == "login")
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<first-menu>
|
<first-menu>
|
||||||
<menu-item href="/settings/database" code="index">详情</menu-item>
|
<menu-item href="/settings/database" code="index">详情</menu-item>
|
||||||
<menu-item href="/settings/database/update" code="update">修改</menu-item>
|
<menu-item href="/settings/database/update" code="update">修改</menu-item>
|
||||||
|
<span class="item">|</span>
|
||||||
|
<span class="item"><tip-icon content="在这里可以设置API节点可以使用的数据库,修改后请重新配置并启动API节点才能生效。"></tip-icon></span>
|
||||||
</first-menu>
|
</first-menu>
|
||||||
<div class="margin"></div>
|
<div class="margin"></div>
|
||||||
@@ -32,7 +32,3 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ui message tiny">
|
|
||||||
<p>在这里可以设置API节点可以使用的数据库。</p>
|
|
||||||
</div>
|
|
||||||
Reference in New Issue
Block a user