修复钓鱼通知与游戏配置保存问题
This commit is contained in:
@@ -241,6 +241,7 @@ function startAutoFishingCooldown(cooldown) {
|
||||
autoFishCooldownCountdown = window.setInterval(() => {
|
||||
const remaining = Math.max(0, Math.ceil((endTime - Date.now()) / 1000));
|
||||
setFishingButton(`⏳ 冷却 ${remaining}s`, true);
|
||||
updateAutoFishStopButtonCountdown(remaining);
|
||||
|
||||
if (remaining <= 0) {
|
||||
window.clearInterval(autoFishCooldownCountdown);
|
||||
@@ -299,6 +300,22 @@ function showAutoFishStopButton(cooldown) {
|
||||
document.body.appendChild(button);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步更新停止自动钓鱼浮层上的冷却秒数,避免与主按钮倒计时不一致。
|
||||
*
|
||||
* @param {number} cooldown
|
||||
* @returns {void}
|
||||
*/
|
||||
function updateAutoFishStopButtonCountdown(cooldown) {
|
||||
const hint = document.querySelector("#auto-fish-stop-btn .drag-hint");
|
||||
|
||||
if (!(hint instanceof HTMLElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
hint.textContent = `冷却 ${Number(cooldown) || 0}s · 可拖动`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 给停止自动钓鱼按钮绑定拖拽和点击停止事件。
|
||||
*
|
||||
|
||||
@@ -81,7 +81,26 @@ function isRedPacketAnnouncementMessage(msg) {
|
||||
function buildRedPacketAnnouncementHtml(msg, timeStr) {
|
||||
const rawContent = String(msg?.content || "");
|
||||
const isExpPacket = rawContent.includes("经验的礼包");
|
||||
const accentColor = isExpPacket ? "#7c3aed" : "#dc2626";
|
||||
const colorPalette = isExpPacket
|
||||
? {
|
||||
accent: "#16a34a",
|
||||
text: "#166534",
|
||||
softBackground: "linear-gradient(135deg,#f0fdf4,#f7fee7)",
|
||||
softBorder: "rgba(22,163,74,.18)",
|
||||
chipBackground: "#dcfce7",
|
||||
chipBorder: "#86efac",
|
||||
chipText: "#15803d",
|
||||
}
|
||||
: {
|
||||
accent: "#dc2626",
|
||||
text: "#b91c1c",
|
||||
softBackground: "linear-gradient(135deg,#fef2f2,#fff7ed)",
|
||||
softBorder: "rgba(220,38,38,.18)",
|
||||
chipBackground: "#fee2e2",
|
||||
chipBorder: "#fca5a5",
|
||||
chipText: "#dc2626",
|
||||
};
|
||||
const accentColor = colorPalette.accent;
|
||||
const typeLabel = isExpPacket ? "经验礼包" : "金币礼包";
|
||||
const icon = isExpPacket ? "✨" : "🧧";
|
||||
const buttonMatch = rawContent.match(/<button\b([^>]*)>([\s\S]*?)<\/button>/iu);
|
||||
@@ -99,12 +118,12 @@ function buildRedPacketAnnouncementHtml(msg, timeStr) {
|
||||
const actionButtonHtml = `<button type="button"${buttonOnclick ? ` onclick="${escapeHtml(buttonOnclick)}"` : ""} style="display:inline-flex;align-items:center;padding:2px 9px;border-radius:999px;background:${accentColor};color:#fff;font-size:11px;font-weight:700;line-height:1;border:1px solid ${accentColor};cursor:pointer;box-shadow:none;vertical-align:middle;">${escapeHtml(buttonLabel)}</button>`;
|
||||
|
||||
return `
|
||||
<div style="display:flex;align-items:center;gap:7px;padding:5px 9px;border-radius:11px;background:linear-gradient(135deg,${isExpPacket ? "#f5f3ff,#faf5ff" : "#fef2f2,#fff7ed"});border:1px solid ${isExpPacket ? "rgba(124,58,237,.16)" : "rgba(220,38,38,.16)"};box-shadow:0 4px 12px rgba(15,23,42,.045);overflow:hidden;">
|
||||
<div style="width:23px;height:23px;border-radius:7px;background:${accentColor};display:flex;align-items:center;justify-content:center;color:#fff;font-size:13px;box-shadow:0 2px 6px ${isExpPacket ? "rgba(124,58,237,.16)" : "rgba(220,38,38,.16)"};flex-shrink:0;">${icon}</div>
|
||||
<div style="min-width:0;flex:1;display:flex;align-items:center;gap:7px;flex-wrap:wrap;color:${isExpPacket ? "#5b21b6" : "#b91c1c"};">
|
||||
<div style="display:flex;align-items:center;gap:7px;padding:5px 9px;border-radius:11px;background:${colorPalette.softBackground};border:1px solid ${colorPalette.softBorder};box-shadow:0 4px 12px rgba(15,23,42,.045);overflow:hidden;">
|
||||
<div style="width:23px;height:23px;border-radius:7px;background:${accentColor};display:flex;align-items:center;justify-content:center;color:#fff;font-size:13px;box-shadow:0 2px 6px ${colorPalette.softBorder};flex-shrink:0;">${icon}</div>
|
||||
<div style="min-width:0;flex:1;display:flex;align-items:center;gap:7px;flex-wrap:wrap;color:${colorPalette.text};">
|
||||
<div style="display:flex;align-items:center;gap:6px;flex-wrap:wrap;flex-shrink:0;">
|
||||
${buildGameLabelChipHtml("礼包红包", accentColor)}
|
||||
<span style="display:inline-flex;align-items:center;padding:2px 9px;border-radius:999px;background:${accentColor}1A;color:${accentColor};font-size:11px;font-weight:700;line-height:1;border:1px solid ${accentColor}33;">${escapeHtml(typeLabel)}</span>
|
||||
<span style="display:inline-flex;align-items:center;padding:2px 9px;border-radius:999px;background:${colorPalette.chipBackground};color:${colorPalette.chipText};font-size:11px;font-weight:700;line-height:1;border:1px solid ${colorPalette.chipBorder};">${escapeHtml(typeLabel)}</span>
|
||||
</div>
|
||||
<div style="display:flex;align-items:center;gap:5px;flex-wrap:wrap;font-size:12px;line-height:1.25;font-weight:700;min-width:200px;flex:1;">
|
||||
<span>${summary}</span>
|
||||
@@ -130,6 +149,26 @@ function buildQuizBadgeHtml(msg, accentColor = "#7c3aed") {
|
||||
`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前公屏消息是否属于“我自己”的钓鱼结果广播。
|
||||
*
|
||||
* 说明:
|
||||
* - 收竿后,钓鱼者本人已经会在包厢窗口收到本地结果提示;
|
||||
* - 这里需要把同一条公屏广播对本人隐藏,避免自己同时看到两条。
|
||||
*/
|
||||
function isOwnFishingResultBroadcast(msg) {
|
||||
const currentUsername = String(window.chatContext?.username || "").trim();
|
||||
const fishingUsername = String(msg?.fishing_username || "").trim();
|
||||
|
||||
if (!currentUsername) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return String(msg?.from_user || "") === "钓鱼播报"
|
||||
&& String(msg?.action || "") === "fishing_result"
|
||||
&& fishingUsername === currentUsername;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前消息是否应该使用统一的游戏通知卡片。
|
||||
*/
|
||||
@@ -549,6 +588,10 @@ export function appendMessage(msg, renderBatch = null) {
|
||||
|
||||
state.trackMaxMsgId(msg.id || 0);
|
||||
|
||||
if (isOwnFishingResultBroadcast(msg)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const quizMeta = normalizeQuizRoundPayload(msg);
|
||||
const idiomRoundId = quizMeta.roundId;
|
||||
const isIdiomStartMessage = isQuizStartMessage(msg)
|
||||
|
||||
Reference in New Issue
Block a user