feat: 新增客户端问题主动上报与控制台问题汇总功能
1. 客户端 (ticketmachine.lua): 修改 showAlert 支持详细错误并主动上报,使用 pcall 包装主循环捕获 Fatal Error 并上报。 2. 服务端 (data.js, api.js): 增加 issues 数据表,提供 /report_issue 和 /issues 接口。 3. 控制台 (index.html, index.js): 添加“问题汇总”菜单及界面状态管理。
This commit is contained in:
@@ -1191,6 +1191,29 @@ router.get('/export', (req, res) => {
|
||||
res.json(DataService.buildExportPayload());
|
||||
});
|
||||
|
||||
// Issues
|
||||
router.post('/report_issue', async (req, res) => {
|
||||
const r = req.body || {};
|
||||
const item = {
|
||||
ts: Number(r.ts || Date.now()),
|
||||
device: String(r.device || 'unknown'),
|
||||
machine_id: String(r.machine_id || ''),
|
||||
station_code: String(r.station_code || ''),
|
||||
error_msg: String(r.error_msg || ''),
|
||||
detail: String(r.detail || ''),
|
||||
type: 'issue'
|
||||
};
|
||||
await DataService.appendIssue(item);
|
||||
io.emit('issue:new', item);
|
||||
appendReqLog(req, { category: 'device', type: 'report_issue', detail: item });
|
||||
res.json({ ok: true });
|
||||
});
|
||||
|
||||
router.get('/issues', (req, res) => {
|
||||
const issues = DataService.getIssues();
|
||||
res.json({ ok: true, issues });
|
||||
});
|
||||
|
||||
// Ticket Operations
|
||||
router.post('/tickets/sale', async (req, res) => {
|
||||
const { start, terminal, train_type, cost, station_code, device, trips_total, trips_remaining } = req.body || {};
|
||||
|
||||
Reference in New Issue
Block a user