fix: 化本
This commit is contained in:
3
run.sh
Normal file
3
run.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
cd /www/wwwroot/www.airtep.com2/usa
|
||||
git fetch origin && git reset --hard origin/master && npm run build && pm2 restart 3
|
||||
@@ -64,6 +64,9 @@ function broadcastSituation() {
|
||||
} catch (_) {}
|
||||
}
|
||||
app.set('broadcastSituation', broadcastSituation)
|
||||
if (typeof routes.setBroadcastSituation === 'function') {
|
||||
routes.setBroadcastSituation(broadcastSituation)
|
||||
}
|
||||
setInterval(broadcastSituation, 3000)
|
||||
|
||||
// 供爬虫调用:先从磁盘重载 DB(纳入爬虫写入),再更新 updated_at 并立即广播
|
||||
|
||||
@@ -5,6 +5,13 @@ const db = require('./db')
|
||||
|
||||
const router = express.Router()
|
||||
|
||||
/** 由 index.js 注入,确保修订后能触发 WebSocket 广播(不依赖 req.app) */
|
||||
let _broadcastSituation = null
|
||||
function setBroadcastSituation(fn) {
|
||||
_broadcastSituation = typeof fn === 'function' ? fn : null
|
||||
}
|
||||
router.setBroadcastSituation = setBroadcastSituation
|
||||
|
||||
// 简单鉴权:通过环境变量配置的 API_ADMIN_KEY 保护敏感接口(不返回真实密钥)
|
||||
const ADMIN_API_KEY = process.env.API_ADMIN_KEY || ''
|
||||
|
||||
@@ -202,7 +209,7 @@ router.get('/events', (req, res) => {
|
||||
// ---------- 手动修正看板数据(编辑页用) ----------
|
||||
function broadcastAfterEdit(req) {
|
||||
try {
|
||||
const broadcast = req.app?.get?.('broadcastSituation')
|
||||
const broadcast = _broadcastSituation || req.app?.get?.('broadcastSituation')
|
||||
if (typeof broadcast === 'function') broadcast()
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user