Files
dypid/main.go
YGXB_net 819a2eb8ec
All checks were successful
部署开发环境 / deploy-dev (push) Successful in 8m30s
refactor: 重构项目结构并优化路由组织
2025-10-28 12:20:16 +08:00

40 lines
729 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package main
import (
"dypid/api"
"dypid/config"
"dypid/internal/db"
"embed"
"fmt"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
)
//go:embed web/dist/*
var webDir embed.FS
func main() {
config.InitConfig()
db.InitRedis()
db.InitLocalDB()
//初始化一个http服务对象
gin.SetMode(config.APPConfig.RunMode)
r := gin.Default()
//跨域设置
r.Use(cors.Default())
//注册网页服务Vue
api.RegWebService(r, webDir)
//注册API接口
api.RegRoutes(r)
// 监听并在 0.0.0.0:8080 上启动服务
fmt.Printf("服务器正在运行http://%s\n", config.APPConfig.Host)
err := r.Run(config.APPConfig.Host)
if err != nil {
fmt.Println("服务启动失败:", err)
return
}
}