From 6c86c11e60edaf95f75f62912f7ebd615c77b605 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=A1=E5=A4=8D=E4=B9=A0?= <2353956224@qq.com> Date: Tue, 24 Mar 2026 14:17:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=8C=97=E4=BA=AC=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/GreetingDialog.vue | 62 +++++++++++++-- src/utils/pk-mini/timeConversion.js | 16 ++++ src/views/pk-mini/PkHall.vue | 113 +++++++++------------------- 3 files changed, 109 insertions(+), 82 deletions(-) diff --git a/src/components/GreetingDialog.vue b/src/components/GreetingDialog.vue index 12c3fe1..d13d558 100644 --- a/src/components/GreetingDialog.vue +++ b/src/components/GreetingDialog.vue @@ -70,9 +70,12 @@
-
@@ -212,9 +215,20 @@ const emit = defineEmits(['close', 'confirm']) const STORAGE_KEY = 'greeting_dialog_data' const REGION_LIST = getRegions() +// 为不同模式分别存储内容 const sentences = ref(['']) const bulkText = ref('') const inputMode = ref('bulk') // 'bulk' 或 'individual' +// 为两个模式分别存储内容 +const modeData = ref({ + bulk: { + sentences: [''], + bulkText: '' + }, + individual: { + sentences: [''] + } +}) const selectedRegions = ref([]) const translations = ref({}) const activeTab = ref('') @@ -286,18 +300,48 @@ watch(selectedLanguages, (newLangs) => { } }) +// 当模式切换时,保存当前模式的内容并加载新模式的内容 +watch(inputMode, (newMode, oldMode) => { + // 保存旧模式的内容 + if (oldMode) { + if (oldMode === 'bulk') { + modeData.value.bulk.sentences = [...sentences.value] + modeData.value.bulk.bulkText = bulkText.value + } else if (oldMode === 'individual') { + modeData.value.individual.sentences = [...sentences.value] + } + } + + // 加载新模式的内容 + if (newMode === 'bulk') { + sentences.value = [...modeData.value.bulk.sentences] + bulkText.value = modeData.value.bulk.bulkText + } else if (newMode === 'individual') { + sentences.value = [...modeData.value.individual.sentences] + needTranslate.value = false + } +}) + function loadFromStorage() { const saved = localStorage.getItem(STORAGE_KEY) if (saved) { try { const data = JSON.parse(saved) - if (data.sentences?.length) sentences.value = data.sentences + if (data.modeData) modeData.value = data.modeData if (data.selectedRegions?.length) selectedRegions.value = data.selectedRegions if (data.translations) translations.value = data.translations if (typeof data.needTranslate === 'boolean') needTranslate.value = data.needTranslate if (data.activeTab) activeTab.value = data.activeTab if (data.inputMode) inputMode.value = data.inputMode + + // 加载当前模式的内容 + if (inputMode.value === 'bulk') { + sentences.value = [...modeData.value.bulk.sentences] + bulkText.value = modeData.value.bulk.bulkText + } else if (inputMode.value === 'individual') { + sentences.value = [...modeData.value.individual.sentences] + } } catch (e) { console.error('加载本地数据失败:', e) } @@ -305,8 +349,16 @@ function loadFromStorage() { } function saveToStorage() { + // 保存当前模式的内容到 modeData + if (inputMode.value === 'bulk') { + modeData.value.bulk.sentences = [...sentences.value] + modeData.value.bulk.bulkText = bulkText.value + } else if (inputMode.value === 'individual') { + modeData.value.individual.sentences = [...sentences.value] + } + localStorage.setItem(STORAGE_KEY, JSON.stringify({ - sentences: sentences.value, + modeData: modeData.value, selectedRegions: selectedRegions.value, translations: translations.value, needTranslate: needTranslate.value, diff --git a/src/utils/pk-mini/timeConversion.js b/src/utils/pk-mini/timeConversion.js index 3ae7cd8..267356f 100644 --- a/src/utils/pk-mini/timeConversion.js +++ b/src/utils/pk-mini/timeConversion.js @@ -11,3 +11,19 @@ export function TimestamptolocalTime(date) { return `${year}/${month}/${day} ${hours}:${minutes}` } + +// 时间戳转换为北京时间,格式为 YYYY/MM/DD hh:mm +export function TimestampttoBeijingTime(date) { + if (!date || isNaN(date)) return '' + + const d = new Date(date) + // 北京时间是 UTC+8 + const beijingTime = new Date(d.getTime() + 8 * 60 * 60 * 1000) + const year = beijingTime.getUTCFullYear() + const month = String(beijingTime.getUTCMonth() + 1).padStart(2, '0') + const day = String(beijingTime.getUTCDate()).padStart(2, '0') + const hours = String(beijingTime.getUTCHours()).padStart(2, '0') + const minutes = String(beijingTime.getUTCMinutes()).padStart(2, '0') + + return `${year}/${month}/${day} ${hours}:${minutes}` +} diff --git a/src/views/pk-mini/PkHall.vue b/src/views/pk-mini/PkHall.vue index e792dd0..7541cd2 100644 --- a/src/views/pk-mini/PkHall.vue +++ b/src/views/pk-mini/PkHall.vue @@ -14,21 +14,9 @@
- - + +
@@ -46,15 +34,8 @@
- +
@@ -74,19 +55,10 @@
-
-
+
+
@@ -101,12 +73,14 @@ {{ item.country }}
-
PK时间(本地时间): {{ formatTime(item.pkTime * 1000) }}
+
PK时间(本地时间): {{ formatTime(item.pkTime * 1000) }} · 北京时间: {{ + TimestampttoBeijingTime(item.pkTime * 1000) }}
金币: {{ item.coin }}K - + 场次: {{ item.pkNumber }}场
@@ -125,13 +99,10 @@ 聊天 · {{ chatUserInfo.nickName }}
-
-
+
+
{{ msg.payload.text }}
@@ -155,11 +126,7 @@
发送
- +
@@ -170,13 +137,7 @@
- + @@ -185,13 +146,8 @@ 暂无可用主播,请先在"我的"页面添加主播
-
+
{{ anchor.anchorId }}
@@ -201,7 +157,8 @@ {{ anchor.coin }}K
-
PK时间: {{ formatTime(anchor.pkTime * 1000) }}
+
PK时间(本地时间): {{ formatTime(anchor.pkTime * 1000) }} · 北京时间: {{ + TimestampttoBeijingTime(anchor.pkTime * 1000) }}
@@ -222,7 +179,7 @@ import { ref, onMounted, onUnmounted, onActivated, nextTick } from 'vue' import { getPkList, getUserInfo, getAnchorListById, createPkRecord } from '@/api/pk-mini' import { getCountryNamesArray } from '@/utils/pk-mini/countryUtil' -import { TimestamptolocalTime } from '@/utils/pk-mini/timeConversion' +import { TimestamptolocalTime, TimestampttoBeijingTime } from '@/utils/pk-mini/timeConversion' import { getMainUserData } from '@/utils/pk-mini/storage' import { isGoEasyEnabled } from '@/config/pk-mini' import { @@ -405,7 +362,7 @@ async function handleItemClick(item) { // 隐藏后滚到底部再显示,避免视觉跳动 scrollToBottomHidden() // 标记消息已读 - goEasyMessageRead({ id: String(item.senderId) }).catch(() => {}) + goEasyMessageRead({ id: String(item.senderId) }).catch(() => { }) } else { messagesList.value = [] ElMessage.warning('聊天功能暂时不可用(GoEasy 订阅未续费)') @@ -463,14 +420,14 @@ async function sendMessage() { scrollToBottom() // 发送消息后标记已读,清除导航栏红点 const senderId = String(selectedItem.value.senderId) - goEasyMessageRead({ id: senderId }).catch(() => {}) + goEasyMessageRead({ id: senderId }).catch(() => { }) unreadStore.decrease(1) } catch (e) { console.error('发送消息失败', e) - if(e =='Error: id can not be the same as your id'){ + if (e == 'Error: id can not be the same as your id') { ElMessage.error('不能给自己发消息') - }else{ - ElMessage.error('发送失败') + } else { + ElMessage.error('发送失败') } } } @@ -741,7 +698,8 @@ onUnmounted(() => { gap: 8px; } -.search-btn, .reset-btn { +.search-btn, +.reset-btn { width: 80px; height: 30px; border-radius: 5px; @@ -765,7 +723,8 @@ onUnmounted(() => { color: #2563eb; // blue-600 } -.search-btn:hover, .reset-btn:hover { +.search-btn:hover, +.reset-btn:hover { transform: scale(1.05); opacity: 0.9; } @@ -1013,7 +972,7 @@ onUnmounted(() => { .control-btn:hover { background: white; - box-shadow: 2px 2px 5px rgba(0,0,0,0.1); + box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.1); } .control-btn img { @@ -1064,8 +1023,8 @@ onUnmounted(() => { .time-box.is-hidden { opacity: 0; - visibility: hidden; // 仍然占位,但看不见 - pointer-events: none; // 不能点击 + visibility: hidden; // 仍然占位,但看不见 + pointer-events: none; // 不能点击 } // 邀请弹窗样式