diff --git a/modules/auth/auth.go b/modules/auth/auth.go index f587a498f..48513831b 100644 --- a/modules/auth/auth.go +++ b/modules/auth/auth.go @@ -161,7 +161,7 @@ type Service struct { P Processor } -func (s *Service) Name() string { +func (*Service) Name() string { return "auth" } diff --git a/modules/config/config.go b/modules/config/config.go index 197a1517c..683d977f5 100644 --- a/modules/config/config.go +++ b/modules/config/config.go @@ -393,7 +393,7 @@ type Config struct { AssetRootPath string `json:"asset_root_path,omitempty" yaml:"asset_root_path,omitempty" ini:"asset_root_path,omitempty"` - URLFormat URLFormat `json:"url_format,omitempty" yaml:"url_format,omitempty" ini:"url_format,omitempty"` + URLFormat *URLFormat `json:"url_format,omitempty" yaml:"url_format,omitempty" ini:"url_format,omitempty"` prefix string `json:"-" yaml:"-" ini:"-"` lock sync.RWMutex `json:"-" yaml:"-" ini:"-"` @@ -438,7 +438,7 @@ type URLFormat struct { Update string `json:"update,omitempty" yaml:"update,omitempty" ini:"update,omitempty"` } -func (f URLFormat) SetDefault() URLFormat { +func (f *URLFormat) SetDefault() { f.Detail = utils.SetDefault(f.Detail, "", "/info/:__prefix/detail") f.ShowEdit = utils.SetDefault(f.ShowEdit, "", "/info/:__prefix/edit") f.ShowCreate = utils.SetDefault(f.ShowCreate, "", "/info/:__prefix/new") @@ -448,13 +448,53 @@ func (f URLFormat) SetDefault() URLFormat { f.Export = utils.SetDefault(f.Export, "", "/export/:__prefix") f.Info = utils.SetDefault(f.Info, "", "/info/:__prefix") f.Update = utils.SetDefault(f.Update, "", "/update/:__prefix") - return f } type ExtraInfo map[string]interface{} type UpdateConfigProcessFn func(values form.Values) (form.Values, error) +// UserConfig type is the user config of goAdmin. +type UserConfig struct { + // user id + UserId int64 `json:"userid",yaml:"userid",ini:"userid"` + + // Used to set as the user language which show in the + // interface. + Language string `json:"language",yaml:"language",ini:"language"` + + // Extend + // ... +} + +var userConfig []UserConfig + +// Set SetUserConfig the config. +func SetUserConfig(uConf UserConfig) { + // insert or update to database, If there is a database + for i := 0; i < len(userConfig); i++ { + if userConfig[i].UserId == uConf.UserId { + userConfig[i] = uConf + return + } + } + userConfig = append(userConfig, uConf) +} + +// Get GetUserConf the config. +func GetUserConf(uId int64) *UserConfig { + for i := 0; i < len(userConfig); i++ { + if userConfig[i].UserId == uId { + return &userConfig[i] + } + } + SetUserConfig(UserConfig{ + UserId: uId, + Language: _global.Language, + }) + return &userConfig[len(userConfig)-1] +} + // see more: https://daneden.github.io/animate.css/ type PageAnimation struct { Type string `json:"type,omitempty" yaml:"type,omitempty" ini:"type,omitempty"` @@ -910,7 +950,8 @@ func SetDefault(cfg *Config) *Config { } else { cfg.prefix = cfg.UrlPrefix } - cfg.URLFormat = cfg.URLFormat.SetDefault() + cfg.URLFormat = new(URLFormat) + cfg.URLFormat.SetDefault() return cfg } @@ -971,8 +1012,8 @@ func AssertPrefix() string { return _global.AssertPrefix() } -// GetIndexURL get the index url with prefix. -func GetIndexURL() string { +// GetFullIndexURL get the index url with prefix. +func GetFullIndexURL() string { return _global.GetIndexURL() } @@ -995,7 +1036,7 @@ func Url(suffix string) string { return _global.Url(suffix) } -func GetURLFormats() URLFormat { +func GetURLFormats() *URLFormat { return _global.URLFormat } @@ -1291,7 +1332,7 @@ type Service struct { C *Config } -func (s *Service) Name() string { +func (*Service) Name() string { return "config" } diff --git a/modules/language/cn.go b/modules/language/cn.go index 708c96f4d..62308a43a 100644 --- a/modules/language/cn.go +++ b/modules/language/cn.go @@ -442,4 +442,6 @@ var cn = LangSet{ "admin.basic admin": "基础Admin", "admin.a built-in plugins of goadmin which help you to build a crud manager platform quickly.": "一个内置GoAdmin插件,帮助您快速搭建curd简易管理后台。", "admin.official": "GoAdmin官方", + + "language": "语言", } diff --git a/modules/language/en.go b/modules/language/en.go index 341f62b98..7286f1ecb 100644 --- a/modules/language/en.go +++ b/modules/language/en.go @@ -405,4 +405,5 @@ var en = LangSet{ "admin.basic admin": "Basic Admin", "admin.a built-in plugins of goadmin which help you to build a crud manager platform quickly.": "A built-in plugins of GoAdmin which help you to build a crud manager platform quickly.", "admin.official": "Official", + "language": "Language", } diff --git a/modules/language/jp.go b/modules/language/jp.go index f7164402c..70d916bc9 100644 --- a/modules/language/jp.go +++ b/modules/language/jp.go @@ -416,4 +416,10 @@ var jp = LangSet{ "admin.basic admin": "Basic Admin", "admin.a built-in plugins of goadmin which help you to build a crud manager platform quickly.": "A built-in plugins of GoAdmin which help you to build a crud manager platform quickly.", "admin.official": "Official", + + "used for login": "ログインに使用", + "used to display": "表示に使用", + "a path a line": "パスの文字列", + + "language": "言語", } diff --git a/modules/language/language.go b/modules/language/language.go index 11539fb7a..4aab563cf 100644 --- a/modules/language/language.go +++ b/modules/language/language.go @@ -160,3 +160,34 @@ func JoinScopes(scopes []string) string { } return j } + +// GetUser return the value of user scope. +func GetUser(value string, uid int64) string { + return GetUserWithScope(value, uid) +} + +// GetUserWithScope return the value of given scopes. +func GetUserWithScope(value string, uid int64, scopes ...string) string { + if config.GetUserConf(uid).Language == "" { + return value + } + + if locale, ok := Lang[config.GetUserConf(uid).Language][JoinScopes(scopes)+strings.ToLower(value)]; ok { + return locale + } + + return value +} + +// GetUserFromHtml return the value of given scopes and template.HTML value. +func GetUserFromHtml(value template.HTML, uid int64, scopes ...string) template.HTML { + if config.GetUserConf(uid).Language == "" { + return value + } + + if locale, ok := Lang[config.GetUserConf(uid).Language][JoinScopes(scopes)+strings.ToLower(string(value))]; ok { + return template.HTML(locale) + } + + return value +} diff --git a/modules/language/tc.go b/modules/language/tc.go index af38a1bde..9514fbd9b 100644 --- a/modules/language/tc.go +++ b/modules/language/tc.go @@ -434,4 +434,5 @@ var tc = LangSet{ "admin.basic admin": "基礎Admin", "admin.a built-in plugins of goadmin which help you to build a crud manager platform quickly.": "壹個內置GoAdmin插件,幫助您快速搭建curd簡易管理後臺。", "admin.official": "GoAdmin官方", + "language": "語言", } diff --git a/modules/menu/menu.go b/modules/menu/menu.go index aa78964fa..4d1110be7 100644 --- a/modules/menu/menu.go +++ b/modules/menu/menu.go @@ -203,14 +203,19 @@ func GetGlobalMenu(user models.UserModel, conn db.Connection, lang string, plugi var title string for i := 0; i < len(menus); i++ { - title = language.GetWithLang(menus[i]["title"].(string), lang) + if menus[i]["type"].(int64) == 1 { + title = language.GetUser(menus[i]["title"].(string), user.Id) + } else { + title = language.GetWithLang(menus[i]["title"].(string), lang) + } + menuOption = append(menuOption, map[string]string{ "id": strconv.FormatInt(menus[i]["id"].(int64), 10), "title": title, }) } - menuList := constructMenuTree(menus, 0, lang) + menuList := constructMenuTree(menus, 0, lang, user.Id) maxOrder := int64(0) if len(menus) > 0 { maxOrder = menus[len(menus)-1]["parent_id"].(int64) @@ -224,15 +229,16 @@ func GetGlobalMenu(user models.UserModel, conn db.Connection, lang string, plugi } } -func constructMenuTree(menus []map[string]interface{}, parentID int64, lang string) []Item { +func constructMenuTree(menus []map[string]interface{}, parentID int64, lang string, uid int64) []Item { branch := make([]Item, 0) var title string for j := 0; j < len(menus); j++ { if parentID == menus[j]["parent_id"].(int64) { + if menus[j]["type"].(int64) == 1 { - title = language.Get(menus[j]["title"].(string)) + title = language.GetUser(menus[j]["title"].(string), uid) } else { title = menus[j]["title"].(string) } @@ -256,7 +262,7 @@ func constructMenuTree(menus []map[string]interface{}, parentID int64, lang stri Icon: menus[j]["icon"].(string), Header: header, Active: "", - ChildrenList: constructMenuTree(menus, menus[j]["id"].(int64), lang), + ChildrenList: constructMenuTree(menus, menus[j]["id"].(int64), lang, uid), } branch = append(branch, child) diff --git a/modules/ui/ui.go b/modules/ui/ui.go index 5d8bd194b..0ff4e0ae5 100644 --- a/modules/ui/ui.go +++ b/modules/ui/ui.go @@ -15,7 +15,7 @@ type Service struct { const ServiceKey = "ui" -func (s *Service) Name() string { +func (*Service) Name() string { return "ui" } diff --git a/plugins/admin/admin.go b/plugins/admin/admin.go index a2631a65a..a703695a9 100644 --- a/plugins/admin/admin.go +++ b/plugins/admin/admin.go @@ -65,7 +65,7 @@ func (admin *Admin) InitPlugin(services service.List) { } func (admin *Admin) GetIndexURL() string { - return config.GetIndexURL() + return config.GetFullIndexURL() } func (admin *Admin) GetInfo() plugins.Info { diff --git a/plugins/admin/controller/api_list.go b/plugins/admin/controller/api_list.go index 0ece61e86..2e5b22f90 100644 --- a/plugins/admin/controller/api_list.go +++ b/plugins/admin/controller/api_list.go @@ -15,7 +15,7 @@ func (h *Handler) ApiList(ctx *context.Context) { params := parameter.GetParam(ctx.Request.URL, panel.GetInfo().DefaultPageSize, panel.GetInfo().SortField, panel.GetInfo().GetSort()) - panel, panelInfo, urls, err := h.showTableData(ctx, prefix, params, panel, "api_") + panel, panelInfo, urls, err := h._showTableData(ctx, prefix, params, panel, "api_") if err != nil { response.Error(ctx, err.Error()) return diff --git a/plugins/admin/controller/detail.go b/plugins/admin/controller/detail.go index ab10ebd86..5d3169816 100644 --- a/plugins/admin/controller/detail.go +++ b/plugins/admin/controller/detail.go @@ -118,18 +118,21 @@ $('.delete-btn').on('click', function (event) { desc := "" isNotIframe := ctx.Query(constant.IframeKey) != "true" + if title == "" { + title = panel.GetInfo().Title + language.GetUser("Detail", user.Id) + } if isNotIframe { title = detail.Title if title == "" { - title = info.Title + language.Get("Detail") + title = info.Title + language.GetUser("Detail", user.Id) } desc = detail.Description if desc == "" { - desc = info.Description + language.Get("Detail") + desc = info.Description + language.GetUser("Detail", user.Id) } } diff --git a/plugins/admin/controller/edit.go b/plugins/admin/controller/edit.go index 1a6e1ca4d..cd371cd34 100644 --- a/plugins/admin/controller/edit.go +++ b/plugins/admin/controller/edit.go @@ -6,6 +6,7 @@ import ( "net/http" "net/url" + "github.com/GoAdminGroup/go-admin/modules/language" "github.com/GoAdminGroup/go-admin/modules/logger" "github.com/GoAdminGroup/go-admin/template" @@ -15,7 +16,6 @@ import ( "github.com/GoAdminGroup/go-admin/context" "github.com/GoAdminGroup/go-admin/modules/auth" "github.com/GoAdminGroup/go-admin/modules/file" - "github.com/GoAdminGroup/go-admin/modules/language" "github.com/GoAdminGroup/go-admin/plugins/admin/modules" "github.com/GoAdminGroup/go-admin/plugins/admin/modules/constant" form2 "github.com/GoAdminGroup/go-admin/plugins/admin/modules/form" @@ -28,10 +28,10 @@ import ( // ShowForm show form page. func (h *Handler) ShowForm(ctx *context.Context) { param := guard.GetShowFormParam(ctx) - h.showForm(ctx, "", param.Prefix, param.Param, false) + h._showForm(ctx, "", param.Prefix, param.Param, false) } -func (h *Handler) showForm(ctx *context.Context, alert template2.HTML, prefix string, param parameter.Parameters, isEdit bool, animation ...bool) { +func (h *Handler) _showForm(ctx *context.Context, alert template2.HTML, prefix string, param parameter.Parameters, isEdit bool, animation ...bool) { panel := h.table(prefix, ctx) @@ -147,7 +147,7 @@ func (h *Handler) EditForm(ctx *context.Context) { if ctx.WantJSON() { response.Error(ctx, err.Error()) } else { - h.showForm(ctx, aAlert().Warning(err.Error()), param.Prefix, param.Param, true) + h._showForm(ctx, aAlert().Warning(err.Error()), param.Prefix, param.Param, true) } return } @@ -177,7 +177,7 @@ func (h *Handler) EditForm(ctx *context.Context) { "token": h.authSrv().AddToken(), }) } else { - h.showForm(ctx, aAlert().Warning(err.Error()), param.Prefix, param.Param, true) + h._showForm(ctx, aAlert().Warning(err.Error()), param.Prefix, param.Param, true) } return } @@ -203,7 +203,7 @@ func (h *Handler) EditForm(ctx *context.Context) { } if isEditUrl(param.PreviousPath, param.Prefix) { - h.showForm(ctx, param.Alert, param.Prefix, param.Param, true, false) + h._showForm(ctx, param.Alert, param.Prefix, param.Param, true, false) return } @@ -223,7 +223,7 @@ func (h *Handler) EditForm(ctx *context.Context) { return } - buf := h.showTable(ctx, param.Prefix, param.Param.DeletePK().DeleteEditPk(), nil) + buf := h._showTable(ctx, param.Prefix, param.Param.DeletePK().DeleteEditPk(), nil) ctx.HTML(http.StatusOK, buf.String()) ctx.AddHeader(constant.PjaxUrlHeader, param.PreviousPath) diff --git a/plugins/admin/controller/new.go b/plugins/admin/controller/new.go index 4d840a1c9..53d0c5635 100644 --- a/plugins/admin/controller/new.go +++ b/plugins/admin/controller/new.go @@ -164,7 +164,7 @@ func (h *Handler) NewForm(ctx *context.Context) { return } - buf := h.showTable(ctx, param.Prefix, param.Param, nil) + buf := h._showTable(ctx, param.Prefix, param.Param, nil) ctx.HTML(http.StatusOK, buf.String()) ctx.AddHeader(constant.PjaxUrlHeader, h.routePathWithPrefix("info", param.Prefix)+param.Param.GetRouteParamStr()) diff --git a/plugins/admin/controller/show.go b/plugins/admin/controller/show.go index 303906ae4..3e238caf4 100644 --- a/plugins/admin/controller/show.go +++ b/plugins/admin/controller/show.go @@ -57,11 +57,11 @@ func (h *Handler) ShowInfo(ctx *context.Context) { params := parameter.GetParam(ctx.Request.URL, panel.GetInfo().DefaultPageSize, panel.GetInfo().SortField, panel.GetInfo().GetSort()) - buf := h.showTable(ctx, prefix, params, panel) + buf := h._showTable(ctx, prefix, params, panel) ctx.HTML(http.StatusOK, buf.String()) } -func (h *Handler) showTableData(ctx *context.Context, prefix string, params parameter.Parameters, +func (h *Handler) _showTableData(ctx *context.Context, prefix string, params parameter.Parameters, panel table.Table, urlNamePrefix string) (table.Table, table.PanelInfo, []string, error) { if panel == nil { panel = h.table(prefix, ctx) @@ -97,9 +97,9 @@ func (h *Handler) showTableData(ctx *context.Context, prefix string, params para return panel, panelInfo, []string{editUrl, newUrl, deleteUrl, exportUrl, detailUrl, infoUrl, updateUrl}, nil } -func (h *Handler) showTable(ctx *context.Context, prefix string, params parameter.Parameters, panel table.Table) *bytes.Buffer { +func (h *Handler) _showTable(ctx *context.Context, prefix string, params parameter.Parameters, panel table.Table) *bytes.Buffer { - panel, panelInfo, urls, err := h.showTableData(ctx, prefix, params, panel, "") + panel, panelInfo, urls, err := h._showTableData(ctx, prefix, params, panel, "") if err != nil { return h.Execute(ctx, auth.Auth(ctx), template.WarningPanelWithDescAndTitle(err.Error(), errors.Msg, errors.Msg), "", @@ -137,7 +137,7 @@ func (h *Handler) showTable(ctx *context.Context, prefix string, params paramete ext := template2.HTML("") if deleteUrl != "" { ext = html.LiEl().SetClass("divider").Get() - allActionBtns = append([]types.Button{types.GetActionButton(language.GetFromHtml("delete"), + allActionBtns = append([]types.Button{types.GetActionButton(language.GetUserFromHtml("delete", user.Id), types.NewDefaultAction(`data-id='{{.Id}}' data-param='{{(index .Value "__goadmin_delete_params").Content}}' style="cursor: pointer;"`, ext, "", ""), "grid-row-delete")}, allActionBtns...) } @@ -146,14 +146,14 @@ func (h *Handler) showTable(ctx *context.Context, prefix string, params paramete if editUrl == "" && deleteUrl == "" { ext = html.LiEl().SetClass("divider").Get() } - allActionBtns = append([]types.Button{types.GetActionButton(language.GetFromHtml("detail"), + allActionBtns = append([]types.Button{types.GetActionButton(language.GetUserFromHtml("detail", user.Id), action.Jump(detailUrl+"&"+constant.DetailPKKey+`={{.Id}}{{(index .Value "__goadmin_detail_params").Content}}`, ext))}, allActionBtns...) } if editUrl != "" { if detailUrl == "" && deleteUrl == "" { ext = html.LiEl().SetClass("divider").Get() } - allActionBtns = append([]types.Button{types.GetActionButton(language.GetFromHtml("edit"), + allActionBtns = append([]types.Button{types.GetActionButton(language.GetUserFromHtml("edit", user.Id), action.Jump(editUrl+"&"+constant.EditPKKey+`={{.Id}}{{(index .Value "__goadmin_edit_params").Content}}`, ext))}, allActionBtns...) } diff --git a/plugins/admin/modules/response/response.go b/plugins/admin/modules/response/response.go index 33706a46d..39a1223bb 100644 --- a/plugins/admin/modules/response/response.go +++ b/plugins/admin/modules/response/response.go @@ -10,6 +10,7 @@ import ( "github.com/GoAdminGroup/go-admin/modules/errors" "github.com/GoAdminGroup/go-admin/modules/language" "github.com/GoAdminGroup/go-admin/modules/menu" + "github.com/GoAdminGroup/go-admin/plugins/admin/models" "github.com/GoAdminGroup/go-admin/template" "github.com/GoAdminGroup/go-admin/template/types" ) @@ -37,9 +38,14 @@ func OkWithData(ctx *context.Context, data map[string]interface{}) { } func BadRequest(ctx *context.Context, msg string) { + var user = models.UserModel{} + var ok bool + if user, ok = ctx.UserValue["user"].(models.UserModel); !ok { + user.Id = -1 + } ctx.JSON(http.StatusBadRequest, map[string]interface{}{ "code": http.StatusBadRequest, - "msg": language.Get(msg), + "msg": language.GetUser(msg, user.Id), }) } @@ -75,9 +81,10 @@ func Alert(ctx *context.Context, desc, title, msg string, conn db.Connection, bt } func Error(ctx *context.Context, msg string, datas ...map[string]interface{}) { + user := ctx.UserValue["user"].(models.UserModel) res := map[string]interface{}{ "code": http.StatusInternalServerError, - "msg": language.Get(msg), + "msg": language.GetUser(msg, user.Id), } if len(datas) > 0 { res["data"] = datas[0] @@ -86,9 +93,10 @@ func Error(ctx *context.Context, msg string, datas ...map[string]interface{}) { } func Denied(ctx *context.Context, msg string) { + user := ctx.UserValue["user"].(models.UserModel) ctx.JSON(http.StatusInternalServerError, map[string]interface{}{ "code": http.StatusForbidden, - "msg": language.Get(msg), + "msg": language.GetUser(msg, user.Id), }) } diff --git a/plugins/admin/modules/table/generators.go b/plugins/admin/modules/table/generators.go index 40b76ea45..8dfcf9f10 100644 --- a/plugins/admin/modules/table/generators.go +++ b/plugins/admin/modules/table/generators.go @@ -43,7 +43,7 @@ func NewSystemTable(conn db.Connection, c *config.Config) *SystemTable { return &SystemTable{conn: conn, c: c} } -func (s *SystemTable) GetManagerTable(ctx *context.Context) (managerTable Table) { +func (s *SystemTable) GetManagerTable(_ *context.Context) (managerTable Table) { managerTable = NewDefaultTable(DefaultConfigWithDriver(config.GetDatabases().GetDefault().Driver)) info := managerTable.GetInfo().AddXssJsFilter().HideFilterArea() @@ -352,7 +352,7 @@ func (s *SystemTable) GetManagerTable(ctx *context.Context) (managerTable Table) return } -func (s *SystemTable) GetNormalManagerTable(ctx *context.Context) (managerTable Table) { +func (s *SystemTable) GetNormalManagerTable(_ *context.Context) (managerTable Table) { managerTable = NewDefaultTable(DefaultConfigWithDriver(config.GetDatabases().GetDefault().Driver)) info := managerTable.GetInfo().AddXssJsFilter().HideFilterArea() @@ -450,6 +450,21 @@ func (s *SystemTable) GetNormalManagerTable(ctx *context.Context) (managerTable FieldDisplay(func(value types.FieldModel) interface{} { return "" }) + m := []types.FieldOption{} + m = append(m, types.FieldOption{ + Text: language.CN, + Value: "zh", + }, types.FieldOption{ + Text: language.EN, + Value: "en", + }, types.FieldOption{ + Text: language.JP, + Value: "jp", + }, types.FieldOption{ + Text: language.TC, + Value: "tc", + }) + formList.AddField(lg("language"), "language", db.Varchar, form.SelectSingle).FieldOptions(m).FieldNotAllowAdd() formList.SetTable("goadmin_users").SetTitle(lg("Managers")).SetDescription(lg("Managers")) formList.SetUpdateFn(func(values form2.Values) error { @@ -520,7 +535,7 @@ func (s *SystemTable) GetNormalManagerTable(ctx *context.Context) (managerTable return } -func (s *SystemTable) GetPermissionTable(ctx *context.Context) (permissionTable Table) { +func (s *SystemTable) GetPermissionTable(_ *context.Context) (permissionTable Table) { permissionTable = NewDefaultTable(DefaultConfigWithDriver(config.GetDatabases().GetDefault().Driver)) info := permissionTable.GetInfo().AddXssJsFilter().HideFilterArea() @@ -658,7 +673,7 @@ func (s *SystemTable) GetPermissionTable(ctx *context.Context) (permissionTable return } -func (s *SystemTable) GetRolesTable(ctx *context.Context) (roleTable Table) { +func (s *SystemTable) GetRolesTable(_ *context.Context) (roleTable Table) { roleTable = NewDefaultTable(DefaultConfigWithDriver(config.GetDatabases().GetDefault().Driver)) info := roleTable.GetInfo().AddXssJsFilter().HideFilterArea() @@ -815,7 +830,7 @@ func (s *SystemTable) GetRolesTable(ctx *context.Context) (roleTable Table) { return } -func (s *SystemTable) GetOpTable(ctx *context.Context) (opTable Table) { +func (s *SystemTable) GetOpTable(_ *context.Context) (opTable Table) { opTable = NewDefaultTable(Config{ Driver: config.GetDatabases().GetDefault().Driver, CanAdd: false, @@ -1039,7 +1054,7 @@ func (s *SystemTable) GetMenuTable(ctx *context.Context) (menuTable Table) { return } -func (s *SystemTable) GetSiteTable(ctx *context.Context) (siteTable Table) { +func (s *SystemTable) GetSiteTable(_ *context.Context) (siteTable Table) { siteTable = NewDefaultTable(DefaultConfigWithDriver(config.GetDatabases().GetDefault().Driver). SetOnlyUpdateForm(). SetGetDataFun(func(params parameter.Parameters) (i []map[string]interface{}, i2 int) { @@ -1383,7 +1398,7 @@ func (s *SystemTable) GetGenerateForm(ctx *context.Context) (generateTool Table) formList.AddField(lgWithScore("connection", "tool"), "conn", db.Varchar, form.SelectSingle). FieldOptions(ops). FieldOnChooseAjax("table", "/tool/choose/conn", - func(ctx *context.Context) (success bool, msg string, data interface{}) { + func(_ *context.Context) (success bool, msg string, data interface{}) { connName := ctx.FormValue("value") if connName == "" { return false, "wrong parameter", nil @@ -1402,7 +1417,7 @@ func (s *SystemTable) GetGenerateForm(ctx *context.Context) (generateTool Table) }) formList.AddField(lgWithScore("table", "tool"), "table", db.Varchar, form.SelectSingle). FieldOnChooseAjax("xxxx", "/tool/choose/table", - func(ctx *context.Context) (success bool, msg string, data interface{}) { + func(_ *context.Context) (success bool, msg string, data interface{}) { var ( tableName = ctx.FormValue("value") diff --git a/template/types/page.go b/template/types/page.go index 7de1e98c9..069be4dab 100644 --- a/template/types/page.go +++ b/template/types/page.go @@ -154,7 +154,7 @@ func NewPage(param *NewPageParam) *Page { Logo: logo, MiniLogo: config.GetMiniLogo(), ColorScheme: config.GetColorScheme(), - IndexUrl: config.GetIndexURL(), + IndexUrl: config.GetFullIndexURL(), CdnUrl: config.GetAssetUrl(), CustomHeadHtml: config.GetCustomHeadHtml(), CustomFootHtml: config.GetCustomFootHtml() + param.NavButtonsJS,