feat: add new file

This commit is contained in:
丹尼尔
2026-03-10 17:13:55 +08:00
commit 551abd1b68
4156 changed files with 805309 additions and 0 deletions

38
backend/server.js Normal file
View File

@@ -0,0 +1,38 @@
import express from 'express'
import cors from 'cors'
const app = express()
const PORT = process.env.PORT || 3000
app.use(cors({ origin: true }))
app.use(express.json())
// 实时数据(可后续接数据库)
const stats = {
nodes: 1280,
tasksToday: 45000,
hoursSaved: 8600,
}
// 模拟激活码(实际应查库或对接线下发码)
const VALID_CODES = new Set(['AX2024', 'DEMO', 'TEST'])
app.get('/api/stats', (req, res) => {
res.json(stats)
})
app.post('/api/activate', (req, res) => {
const { code } = req.body || {}
if (!code || typeof code !== 'string') {
return res.status(400).json({ message: '请提供激活码' })
}
const upper = code.trim().toUpperCase()
if (VALID_CODES.has(upper)) {
return res.json({ success: true, message: '激活成功' })
}
res.status(400).json({ message: '激活码无效或已使用' })
})
app.listen(PORT, () => {
console.log(`Backend running at http://localhost:${PORT}`)
})