fix:修复相关问题,新增留言查看

This commit is contained in:
Daniel
2026-03-06 11:41:09 +08:00
parent cbac58af62
commit 97b04b6ccc
10 changed files with 252 additions and 12 deletions

View File

@@ -267,6 +267,10 @@ router.get('/edit/raw', (req, res) => {
try {
animationConfig = db.prepare('SELECT strike_cutoff_days FROM animation_config WHERE id = 1').get()
} catch (_) {}
let crawlerConfig = null
try {
crawlerConfig = db.prepare('SELECT rss_interval_sec FROM crawler_config WHERE id = 1').get()
} catch (_) {}
const realCumulative = db.prepare('SELECT total FROM visitor_count WHERE id = 1').get()?.total ?? 0
const realShare = db.prepare('SELECT total FROM share_count WHERE id = 1').get()?.total ?? 0
const liveViewers = db.prepare(
@@ -293,6 +297,9 @@ router.get('/edit/raw', (req, res) => {
animationConfig: {
strikeCutoffDays: animationConfig?.strike_cutoff_days ?? 5,
},
crawlerConfig: {
rssIntervalSec: crawlerConfig?.rss_interval_sec ?? 60,
},
})
} catch (err) {
console.error(err)
@@ -300,6 +307,33 @@ router.get('/edit/raw', (req, res) => {
}
})
/** GET 留言列表(修订页查看) */
router.get('/edit/feedback', (req, res) => {
try {
const list = db.prepare('SELECT id, content, ip, created_at FROM feedback ORDER BY id DESC LIMIT 500').all()
res.json({ list })
} catch (err) {
console.error('[edit/feedback]', err?.message || err)
// 表不存在或列缺失时返回空列表,避免修订页报错
res.json({ list: [] })
}
})
/** PUT 爬虫配置RSS 抓取间隔等,爬虫从同一 DB 读取) */
router.put('/edit/crawler-config', (req, res) => {
try {
const n = req.body?.rssIntervalSec
if (n === undefined) return res.status(400).json({ error: 'rssIntervalSec required' })
const val = parseInt(String(n), 10)
if (!Number.isFinite(val) || val < 30 || val > 86400) return res.status(400).json({ error: 'rssIntervalSec must be 3086400' })
db.prepare('INSERT OR REPLACE INTO crawler_config (id, rss_interval_sec) VALUES (1, ?)').run(val)
res.json({ ok: true, rssIntervalSec: val })
} catch (err) {
console.error(err)
res.status(500).json({ error: err.message })
}
})
/** PUT 更新战损(美/伊) */
router.put('/edit/combat-losses', (req, res) => {
try {