| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- package main
- import (
- _ "github.com/GoAdminGroup/go-admin/adapter/gin" // web framework adapter
- _ "github.com/GoAdminGroup/go-admin/modules/db/drivers/sqlite" // sql driver
- _ "github.com/GoAdminGroup/themes/adminlte" // ui theme
- "github.com/GoAdminGroup/example/pages"
- "github.com/GoAdminGroup/example/tables"
- "github.com/GoAdminGroup/go-admin/engine"
- "github.com/GoAdminGroup/go-admin/template"
- "github.com/GoAdminGroup/go-admin/template/chartjs"
- "github.com/gin-gonic/gin"
- "io/ioutil"
- )
- func main() {
- r := gin.Default()
- gin.SetMode(gin.ReleaseMode)
- gin.DefaultWriter = ioutil.Discard
- eng := engine.Default()
- template.AddComp(chartjs.NewChart())
- //cfg := config.Config{
- // Databases: config.DatabaseList{
- // "default": {
- // Host: "127.0.0.1",
- // Port: "3306",
- // User: "root",
- // Pwd: "root",
- // Name: "go-admin",
- // MaxIdleCon: 50,
- // MaxOpenCon: 150,
- // Driver: db.DriverMysql,
- // },
- // },
- // UrlPrefix: "admin",
- // IndexUrl: "/",
- // Debug: true,
- // Language: language.CN,
- //}
- if err := eng.AddConfigFromJSON("./config.json").
- AddGenerators(tables.Generators).
- AddGenerator("external", tables.GetExternalTable).
- Use(r); err != nil {
- panic(err)
- }
- r.Static("/uploads", "./uploads")
- eng.HTML("GET", "/admin", DashboardPage)
- eng.HTML("GET", "/admin/form", pages.GetFormContent)
- eng.HTML("GET", "/admin/table", pages.GetTableContent)
- eng.HTMLFile("GET", "/admin/hello", "./html/hello.tmpl", map[string]interface{}{
- "msg": "Hello world",
- })
- _ = r.Run(":9033")
- }
|