diff --git a/resources/views/chat/partials/games/baccarat-panel.blade.php b/resources/views/chat/partials/games/baccarat-panel.blade.php index c8ff424..055e32b 100644 --- a/resources/views/chat/partials/games/baccarat-panel.blade.php +++ b/resources/views/chat/partials/games/baccarat-panel.blade.php @@ -490,17 +490,39 @@ const min = this.minBet || 100; const max = this.maxBet || 50000; - // 生成阶梯:最小值, 10倍, 100倍, 500倍, 最大值 - // 并确保每个阶梯都不超过最大值,最后去重排序取前5个 - let steps = [ - min, - min * 10, - min * 100, - min * 500, - max - ].map(v => Math.min(v, max)); - - return [...new Set(steps)].sort((a, b) => a - b).slice(0, 5); + // 预设候选倍数,尽量生成美观的数字 + const candidates = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000]; + let steps = candidates.map(m => min * m).filter(v => v >= min && v < max); + steps.push(max); + steps = [...new Set(steps)].sort((a, b) => a - b); + + if (steps.length >= 5) { + // 如果候选值足够多,均匀采样,确保首尾是最小值和最大值 + return [ + steps[0], + steps[Math.floor((steps.length - 1) * 0.25)], + steps[Math.floor((steps.length - 1) * 0.5)], + steps[Math.floor((steps.length - 1) * 0.75)], + steps[steps.length - 1] + ]; + } else { + // 如果候选值不足5个(范围太小),通过线性插值补齐 + while (steps.length < 5) { + let maxGap = 0; + let insertIdx = -1; + for (let i = 0; i < steps.length - 1; i++) { + if (steps[i+1] - steps[i] > maxGap) { + maxGap = steps[i+1] - steps[i]; + insertIdx = i; + } + } + if (insertIdx === -1) break; + let newVal = Math.floor((steps[insertIdx] + steps[insertIdx+1]) / 2); + if (newVal > 100) newVal = Math.floor(newVal / 10) * 10; // 简单取整 + steps.splice(insertIdx + 1, 0, newVal); + } + return steps; + } }, /** diff --git a/resources/views/chat/partials/games/horse-race-panel.blade.php b/resources/views/chat/partials/games/horse-race-panel.blade.php index 3107f42..6b4de89 100644 --- a/resources/views/chat/partials/games/horse-race-panel.blade.php +++ b/resources/views/chat/partials/games/horse-race-panel.blade.php @@ -435,16 +435,39 @@ const min = this.minBet || 100; const max = this.maxBet || 100000; - // 生成阶梯:最小值, 10倍, 100倍, 500倍, 最大值 - let steps = [ - min, - min * 10, - min * 100, - min * 500, - max - ].map(v => Math.min(v, max)); - - return [...new Set(steps)].sort((a, b) => a - b).slice(0, 5); + // 预设候选倍数,尽量生成美观的数字 + const candidates = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000]; + let steps = candidates.map(m => min * m).filter(v => v >= min && v < max); + steps.push(max); + steps = [...new Set(steps)].sort((a, b) => a - b); + + if (steps.length >= 5) { + // 如果候选值足够多,均匀采样,确保首尾是最小值和最大值 + return [ + steps[0], + steps[Math.floor((steps.length - 1) * 0.25)], + steps[Math.floor((steps.length - 1) * 0.5)], + steps[Math.floor((steps.length - 1) * 0.75)], + steps[steps.length - 1] + ]; + } else { + // 如果候选值不足5个(范围太小),通过线性插值补齐 + while (steps.length < 5) { + let maxGap = 0; + let insertIdx = -1; + for (let i = 0; i < steps.length - 1; i++) { + if (steps[i+1] - steps[i] > maxGap) { + maxGap = steps[i+1] - steps[i]; + insertIdx = i; + } + } + if (insertIdx === -1) break; + let newVal = Math.floor((steps[insertIdx] + steps[insertIdx+1]) / 2); + if (newVal > 100) newVal = Math.floor(newVal / 10) * 10; + steps.splice(insertIdx + 1, 0, newVal); + } + return steps; + } }, /**