diff --git a/frontend/dashboard.html b/frontend/dashboard.html
new file mode 100644
index 0000000..5328d08
--- /dev/null
+++ b/frontend/dashboard.html
@@ -0,0 +1,336 @@
+
+
+
+
+
+ 猪场管理系统 - 控制台
+
+
+
+
+
+
+
+
+
📊 系统状态
+
当前系统运行正常
+
连接设备: 0 台
+
今日操作: 0 次
+
+
+
+
🌡️ 环境监控
+
温度: 25.6°C
+
湿度: 65%
+
空气质量: 良好
+
+
+
+
📡 设备连接
+
中继设备: 在线
+
风扇设备: 在线
+
水帘设备: 离线
+
+
+
+
+
⚙️ 设备控制
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/frontend/index.html b/frontend/index.html
new file mode 100644
index 0000000..0e7e52b
--- /dev/null
+++ b/frontend/index.html
@@ -0,0 +1,272 @@
+
+
+
+
+
+ 猪场管理系统 - 登录
+
+
+
+
+
🐷
+
猪场管理系统
+
请登录您的账户
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/internal/api/api.go b/internal/api/api.go
index 68e0e71..39c9d30 100644
--- a/internal/api/api.go
+++ b/internal/api/api.go
@@ -7,6 +7,7 @@ import (
"context"
"fmt"
"net/http"
+ "strings"
"time"
"git.huangwc.com/pig/pig-farm-controller/internal/api/middleware"
@@ -203,6 +204,26 @@ func (a *API) setupRoutes() {
}
}
+ // 使用NoRoute处理器处理前端路由
+ a.engine.NoRoute(func(c *gin.Context) {
+ path := c.Request.URL.Path
+
+ // 判断是否为API路径
+ if strings.HasPrefix(path, "/api/") || strings.HasPrefix(path, "/ws/") {
+ // API路径返回404
+ c.JSON(http.StatusNotFound, gin.H{
+ "error": "API路径未找到",
+ })
+ return
+ }
+
+ // 其他路径提供前端静态文件服务
+ c.File("./frontend/index.html")
+ })
+
+ // 静态文件服务 - 提供前端静态资源
+ a.engine.Static("/static", "./frontend/static")
+
// TODO: 添加更多路由
}
diff --git a/internal/core/application.go b/internal/core/application.go
index aacc36d..d902bb5 100644
--- a/internal/core/application.go
+++ b/internal/core/application.go
@@ -108,8 +108,8 @@ func (app *Application) Start() error {
app.logger.Info("API启动成功")
// 启动任务执行器组件
+ app.logger.Info("启动任务执行器")
app.TaskExecutor.Start()
- app.logger.Info("任务执行器启动成功")
return nil
}
@@ -123,8 +123,8 @@ func (app *Application) Stop() error {
}
// 停止任务执行器组件
+ app.logger.Info("停止任务执行器")
app.TaskExecutor.Stop()
- app.logger.Info("任务执行器已停止")
// 停止存储组件
if err := app.Storage.Disconnect(); err != nil {