更改登录界面


通过组件的方式可以修改登录界面,如下例子:

更多登录界面组件看这里;加载后引入即可。

  1. package main
  2. import (
  3. "github.com/GoAdminGroup/demo/login"
  4. "github.com/GoAdminGroup/demo/pages"
  5. _ "github.com/GoAdminGroup/go-admin/adapter/gin"
  6. _ "github.com/GoAdminGroup/go-admin/modules/db/drivers/mysql"
  7. _ "github.com/GoAdminGroup/themes/adminlte"
  8. "github.com/GoAdminGroup/go-admin/engine"
  9. "github.com/GoAdminGroup/go-admin/examples/datamodel"
  10. "github.com/GoAdminGroup/go-admin/plugins/admin"
  11. "github.com/GoAdminGroup/go-admin/plugins/example"
  12. "github.com/GoAdminGroup/go-admin/template"
  13. "github.com/GoAdminGroup/go-admin/template/types"
  14. "github.com/gin-gonic/gin"
  15. )
  16. func main() {
  17. r := gin.Default()
  18. eng := engine.Default()
  19. adminPlugin := admin.NewAdmin(datamodel.Generators)
  20. adminPlugin.AddGenerator("user", datamodel.GetUserTable)
  21. // 增加登录组件
  22. template.AddLoginComp(login.GetLoginComponent())
  23. // you can custom a plugin like:
  24. examplePlugin := example.NewExample()
  25. rootPath := "/data/www/go-admin"
  26. if err := eng.AddConfigFromJson(rootPath+"/config.json").AddPlugins(adminPlugin, examplePlugin).Use(r); err != nil {
  27. panic(err)
  28. }
  29. r.Static("/uploads", rootPath+"/uploads")
  30. _ = r.Run(":9033")
  31. }