fix: some
All checks were successful
构建并部署前端到生产环境 / build-and-deploy (push) Successful in 2m16s

This commit is contained in:
luo
2026-10-13 18:02:13 +08:00
parent 97dec4dc65
commit 697ff9c33c
6 changed files with 263 additions and 54 deletions

View File

@@ -3,8 +3,6 @@
<UserInfoCard :currentCardNo="currentCardNo" :deviceInfo="deviceInfo" :onlineStatus="onlineStatus"
:isDevice="userInfo.isDevice" :networkStatus="deviceInfo.network_status"
:isExpiring="deviceInfo.isExpiring" :expiryDays="deviceInfo.expiryDays" @renew="startHomepageRenewal" />
<ExpiryReminderBanner v-if="visibleExpiryReminder" :reminder="visibleExpiryReminder"
@close="closeExpiryReminder" />
<DeviceStatusCard v-if="userInfo.isDevice" :deviceInfo="deviceInfo" :isRealName="isRealName"
:isDevice="userInfo.isDevice" @authentication="enterDetail('authentication')" />
@@ -99,6 +97,8 @@
</FunctionCard>
<view class="bottom-spacer"></view>
<ExpiryReminderPopup v-if="visibleExpiryReminder" :reminder="visibleExpiryReminder"
@close="closeExpiryReminder" />
<NotificationPopup :show="notificationPopupShow" :items="notificationItems"
:current="notificationPopupCurrent" @change="onNotificationChange" @close="closeNotificationPopup"
@@ -140,7 +140,7 @@
import FunctionCard from '@/components/FunctionCard.vue';
import FloatingButton from '@/components/FloatingButton.vue';
import NotificationPopup from '@/components/NotificationPopup.vue';
import ExpiryReminderBanner from '@/components/ExpiryReminderBanner.vue';
import ExpiryReminderPopup from '@/components/ExpiryReminderPopup.vue';
import RenewalPaymentPopup from '@/components/RenewalPaymentPopup.vue';
import PopupCandidate from '@/components/PopupCandidate.vue';
import {
@@ -161,6 +161,10 @@
const assetStore = useAssetStore();
const homeActive = ref(false);
const shownExpiryReminder = ref(null);
const awaitingHomeReminders = ref(false);
let notificationFallbackPending = false;
let notificationQueued = false;
let homeEntryId = 0;
const visibleExpiryReminder = computed(() => {
const entry = shownExpiryReminder.value;
return homeActive.value && entry && isCurrentSession(entry) && entry.day === getShanghaiDay()
@@ -168,15 +172,31 @@
});
const showPendingExpiryReminder = () => {
const entry = assetStore.state.expiryReminder;
if (!homeActive.value || !entry || entry.shown || !isCurrentSession(entry) || entry.day !== getShanghaiDay()) return;
if (!homeActive.value || awaitingHomeReminders.value || popupCandidateShow.value || notificationPopupShow.value ||
visibleExpiryReminder.value || !entry || entry.shown || !isCurrentSession(entry) || entry.day !== getShanghaiDay()) return;
shownExpiryReminder.value = { ...entry };
assetStore.markExpiryReminderShown();
};
const closeExpiryReminder = () => {
shownExpiryReminder.value = null;
assetStore.dismissExpiryReminder();
advanceHomePopupQueue();
};
watch(() => assetStore.state.expiryReminder, showPendingExpiryReminder);
const advanceHomePopupQueue = () => {
if (!homeActive.value || awaitingHomeReminders.value || popupCandidateShow.value ||
visibleExpiryReminder.value || notificationPopupShow.value) return;
showPendingExpiryReminder();
if (visibleExpiryReminder.value) return;
if (notificationQueued) {
notificationQueued = false;
notificationPopupShow.value = true;
markNotificationRead(notificationItems.value[0]);
} else if (notificationFallbackPending) {
notificationFallbackPending = false;
loadUnreadNotifications();
}
};
watch(() => assetStore.state.expiryReminder, advanceHomePopupQueue);
let showModifyWifi = ref(false);
let restartShow = ref(false);
@@ -899,18 +919,18 @@
const loadUnreadNotifications = async () => {
const context = getSessionContext();
const entryId = homeEntryId;
try {
const data = await notificationApi.getList(1, 50, false);
if (!homeActive.value || !isCurrentSession(context)) return;
if (!homeActive.value || entryId !== homeEntryId || !isCurrentSession(context)) return;
const items = (data?.items || [])
.filter(item => !item.is_read && item.category !== 'expiry');
if (!items.length) return;
notificationItems.value = items;
notificationPopupCurrent.value = 0;
notificationPopupShow.value = true;
// 弹窗打开即视为用户已看到第一条通知。
markNotificationRead(items[0]);
notificationQueued = true;
advanceHomePopupQueue();
} catch (error) {
console.error('加载首页未读通知失败', error);
}
@@ -931,6 +951,7 @@
const closeNotificationPopup = () => {
notificationPopupShow.value = false;
advanceHomePopupQueue();
};
const runPopupCandidate = () => {
@@ -938,10 +959,12 @@
};
const onPopupCandidateClose = (reason) => {
if (!homeActive.value) return;
popupCandidateShow.value = false;
if (reason === 'empty' || reason === 'invisible') {
loadUnreadNotifications();
notificationFallbackPending = true;
}
advanceHomePopupQueue();
loadNotificationUnreadCount();
};
@@ -949,31 +972,44 @@
initCurrentMonth();
});
onShow(() => {
onShow(async () => {
const entryId = ++homeEntryId;
homeActive.value = true;
shownExpiryReminder.value = null;
showPendingExpiryReminder();
awaitingHomeReminders.value = true;
notificationFallbackPending = false;
notificationQueued = false;
if (!getSessionContext().token) {
awaitingHomeReminders.value = false;
handleIndexEntry();
return;
}
if (consumePendingPaymentRefresh(PAYMENT_REFRESH_TARGETS.HOME)) {
loadAssetInfo();
}
handleIndexEntry();
loadNotificationUnreadCount();
runPopupCandidate();
await handleIndexEntry();
if (!homeActive.value || entryId !== homeEntryId) return;
awaitingHomeReminders.value = false;
advanceHomePopupQueue();
});
onHide(() => {
homeEntryId++;
homeActive.value = false;
shownExpiryReminder.value = null;
notificationPopupShow.value = false;
popupCandidateShow.value = false;
notificationQueued = false;
notificationFallbackPending = false;
});
watch(() => [userStore.state.token, userStore.state.identifier], () => {
shownExpiryReminder.value = null;
notificationItems.value = [];
notificationUnreadCount.value = 0;
notificationPopupShow.value = false;
notificationQueued = false;
notificationFallbackPending = false;
});
</script>