云上贵猪 2d5aa1d860 新增
1、浏览器自动获取,存本地
2、运行后端服务
3、vue启动获取
2026-03-11 03:01:56 +08:00

47 lines
1.2 KiB
JavaScript

import express from 'express'
import cors from 'cors'
import { ensureDataFiles, readCache, readStatus } from './lib/cache.js'
const app = express()
app.use(cors())
app.use(express.json())
ensureDataFiles()
app.get('/api/qishier/all', (_req, res) => {
try {
const cache = readCache()
res.json({
updatedAt: cache.updatedAt,
name: cache.name || '七十二家房客',
coverUrl: cache.coverUrl || '',
displayType: cache.displayType || 0,
total: cache.items?.length || 0,
beginScoreMap: cache.beginScoreMap || {},
pages: cache.pages || {},
list: cache.items || []
})
} catch (error) {
res.status(500).json({
message: '读取缓存失败',
error: error.message
})
}
})
app.get('/api/qishier/status', (_req, res) => {
try {
const status = readStatus()
res.json(status)
} catch (error) {
res.status(500).json({
message: '读取状态失败',
error: error.message
})
}
})
app.listen(3000, () => {
console.log('Node 服务已启动: http://localhost:3000')
})