feat: 初始化前后端Node.js控制台项目基础架构
- 创建项目核心文件:package.json、vite.config.js、.gitignore - 添加前后端基础依赖和开发工具配置 - 完善OpenSpec模块,包括项目文档和核心能力规格 - 配置ESLint和Prettier代码规范 - 创建基本目录结构 - 实现前端Vue3应用框架和路由 - 添加后端Express服务器和基础路由 - 编写README项目说明文档
This commit is contained in:
22
src/backend/routes/commands.js
Normal file
22
src/backend/routes/commands.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import express from 'express'
|
||||
const router = express.Router()
|
||||
|
||||
// 发送指令
|
||||
router.post('/', (req, res) => {
|
||||
const { command } = req.body
|
||||
|
||||
if (!command) {
|
||||
return res.status(400).json({
|
||||
success: false,
|
||||
message: '指令内容不能为空'
|
||||
})
|
||||
}
|
||||
|
||||
// 这里将实现发送指令到Redis队列的逻辑
|
||||
res.status(200).json({
|
||||
success: true,
|
||||
message: '指令已发送到Redis队列'
|
||||
})
|
||||
})
|
||||
|
||||
export default router
|
||||
12
src/backend/routes/logs.js
Normal file
12
src/backend/routes/logs.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import express from 'express'
|
||||
const router = express.Router()
|
||||
|
||||
// 获取日志列表
|
||||
router.get('/', (req, res) => {
|
||||
// 这里将实现从Redis读取日志的逻辑
|
||||
res.status(200).json({
|
||||
logs: []
|
||||
})
|
||||
})
|
||||
|
||||
export default router
|
||||
25
src/backend/server.js
Normal file
25
src/backend/server.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import express from 'express'
|
||||
import cors from 'cors'
|
||||
import logRoutes from './routes/logs.js'
|
||||
import commandRoutes from './routes/commands.js'
|
||||
|
||||
const app = express()
|
||||
const PORT = 3001
|
||||
|
||||
// 中间件
|
||||
app.use(cors())
|
||||
app.use(express.json())
|
||||
|
||||
// 路由
|
||||
app.use('/api/logs', logRoutes)
|
||||
app.use('/api/commands', commandRoutes)
|
||||
|
||||
// 健康检查
|
||||
app.get('/api/health', (req, res) => {
|
||||
res.status(200).json({ status: 'ok' })
|
||||
})
|
||||
|
||||
// 启动服务器
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Server running on port ${PORT}`)
|
||||
})
|
||||
Reference in New Issue
Block a user