1.修复关闭自动创建下一局后还自动创建下一期
This commit is contained in:
@@ -426,6 +426,11 @@ function handlePeriodTickEvent(periodData: anyObj): void {
|
||||
const status = typeof periodData.status === 'string' ? periodData.status : ''
|
||||
const periodNo = typeof periodData.period_no === 'string' ? periodData.period_no : ''
|
||||
const currentNo = typeof snapshot.record?.period_no === 'string' ? snapshot.record.period_no : ''
|
||||
const runtimeOff =
|
||||
toBool(snapshot.runtime_enabled) === false || toBool(periodData.runtime_enabled) === false
|
||||
if (runtimeOff && (status === 'betting' || status === 'locked')) {
|
||||
return
|
||||
}
|
||||
if (status === 'betting' && periodNo !== '' && periodNo !== currentNo) {
|
||||
void loadSnapshot({ force: true })
|
||||
return
|
||||
@@ -436,7 +441,7 @@ function handlePeriodTickEvent(periodData: anyObj): void {
|
||||
}
|
||||
return
|
||||
}
|
||||
if (currentNo === '' && periodNo !== '') {
|
||||
if (currentNo === '' && periodNo !== '' && !runtimeOff) {
|
||||
void loadSnapshot({ force: true })
|
||||
}
|
||||
}
|
||||
@@ -698,7 +703,13 @@ function mergeLiveSnapshot(data: anyObj): void {
|
||||
if (data.record !== undefined) {
|
||||
const nextId = data.record?.id != null ? Number(data.record.id) : null
|
||||
periodChanged = prevPeriodId !== null && nextId !== null && prevPeriodId !== nextId
|
||||
snapshot.record = data.record
|
||||
const runtimeOff = toBool(data.runtime_enabled) === false || toBool(snapshot.runtime_enabled) === false
|
||||
const serverMaintenance = data.maintenance_ui === true
|
||||
if (runtimeOff && serverMaintenance) {
|
||||
snapshot.record = null
|
||||
} else {
|
||||
snapshot.record = data.record
|
||||
}
|
||||
}
|
||||
|
||||
const incomingBets = Array.isArray(data.bets) ? data.bets : null
|
||||
@@ -835,9 +846,7 @@ async function loadSnapshot(options?: { force?: boolean }): Promise<void> {
|
||||
|
||||
async function onRuntimeSwitch(val: boolean | string | number): void {
|
||||
const on = toBool(val) === true
|
||||
// 防止某些场景下 model-value 变化触发重复 change 事件,造成 runtime 接口循环调用
|
||||
const current = toBool(snapshot.runtime_enabled) === true
|
||||
if (on === current) {
|
||||
if (runtimeSwitchLoading.value) {
|
||||
return
|
||||
}
|
||||
// el-switch 为受控组件(model-value 来自 snapshot),接口返回前先乐观更新,避免点击后立刻回弹
|
||||
|
||||
Reference in New Issue
Block a user