Customize Login Page
You can modify the login interface by means of components, as in the following example:
More login interface components see here;It can be introduced after loading.
1
package main
2
3
import (
4
_ "github.com/GoAdminGroup/go-admin/adapter/gin"
5
_ "github.com/GoAdminGroup/go-admin/adapter/gin"
6
_ "github.com/GoAdminGroup/go-admin/modules/db/drivers/mysql"
7
// import the theme2 login theme, if you don`t use, don`t import
8
_ "github.com/GoAdminGroup/components/login/theme2"
9
10
"github.com/GoAdminGroup/components/login"
11
"github.com/GoAdminGroup/go-admin/engine"
12
"github.com/GoAdminGroup/go-admin/examples/datamodel"
13
"github.com/GoAdminGroup/go-admin/plugins/admin"
14
"github.com/gin-gonic/gin"
15
"io/ioutil"
16
)
17
18
func main() {
19
r := gin.Default()
20
21
gin.SetMode(gin.ReleaseMode)
22
gin.DefaultWriter = ioutil.Discard
23
24
eng := engine.Default()
25
adminPlugin := admin.NewAdmin(datamodel.Generators)
26
adminPlugin.AddGenerator("user", datamodel.GetUserTable)
27
28
// load the CAPTCHA driver if you use it
29
adminPlugin.SetCaptcha(map[string]string{"driver": login.CaptchaDriverKeyDefault})
30
31
// use the login theme component
32
login.Init(login.Config{
33
Theme: "theme2", // theme name
34
CaptchaDigits: 5, // Use captcha images, here on behalf of how many authentication code Numbers
35
// Use tencent verification code, need to offer appID and appSecret
36
// TencentWaterProofWallData: login.TencentWaterProofWallData{
37
// AppID:"",
38
// AppSecret: "",
39
// }
40
})
41
42
if err := eng.AddConfigFromJson("./config.json").
43
AddPlugins(adminPlugin).
44
Use(r); err != nil {
45
panic(err)
46
}
47
48
r.Static("/uploads", "./uploads")
49
50
_ = r.Run(":9033")
51
}
Copied!
Last modified 1yr ago
Copy link