@@ -9,44 +9,51 @@ More login interface components [see here](https://github.com/GoAdminGroup/compo
9
9
package main
10
10
11
11
import (
12
- " github.com/GoAdminGroup/demo/ecommerce"
13
- " github.com/GoAdminGroup/demo/login"
14
- " github.com/GoAdminGroup/demo/pages"
15
- _ " github.com/GoAdminGroup/go-admin/adapter/gin"
16
- _ " github.com/GoAdminGroup/go-admin/modules/db/drivers/mysql"
17
- _ " github.com/GoAdminGroup/themes/adminlte"
12
+ _ " github.com/GoAdminGroup/go-admin/adapter/gin"
13
+ _ " github.com/GoAdminGroup/go-admin/adapter/gin"
14
+ _ " github.com/GoAdminGroup/go-admin/modules/db/drivers/mysql"
15
+ // import the theme2 login theme, if you don`t use, don`t import
16
+ _ " github.com/GoAdminGroup/components/login/theme2"
17
+
18
+ " github.com/GoAdminGroup/components/login"
18
19
" github.com/GoAdminGroup/go-admin/engine"
19
20
" github.com/GoAdminGroup/go-admin/examples/datamodel"
20
21
" github.com/GoAdminGroup/go-admin/plugins/admin"
21
- " github.com/GoAdminGroup/go-admin/plugins/example"
22
- " github.com/GoAdminGroup/go-admin/template"
23
- " github.com/GoAdminGroup/go-admin/template/types"
24
22
" github.com/gin-gonic/gin"
23
+ " io/ioutil"
25
24
)
26
25
27
26
func main () {
28
27
r := gin.Default ()
29
28
30
- eng := engine.Default ()
31
-
32
- // Add login component
33
- template.AddLoginComp (login.GetLoginComponent ())
34
-
35
- // you can custom a plugin like:
29
+ gin.SetMode (gin.ReleaseMode )
30
+ gin.DefaultWriter = ioutil.Discard
36
31
37
- examplePlugin := example.NewExample ()
38
-
39
- rootPath := " /data/www/go-admin"
40
-
41
- if err := eng.AddConfigFromJson (rootPath+" /config.json" ).
42
- AddGenerators (datamodel.Generators ).
43
- AddGenerator (" user" , datamodel.GetUserTable ).
44
- AddPlugins (examplePlugin).
32
+ eng := engine.Default ()
33
+ adminPlugin := admin.NewAdmin (datamodel.Generators )
34
+ adminPlugin.AddGenerator (" user" , datamodel.GetUserTable )
35
+
36
+ // load the CAPTCHA driver if you use it
37
+ adminPlugin.SetCaptcha (map [string ]string {" driver" : login.CaptchaDriverKeyDefault })
38
+
39
+ // use the login theme component
40
+ login.Init (login.Config {
41
+ Theme: " theme2" , // theme name
42
+ CaptchaDigits: 5 , // Use captcha images, here on behalf of how many authentication code Numbers
43
+ // Use tencent verification code, need to offer appID and appSecret
44
+ // TencentWaterProofWallData: login.TencentWaterProofWallData{
45
+ // AppID:"",
46
+ // AppSecret: "",
47
+ // }
48
+ })
49
+
50
+ if err := eng.AddConfigFromJson (" ./config.json" ).
51
+ AddPlugins (adminPlugin).
45
52
Use (r); err != nil {
46
53
panic (err)
47
54
}
48
55
49
- r.Static (" /uploads" , rootPath+ " /uploads" )
56
+ r.Static (" /uploads" , " . /uploads" )
50
57
51
58
_ = r.Run (" :9033" )
52
59
}
0 commit comments