| | package main |
| |
|
| | import ( |
| | "log" |
| | "os" |
| | "os/signal" |
| | "time" |
| |
|
| | _ "github.com/GoAdminGroup/go-admin/adapter/gofiber" |
| | _ "github.com/GoAdminGroup/go-admin/modules/db/drivers/mysql" |
| | _ "github.com/GoAdminGroup/themes/adminlte" |
| |
|
| | "github.com/GoAdminGroup/go-admin/engine" |
| | "github.com/GoAdminGroup/go-admin/examples/datamodel" |
| | "github.com/GoAdminGroup/go-admin/modules/config" |
| | "github.com/GoAdminGroup/go-admin/modules/language" |
| | "github.com/GoAdminGroup/go-admin/plugins/example" |
| | "github.com/GoAdminGroup/go-admin/template" |
| | "github.com/GoAdminGroup/go-admin/template/chartjs" |
| |
|
| | "github.com/gofiber/fiber/v2" |
| | ) |
| |
|
| | func main() { |
| |
|
| | app := fiber.New(fiber.Config{ |
| | ServerHeader: "Fiber", |
| | }) |
| |
|
| | eng := engine.Default() |
| |
|
| | cfg := config.Config{ |
| | Env: config.EnvLocal, |
| | Databases: config.DatabaseList{ |
| | "default": { |
| | Host: "127.0.0.1", |
| | Port: "3306", |
| | User: "root", |
| | Pwd: "root", |
| | Name: "godmin", |
| | MaxIdleConns: 50, |
| | MaxOpenConns: 150, |
| | ConnMaxLifetime: time.Hour, |
| | Driver: config.DriverMysql, |
| | }, |
| | }, |
| | UrlPrefix: "admin", |
| | IndexUrl: "/", |
| | Store: config.Store{ |
| | Path: "./uploads", |
| | Prefix: "uploads", |
| | }, |
| | Debug: true, |
| | Language: language.CN, |
| | } |
| |
|
| | template.AddComp(chartjs.NewChart()) |
| |
|
| | |
| |
|
| | examplePlugin := example.NewExample() |
| |
|
| | |
| | |
| | |
| |
|
| | |
| | |
| | |
| | |
| |
|
| | |
| | |
| | |
| |
|
| | if err := eng.AddConfig(&cfg). |
| | AddGenerators(datamodel.Generators). |
| | AddDisplayFilterXssJsFilter(). |
| | |
| | |
| | |
| | |
| | |
| | AddGenerator("user", datamodel.GetUserTable). |
| | AddPlugins(examplePlugin). |
| | Use(app); err != nil { |
| | panic(err) |
| | } |
| |
|
| | eng.HTML("GET", "/admin", datamodel.GetContent) |
| |
|
| | _ = app.Listen(":8897") |
| |
|
| | quit := make(chan os.Signal, 1) |
| | signal.Notify(quit, os.Interrupt) |
| | <-quit |
| | log.Print("closing database connection") |
| | eng.MysqlConnection().Close() |
| | } |
| |
|